From 0a288acbaa5a7b4976c046a9c8262a8209111415 Mon Sep 17 00:00:00 2001 From: sk89q Date: Tue, 19 Oct 2010 23:06:12 -0700 Subject: [PATCH] Added /chunkinfo. --- src/WorldEdit.java | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/WorldEdit.java b/src/WorldEdit.java index 9468c0c50..db651caf8 100644 --- a/src/WorldEdit.java +++ b/src/WorldEdit.java @@ -161,6 +161,7 @@ public class WorldEdit { commands.put("/jumpto", "Jump to the block that you are looking at"); commands.put("/thru", "Go through the wall that you are looking at"); commands.put("/ceil", " - Get to the ceiling"); + commands.put("/chunkinfo", "Get the filename of the chunk that you are in"); } /** @@ -341,7 +342,7 @@ public class WorldEdit { checkArgs(split, 0, 1, split[0]); int clearence = split.length > 1 ? Math.max(0, Integer.parseInt(split[1])) : 0; - + if (player.ascendToCeiling(clearence)) { player.print("Whoosh!"); } else { @@ -857,12 +858,41 @@ public class WorldEdit { player.printError("Angles must be divisible by 90 degrees."); } + return true; + + // Get chunk filename + } else if (split[0].equalsIgnoreCase("/chunkinfo")) { + checkArgs(split, 0, 0, split[0]); + + Vector pos = player.getBlockIn(); + int chunkX = (int)Math.floor(pos.getBlockX() / 16.0); + int chunkZ = (int)Math.floor(pos.getBlockZ() / 16.0); + + String folder1 = Integer.toString(divisorMod(chunkX, 64), 36); + String folder2 = Integer.toString(divisorMod(chunkZ, 64), 36); + String filename = "c." + Integer.toString(chunkX, 36) + + "." + Integer.toString(chunkZ, 36) + ".dat"; + + player.print("Chunk: " + chunkX + ", " + chunkZ); + player.print(folder1 + "/" + folder2 + "/" + filename); + return true; } return false; } + /** + * Modulus, divisor-style. + * + * @param a + * @param n + * @return + */ + private static int divisorMod(int a, int n) { + return (int)(a - n * Math.floor(Math.floor(a) / (double)n)); + } + /** * Get the direction vector for a player's direction. May return * null if a direction could not be found.