Skip to content

Commit 3d5b744

Browse files
committed
fixes
1 parent 04813a8 commit 3d5b744

File tree

4 files changed

+27
-20
lines changed

4 files changed

+27
-20
lines changed

src/main/java/baritone/process/ElytraProcess.java

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import baritone.utils.BaritoneProcessHelper;
4545
import baritone.utils.PathingCommandContext;
4646
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
47+
import net.minecraft.ChatFormatting;
4748
import net.minecraft.core.BlockPos;
4849
import net.minecraft.core.NonNullList;
4950
import net.minecraft.world.entity.EquipmentSlot;
@@ -112,20 +113,25 @@ public void resetState() {
112113

113114
@Override
114115
public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) {
115-
final long seedSetting = Baritone.settings().elytraNetherSeed.value;
116-
if (seedSetting != this.behavior.context.getSeed()) {
117-
logDirect("Nether seed changed, recalculating path");
118-
this.resetState();
119-
}
120-
if (predictingTerrain != Baritone.settings().elytraPredictTerrain.value && ctx.player().level.dimension() == Level.NETHER) {
121-
logDirect("elytraPredictTerrain setting changed, recalculating path from scratch");
122-
predictingTerrain = Baritone.settings().elytraPredictTerrain.value;
123-
this.resetState();
124-
}
125-
if (allowTight != Baritone.settings().elytraAllowTightSpaces.value) {
126-
logDirect("elytraAllowTightSpaces setting changed, recalculating path from scratch");
127-
allowTight = Baritone.settings().elytraAllowTightSpaces.value;
128-
this.resetState();
116+
try {
117+
final long seedSetting = Baritone.settings().elytraNetherSeed.value;
118+
if (seedSetting != this.behavior.context.getSeed()) {
119+
logDirect("Nether seed changed, recalculating path");
120+
this.resetState();
121+
}
122+
if (predictingTerrain != Baritone.settings().elytraPredictTerrain.value && ctx.player().level.dimension() == Level.NETHER) {
123+
logDirect("elytraPredictTerrain setting changed, recalculating path from scratch");
124+
predictingTerrain = Baritone.settings().elytraPredictTerrain.value;
125+
this.resetState();
126+
}
127+
if (allowTight != Baritone.settings().elytraAllowTightSpaces.value) {
128+
logDirect("elytraAllowTightSpaces setting changed, recalculating path from scratch");
129+
allowTight = Baritone.settings().elytraAllowTightSpaces.value;
130+
this.resetState();
131+
}
132+
} catch (IllegalArgumentException e) {
133+
logDirect(e.getMessage(), ChatFormatting.RED);
134+
return new PathingCommand(null, PathingCommandType.CANCEL_AND_SET_GOAL);
129135
}
130136

131137
this.behavior.onTick();

src/main/java/baritone/process/elytra/BlockStateOctreeInterface.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,21 @@ public final class BlockStateOctreeInterface {
2828

2929
private final NetherPathfinderContext context;
3030
private final long contextPtr;
31-
private final DimensionType dimType;
31+
private final int minY;
3232
transient long chunkPtr;
3333

3434
// Guarantee that the first lookup will fetch the context by setting MAX_VALUE
3535
private int prevChunkX = Integer.MAX_VALUE;
3636
private int prevChunkZ = Integer.MAX_VALUE;
3737

38-
public BlockStateOctreeInterface(final NetherPathfinderContext context, final DimensionType dimType) {
38+
public BlockStateOctreeInterface(final NetherPathfinderContext context) {
3939
this.context = context;
4040
this.contextPtr = context.context;
41-
this.dimType = dimType;
41+
this.minY = context.minY;
4242
}
4343

4444
public boolean get0(final int x, final int y, final int z) {
45-
final int adjustedY = y - dimType.minY();
45+
final int adjustedY = y - this.minY;
4646
if (adjustedY < 0 || adjustedY > 383) {
4747
return false;
4848
}

src/main/java/baritone/process/elytra/ElytraBehavior.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public ElytraBehavior(Baritone baritone, ElytraProcess process, BlockPos destina
134134
Baritone.settings().elytraUseCache.value ? baritone.getWorldProvider().getCurrentWorld().directory.resolve("cache") : null,
135135
ctx.world()
136136
);
137-
this.boi = new BlockStateOctreeInterface(context, ctx.world().dimensionType());
137+
this.boi = new BlockStateOctreeInterface(context);
138138
}
139139

140140
public final class PathManager {
@@ -152,6 +152,7 @@ public PathManager() {
152152
this.clear();
153153
}
154154

155+
// requires read lock to be held
155156
public void tick() {
156157
// Recalculate closest path node
157158
this.updatePlayerNear();

src/main/java/baritone/process/elytra/NetherPathfinderContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public final class NetherPathfinderContext {
8080
// operations that don't make changes to the chunk cache. could use multiple threads but i'm not sure if it would cause problems.
8181
private final ExecutorService readExecutor = Executors.newSingleThreadExecutor();
8282
private final ResourceKey<Level> dimension;
83-
private final int minY;
83+
final int minY;
8484

8585
public NetherPathfinderContext(long seed, Path cache, Level world) {
8686
this.dimension = world.dimension();

0 commit comments

Comments
 (0)