Added /chunkinfo.

Dieser Commit ist enthalten in:
sk89q 2010-10-19 23:06:12 -07:00
Ursprung c25f13c3f0
Commit 0a288acbaa

Datei anzeigen

@ -161,6 +161,7 @@ public class WorldEdit {
commands.put("/jumpto", "Jump to the block that you are looking at"); 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("/thru", "Go through the wall that you are looking at");
commands.put("/ceil", "<Clearance> - Get to the ceiling"); commands.put("/ceil", "<Clearance> - Get to the ceiling");
commands.put("/chunkinfo", "Get the filename of the chunk that you are in");
} }
/** /**
@ -857,12 +858,41 @@ public class WorldEdit {
player.printError("Angles must be divisible by 90 degrees."); 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 true;
} }
return false; 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 * Get the direction vector for a player's direction. May return
* null if a direction could not be found. * null if a direction could not be found.