MCPcopy Index your code
hub / github.com/cabaletta/baritone / prune

Method prune

src/main/java/baritone/cache/CachedWorld.java:186–203  ·  view source on GitHub ↗

Delete regions that are too far from the player

()

Source from the content-addressed store, hash-verified

184 * Delete regions that are too far from the player
185 */
186 private synchronized void prune() {
187 if (!Baritone.settings().pruneRegionsFromRAM.value) {
188 return;
189 }
190 BlockPos pruneCenter = guessPosition();
191 for (CachedRegion region : allRegions()) {
192 if (region == null) {
193 continue;
194 }
195 int distX = ((region.getX() << 9) + 256) - pruneCenter.getX();
196 int distZ = ((region.getZ() << 9) + 256) - pruneCenter.getZ();
197 double dist = Math.sqrt(distX * distX + distZ * distZ);
198 if (dist > 1024) {
199 logDebug("Deleting cached region from ram");
200 cachedRegions.remove(getRegionID(region.getX(), region.getZ()));
201 }
202 }
203 }
204
205 /**
206 * If we are still in this world and dimension, return player feet, otherwise return most recently modified chunk

Callers 1

saveMethod · 0.95

Calls 7

settingsMethod · 0.95
guessPositionMethod · 0.95
allRegionsMethod · 0.95
getRegionIDMethod · 0.95
logDebugMethod · 0.80
getXMethod · 0.65
getZMethod · 0.65

Tested by

no test coverage detected