repack on mine cmd

This commit is contained in:
Leijurv 2019-08-17 22:01:53 -07:00
parent cca137d526
commit 1c36bf3300
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A

View File

@ -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<BlockPos> 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());
}