From b953da0341344632e54d4b3132a1ce3da35b22f7 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 30 Jan 2019 12:19:15 -0800 Subject: [PATCH] more accurate isEmpty --- .../launch/mixins/MixinRenderChunk.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/launch/java/baritone/launch/mixins/MixinRenderChunk.java b/src/launch/java/baritone/launch/mixins/MixinRenderChunk.java index 47402c6b..4190ae59 100644 --- a/src/launch/java/baritone/launch/mixins/MixinRenderChunk.java +++ b/src/launch/java/baritone/launch/mixins/MixinRenderChunk.java @@ -43,15 +43,28 @@ public class MixinRenderChunk { ) ) private boolean isEmpty(ChunkCache chunkCache) { + if (!chunkCache.isEmpty()) { + return false; + } if (Baritone.settings().renderCachedChunks.get()) { Baritone baritone = (Baritone) BaritoneAPI.getProvider().getPrimaryBaritone(); IPlayerContext ctx = baritone.getPlayerContext(); if (ctx.player() != null && ctx.world() != null && baritone.bsi != null) { - return false; + BlockPos position = ((RenderChunk) (Object) this).getPosition(); + // RenderChunk extends from -1,-1,-1 to +16,+16,+16 + // then the constructor of ChunkCache extends it one more (presumably to get things like the connected status of fences? idk) + // so if ANY of the adjacent chunks are loaded, we are unempty + for (int dx = -1; dx <= 1; dx++) { + for (int dz = -1; dz <= 1; dz++) { + if (baritone.bsi.isLoaded(16 * dx + position.getX(), 16 * dz + position.getZ())) { + return false; + } + } + } } } - return chunkCache.isEmpty(); + return true; } @Redirect(