From 9dad1af960170f0ec1f87617bd36aa222a9f9791 Mon Sep 17 00:00:00 2001 From: Wagyourtail Date: Tue, 8 Feb 2022 01:57:56 -0700 Subject: [PATCH 1/2] move up null check to fix new data-driven caused crash with replaymod --- src/main/java/baritone/utils/BlockStateInterface.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index c615ff4e1..95c8ba09d 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -97,6 +97,9 @@ public class BlockStateInterface { } public BlockState get0(int x, int y, int z) { // Mickey resigned + if (worldData == null) { + return AIR; + } y -= worldData.dimension.minY(); // Invalid vertical position if (y < 0 || y >= worldData.dimension.height()) { @@ -124,9 +127,6 @@ public class BlockStateInterface { // except here, it's 512x512 tiles instead of 16x16, so even better repetition CachedRegion cached = prevCached; if (cached == null || cached.getX() != x >> 9 || cached.getZ() != z >> 9) { - if (worldData == null) { - return AIR; - } CachedRegion region = worldData.cache.getRegion(x >> 9, z >> 9); if (region == null) { return AIR; From 0ef1558803183edab08dcf47a39d65483141c49d Mon Sep 17 00:00:00 2001 From: Wagyourtail Date: Tue, 8 Feb 2022 02:09:20 -0700 Subject: [PATCH 2/2] fix this in a "better" way --- .../java/baritone/utils/BlockStateInterface.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index 95c8ba09d..2ebc1c0fb 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -43,7 +43,7 @@ public class BlockStateInterface { private final ClientChunkCache provider; private final WorldData worldData; - protected final BlockGetter world; + protected final Level world; public final BlockPos.MutableBlockPos isPassableBlockPos; public final BlockGetter access; @@ -97,12 +97,9 @@ public class BlockStateInterface { } public BlockState get0(int x, int y, int z) { // Mickey resigned - if (worldData == null) { - return AIR; - } - y -= worldData.dimension.minY(); + y -= world.dimensionType().minY(); // Invalid vertical position - if (y < 0 || y >= worldData.dimension.height()) { + if (y < 0 || y >= world.dimensionType().height()) { return AIR; } @@ -127,6 +124,9 @@ public class BlockStateInterface { // except here, it's 512x512 tiles instead of 16x16, so even better repetition CachedRegion cached = prevCached; if (cached == null || cached.getX() != x >> 9 || cached.getZ() != z >> 9) { + if (worldData == null) { + return AIR; + } CachedRegion region = worldData.cache.getRegion(x >> 9, z >> 9); if (region == null) { return AIR;