From c0bc7b5ecd1e86d1473fd55f59628ffbaef638a6 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sat, 1 Sep 2018 12:26:55 -0700 Subject: [PATCH] fix strange issue when exiting and entering the same world --- src/main/java/baritone/api/event/GameEventHandler.java | 3 +++ src/main/java/baritone/utils/BlockStateInterface.java | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/baritone/api/event/GameEventHandler.java b/src/main/java/baritone/api/event/GameEventHandler.java index 88cd0560..45e86885 100644 --- a/src/main/java/baritone/api/event/GameEventHandler.java +++ b/src/main/java/baritone/api/event/GameEventHandler.java @@ -39,6 +39,7 @@ import baritone.api.event.events.*; import baritone.api.event.events.type.EventState; import baritone.api.event.listener.IGameEventListener; import baritone.chunk.WorldProvider; +import baritone.utils.BlockStateInterface; import baritone.utils.Helper; import baritone.utils.InputOverrideHandler; import baritone.utils.interfaces.Toggleable; @@ -133,6 +134,8 @@ public final class GameEventHandler implements IGameEventListener, Helper { public final void onWorldEvent(WorldEvent event) { WorldProvider cache = WorldProvider.INSTANCE; + BlockStateInterface.clearCachedChunk(); + switch (event.getState()) { case PRE: break; diff --git a/src/main/java/baritone/utils/BlockStateInterface.java b/src/main/java/baritone/utils/BlockStateInterface.java index f21ddc50..cd3ca646 100644 --- a/src/main/java/baritone/utils/BlockStateInterface.java +++ b/src/main/java/baritone/utils/BlockStateInterface.java @@ -31,7 +31,7 @@ import net.minecraft.world.chunk.Chunk; public class BlockStateInterface implements Helper { private static Chunk prev = null; - + public static IBlockState get(BlockPos pos) { // wrappers for chunk caching capability // Invalid vertical position @@ -66,6 +66,10 @@ public class BlockStateInterface implements Helper { return Blocks.AIR.getDefaultState(); } + public static void clearCachedChunk() { + prev = null; + } + public static Block getBlock(BlockPos pos) { return get(pos).getBlock(); }