From 3333797144f4e3150b6e93387c3236bb2c5aee3e Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 14 Apr 2019 10:06:37 -0700 Subject: [PATCH] fix region pruning --- src/api/java/baritone/api/Settings.java | 6 ++++-- src/main/java/baritone/cache/CachedWorld.java | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index b61656a9..1de894dc 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -401,10 +401,12 @@ public final class Settings { * On save, delete from RAM any cached regions that are more than 1024 blocks away from the player *

* Temporarily disabled + *

+ * Temporarily reenabled * * @see Issue #248 */ - public final Setting pruneRegionsFromRAM = new Setting<>(false); + public final Setting pruneRegionsFromRAM = new Setting<>(true); /** * Remember the contents of containers (chests, echests, furnaces) @@ -575,7 +577,7 @@ public final class Settings { /** * How far to move before repeating the build. -1 for the size of the build in that axis. 0 to disable */ - public final Setting buildRepeatDistance=new Setting<>(0); + public final Setting buildRepeatDistance = new Setting<>(0); /** * What direction te repeat the build in diff --git a/src/main/java/baritone/cache/CachedWorld.java b/src/main/java/baritone/cache/CachedWorld.java index c025d489..949f818c 100644 --- a/src/main/java/baritone/cache/CachedWorld.java +++ b/src/main/java/baritone/cache/CachedWorld.java @@ -180,8 +180,8 @@ public final class CachedWorld implements ICachedWorld, Helper { if (region == null) { continue; } - int distX = (region.getX() << 9 + 256) - pruneCenter.getX(); - int distZ = (region.getZ() << 9 + 256) - pruneCenter.getZ(); + int distX = ((region.getX() << 9) + 256) - pruneCenter.getX(); + int distZ = ((region.getZ() << 9) + 256) - pruneCenter.getZ(); double dist = Math.sqrt(distX * distX + distZ * distZ); if (dist > 1024) { logDebug("Deleting cached region " + region.getX() + "," + region.getZ() + " from ram"); @@ -216,7 +216,7 @@ public final class CachedWorld implements ICachedWorld, Helper { if (mostRecentlyModified == null) { return new BlockPos(0, 0, 0); } - return new BlockPos(mostRecentlyModified.x << 4 + 8, 0, mostRecentlyModified.z << 4 + 8); + return new BlockPos((mostRecentlyModified.x << 4) + 8, 0, (mostRecentlyModified.z << 4) + 8); } private synchronized List allRegions() {