diff --git a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java index 76849dae..16a56667 100644 --- a/src/api/java/baritone/api/utils/ExampleBaritoneControl.java +++ b/src/api/java/baritone/api/utils/ExampleBaritoneControl.java @@ -241,20 +241,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener return true; } if (msg.equals("repack") || msg.equals("rescan")) { - ChunkProviderClient cli = (ChunkProviderClient) ctx.world().getChunkProvider(); - int playerChunkX = ctx.playerFeet().getX() >> 4; - int playerChunkZ = ctx.playerFeet().getZ() >> 4; - int count = 0; - for (int x = playerChunkX - 40; x <= playerChunkX + 40; x++) { - for (int z = playerChunkZ - 40; z <= playerChunkZ + 40; z++) { - Chunk chunk = cli.getLoadedChunk(x, z); - if (chunk != null) { - count++; - baritone.getWorldProvider().getCurrentWorld().getCachedWorld().queueForPacking(chunk); - } - } - } - logDirect("Queued " + count + " chunks for repacking"); + logDirect("Queued " + repack() + " chunks for repacking"); return true; } if (msg.startsWith("build")) { @@ -502,6 +489,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener return true; } if (msg.startsWith("find")) { + repack(); String blockType = msg.substring(4).trim(); ArrayList locs = baritone.getWorldProvider().getCurrentWorld().getCachedWorld().getLocationsOf(blockType, 1, ctx.playerFeet().getX(), ctx.playerFeet().getZ(), 4); logDirect("Have " + locs.size() + " locations"); @@ -514,6 +502,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener return true; } if (msg.startsWith("mine")) { + repack(); String[] blockTypes = msg.substring(4).trim().split(" "); try { int quantity = Integer.parseInt(blockTypes[1]); @@ -603,6 +592,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener return true; } if (msg.startsWith("goto")) { + repack(); String waypointType = msg.substring(4).trim(); if (waypointType.endsWith("s") && IWaypoint.Tag.fromString(waypointType.substring(0, waypointType.length() - 1)) != null) { // for example, "show deaths" @@ -676,6 +666,23 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener return false; } + private int repack() { + ChunkProviderClient cli = (ChunkProviderClient) ctx.world().getChunkProvider(); + int playerChunkX = ctx.playerFeet().getX() >> 4; + int playerChunkZ = ctx.playerFeet().getZ() >> 4; + int count = 0; + for (int x = playerChunkX - 40; x <= playerChunkX + 40; x++) { + for (int z = playerChunkZ - 40; z <= playerChunkZ + 40; z++) { + Chunk chunk = cli.getLoadedChunk(x, z); + if (chunk != null && !chunk.isEmpty()) { + count++; + baritone.getWorldProvider().getCurrentWorld().getCachedWorld().queueForPacking(chunk); + } + } + } + return count; + } + private int parseOrDefault(String str, int i, double dimensionFactor) { return str.equals("~") ? i : str.startsWith("~") ? (int) (Integer.parseInt(str.substring(1)) * dimensionFactor) + i : (int) (Integer.parseInt(str) * dimensionFactor); } @@ -722,7 +729,6 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener } - private double calculateDimensionFactor(String to) { return Math.pow(8, ctx.world().provider.getDimensionType().getId() - getDimensionByName(to.toLowerCase()).getId()); }