Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-26 02:50:06 +01:00
Added /fixwater.
Dieser Commit ist enthalten in:
Ursprung
e74700127f
Commit
9f4c262d1f
@ -751,6 +751,75 @@ public class EditSession {
|
|||||||
return affected;
|
return affected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Level water.
|
||||||
|
*
|
||||||
|
* @param pos
|
||||||
|
* @param radius
|
||||||
|
* @return number of blocks affected
|
||||||
|
* @throws MaxChangedBlocksException
|
||||||
|
*/
|
||||||
|
public int fixWater(Vector pos, int radius) throws MaxChangedBlocksException {
|
||||||
|
int affected = 0;
|
||||||
|
|
||||||
|
HashSet<BlockVector> visited = new HashSet<BlockVector>();
|
||||||
|
Stack<BlockVector> queue = new Stack<BlockVector>();
|
||||||
|
|
||||||
|
for (int x = pos.getBlockX() - 1; x <= pos.getBlockX() + 1; x++) {
|
||||||
|
for (int z = pos.getBlockZ() - 1; z <= pos.getBlockZ() + 1; z++) {
|
||||||
|
for (int y = pos.getBlockY() - 1; y <= pos.getBlockY() + 1; y++) {
|
||||||
|
int type = getBlock(new Vector(x, y, z)).getID();
|
||||||
|
|
||||||
|
// Check block type
|
||||||
|
if (type == 8 || type == 9) {
|
||||||
|
queue.push(new BlockVector(x, y, z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseBlock stationaryWater = new BaseBlock(9);
|
||||||
|
|
||||||
|
while (!queue.empty()) {
|
||||||
|
BlockVector cur = queue.pop();
|
||||||
|
|
||||||
|
int type = getBlock(cur).getID();
|
||||||
|
|
||||||
|
// Check block type
|
||||||
|
if (type != 8 && type != 9 && type != 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't want to revisit
|
||||||
|
if (visited.contains(cur)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
visited.add(cur);
|
||||||
|
|
||||||
|
if (setBlock(cur, stationaryWater)) {
|
||||||
|
affected++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check radius
|
||||||
|
if (pos.distance(cur) > radius) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int x = cur.getBlockX() - 1; x <= cur.getBlockX() + 1; x++) {
|
||||||
|
for (int z = cur.getBlockZ() - 1; z <= cur.getBlockZ() + 1; z++) {
|
||||||
|
BlockVector newPos = new BlockVector(x, cur.getBlockY(), z);
|
||||||
|
|
||||||
|
if (!cur.equals(newPos)) {
|
||||||
|
queue.push(newPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return affected;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a block by chance.
|
* Set a block by chance.
|
||||||
|
@ -141,6 +141,7 @@ public class WorldEdit {
|
|||||||
commands.put("//expand", "<Dir> [Num] - Expands the selection");
|
commands.put("//expand", "<Dir> [Num] - Expands the selection");
|
||||||
commands.put("//contract", "<Dir> [Num] - Contracts the selection");
|
commands.put("//contract", "<Dir> [Num] - Contracts the selection");
|
||||||
commands.put("//rotate", "[Angle] - Rotate the clipboard");
|
commands.put("//rotate", "[Angle] - Rotate the clipboard");
|
||||||
|
commands.put("/fixwater", "[Radius] - Level nearby pools of water");
|
||||||
commands.put("/forestgen", "<Size> - Make an ugly pine tree forest");
|
commands.put("/forestgen", "<Size> - Make an ugly pine tree forest");
|
||||||
commands.put("/unstuck", "Go up to the first free spot");
|
commands.put("/unstuck", "Go up to the first free spot");
|
||||||
commands.put("/ascend", "Go up one level");
|
commands.put("/ascend", "Go up one level");
|
||||||
@ -537,6 +538,16 @@ public class WorldEdit {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
// Fix water
|
||||||
|
} else if(split[0].equalsIgnoreCase("/fixwater")) {
|
||||||
|
checkArgs(split, 1, 1, split[0]);
|
||||||
|
int radius = Math.max(0, Integer.parseInt(split[1]));
|
||||||
|
int affected = editSession.fixWater(
|
||||||
|
session.getPlacementPosition(player), radius);
|
||||||
|
player.print(affected + " block(s) have been changed.");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
// Replace all blocks in the region
|
// Replace all blocks in the region
|
||||||
} else if(split[0].equalsIgnoreCase("//replace")) {
|
} else if(split[0].equalsIgnoreCase("//replace")) {
|
||||||
checkArgs(split, 1, 2, split[0]);
|
checkArgs(split, 1, 2, split[0]);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren