mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Added /fixwater.
This commit is contained in:
parent
e74700127f
commit
9f4c262d1f
@ -689,7 +689,7 @@ public class EditSession {
|
||||
|
||||
/**
|
||||
* Drain nearby pools of water or lava.
|
||||
*
|
||||
*
|
||||
* @param pos
|
||||
* @param radius
|
||||
* @return number of blocks affected
|
||||
@ -711,7 +711,7 @@ public class EditSession {
|
||||
|
||||
while (!queue.empty()) {
|
||||
BlockVector cur = queue.pop();
|
||||
|
||||
|
||||
int type = getBlock(cur).getID();
|
||||
|
||||
// Check block type
|
||||
@ -723,7 +723,7 @@ public class EditSession {
|
||||
if (visited.contains(cur)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
visited.add(cur);
|
||||
|
||||
// Check radius
|
||||
@ -750,6 +750,75 @@ public class EditSession {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -141,6 +141,7 @@ public class WorldEdit {
|
||||
commands.put("//expand", "<Dir> [Num] - Expands the selection");
|
||||
commands.put("//contract", "<Dir> [Num] - Contracts the selection");
|
||||
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("/unstuck", "Go up to the first free spot");
|
||||
commands.put("/ascend", "Go up one level");
|
||||
@ -537,6 +538,16 @@ public class WorldEdit {
|
||||
|
||||
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
|
||||
} else if(split[0].equalsIgnoreCase("//replace")) {
|
||||
checkArgs(split, 1, 2, split[0]);
|
||||
|
Loading…
Reference in New Issue
Block a user