Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-03 01:50:07 +01:00
Added //sphere and //hsphere.
Dieser Commit ist enthalten in:
Ursprung
3ad6577be6
Commit
1b88e1592e
@ -1005,6 +1005,43 @@ public class EditSession {
|
||||
return affected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a sphere.
|
||||
*
|
||||
* @param pos
|
||||
* @param block
|
||||
* @param radius
|
||||
* @param filled
|
||||
* @return number of blocks changed
|
||||
* @throws MaxChangedBlocksException
|
||||
*/
|
||||
public int makeSphere(Vector pos, BaseBlock block, int radius, boolean filled)
|
||||
throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
|
||||
for (int x = 0; x <= radius; x++) {
|
||||
for (int y = 0; y <= radius; y++) {
|
||||
for (int z = 0; z <= radius; z++) {
|
||||
Vector vec = pos.add(x, y, z);
|
||||
double d = vec.distance(pos);
|
||||
|
||||
if (d <= radius + 0.5 && (filled || d >= radius - 0.5)) {
|
||||
if (setBlock(vec, block)) { affected++; }
|
||||
if (setBlock(pos.add(-x, y, z), block)) { affected++; }
|
||||
if (setBlock(pos.add(x, -y, z), block)) { affected++; }
|
||||
if (setBlock(pos.add(x, y, -z), block)) { affected++; }
|
||||
if (setBlock(pos.add(-x, -y, z), block)) { affected++; }
|
||||
if (setBlock(pos.add(x, -y, -z), block)) { affected++; }
|
||||
if (setBlock(pos.add(-x, y, -z), block)) { affected++; }
|
||||
if (setBlock(pos.add(-x, -y, -z), block)) { affected++; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return affected;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a block by chance.
|
||||
|
@ -143,6 +143,8 @@ public class WorldEdit {
|
||||
commands.put("//rotate", "[Angle] - Rotate the clipboard");
|
||||
commands.put("//hcyl", "[ID] [Radius] <Height> - Create a vertical hollow cylinder");
|
||||
commands.put("//cyl", "[ID] [Radius] <Height> - Create a vertical cylinder");
|
||||
commands.put("//sphere", "[ID] [Radius] [Raised?] - Create a sphere");
|
||||
commands.put("//hsphere", "[ID] [Radius] [Raised?] - Create a hollow sphere");
|
||||
commands.put("/fixwater", "[Radius] - Level nearby pools of water");
|
||||
commands.put("/forestgen", "<Size> - Make an ugly pine tree forest");
|
||||
commands.put("/unstuck", "Go up to the first free spot");
|
||||
@ -433,6 +435,29 @@ public class WorldEdit {
|
||||
|
||||
return true;
|
||||
|
||||
// Draw a sphere
|
||||
} else if (split[0].equalsIgnoreCase("//sphere")
|
||||
|| split[0].equalsIgnoreCase("//hsphere")) {
|
||||
checkArgs(split, 2, 3, split[0]);
|
||||
BaseBlock block = getBlock(split[1]);
|
||||
int radius = Math.max(1, Integer.parseInt(split[2]));
|
||||
boolean raised = split.length > 3
|
||||
? (split[3].equalsIgnoreCase("true")
|
||||
|| split[3].equalsIgnoreCase("yes"))
|
||||
: false;
|
||||
boolean filled = split[0].equalsIgnoreCase("//sphere");
|
||||
|
||||
Vector pos = session.getPlacementPosition(player);
|
||||
if (raised) {
|
||||
pos = pos.add(0, radius, 0);
|
||||
}
|
||||
|
||||
int affected = editSession.makeSphere(pos, block, radius, filled);
|
||||
player.findFreePosition();
|
||||
player.print(affected + " block(s) have been created.");
|
||||
|
||||
return true;
|
||||
|
||||
// Fill a hole
|
||||
} else if (split[0].equalsIgnoreCase("//fill")) {
|
||||
checkArgs(split, 2, 3, split[0]);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren