Requested changes

This commit is contained in:
Brady
2023-07-18 16:48:00 -05:00
parent 0239a2cad4
commit 218de1cb98
4 changed files with 12 additions and 26 deletions

View File

@@ -66,7 +66,6 @@ public class Baritone implements IBaritone {
private final GameEventHandler gameEventHandler;
private final List<IBehavior> behaviors;
private final PathingBehavior pathingBehavior;
private final LookBehavior lookBehavior;
private final InventoryBehavior inventoryBehavior;
@@ -93,7 +92,6 @@ public class Baritone implements IBaritone {
Baritone(Minecraft mc) {
this.mc = mc;
this.behaviors = new ArrayList<>();
this.gameEventHandler = new GameEventHandler(this);
this.directory = mc.gameDir.toPath().resolve("baritone");
@@ -131,12 +129,9 @@ public class Baritone implements IBaritone {
this.worldProvider = new WorldProvider(this);
this.selectionManager = new SelectionManager(this);
this.commandManager = new CommandManager(this);
this.behaviors.forEach(IBehavior::onLoad);
}
public void registerBehavior(IBehavior behavior) {
this.behaviors.add(behavior);
this.gameEventHandler.registerEventListener(behavior);
}

View File

@@ -42,15 +42,14 @@ import baritone.utils.PathingCommandContext;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
public class ElytraProcess extends BaritoneProcessHelper implements IBaritoneProcess, IElytraProcess, AbstractGameEventListener {
public State state;
private Goal goal;
private LegacyElytraBehavior behavior;
private ElytraProcess(Baritone baritone) {
super(baritone);
this.behavior = new LegacyElytraBehavior(baritone, this);
baritone.getGameEventHandler().registerEventListener(this);
}
@@ -60,11 +59,9 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
: new NullElytraProcess(baritone));
}
@Override
public boolean isActive() {
return behavior != null;
return this.behavior != null;
}
@Override
@@ -78,7 +75,7 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
@Override
public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) {
final long seedSetting = Baritone.settings().elytraNetherSeed.value;
if (seedSetting != behavior.context.getSeed()) {
if (seedSetting != this.behavior.context.getSeed()) {
logDirect("Nether seed changed, recalculating path");
this.resetState();
}
@@ -232,11 +229,11 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
@Override
public void pathTo(BlockPos destination) {
this.behavior = new LegacyElytraBehavior(this.baritone, this);
this.behavior = new LegacyElytraBehavior(this.baritone, this, destination);
if (ctx.world() != null) {
this.behavior.repackChunks();
}
this.behavior.pathTo(destination);
this.behavior.pathTo();
}
@Override
@@ -275,7 +272,7 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
if (event.getWorld() != null && event.getState() == EventState.POST && this.behavior != null) {
// Exiting the world, just destroy
this.behavior.destroy();
this.behavior = new LegacyElytraBehavior(baritone, this);
this.behavior = null;
}
}

View File

@@ -74,7 +74,7 @@ public final class LegacyElytraBehavior implements Helper {
public List<BetterBlockPos> visiblePath;
// :sunglasses:
public final NetherPathfinderContext context; // TODO: make this final
public final NetherPathfinderContext context;
public final PathManager pathManager;
private final ElytraProcess process;
@@ -100,7 +100,7 @@ public final class LegacyElytraBehavior implements Helper {
private BlockStateInterface bsi;
private final BlockStateOctreeInterface boi;
public BlockPos destination; // TODO: make this final?
public final BlockPos destination;
private final ExecutorService solverExecutor;
private Future<Solution> solver;
@@ -113,13 +113,14 @@ public final class LegacyElytraBehavior implements Helper {
private int invTickCountdown = 0;
private final Queue<Runnable> invTransactionQueue = new LinkedList<>();
public LegacyElytraBehavior(Baritone baritone, ElytraProcess process) {
public LegacyElytraBehavior(Baritone baritone, ElytraProcess process, BlockPos destination) {
this.baritone = baritone;
this.ctx = baritone.getPlayerContext();
this.clearLines = new CopyOnWriteArrayList<>();
this.blockedLines = new CopyOnWriteArrayList<>();
this.pathManager = this.new PathManager();
this.process = process;
this.destination = destination;
this.solverExecutor = Executors.newSingleThreadExecutor();
this.nextTickBoostCounter = new int[2];
@@ -428,8 +429,7 @@ public final class LegacyElytraBehavior implements Helper {
}
}
public void pathTo(BlockPos destination) {
this.destination = destination;
public void pathTo() {
if (!Baritone.settings().elytraAutoJump.value || ctx.player().isElytraFlying()) {
this.pathManager.pathToDestination();
}