Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-09-07 08:32:51 +02:00
Converted /editdrain to use own stack.
Dieser Commit ist enthalten in:
Ursprung
6882aa416d
Commit
2f2ff86bac
@ -20,6 +20,7 @@
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Stack;
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -634,62 +635,53 @@ public class EditSession {
|
|||||||
int affected = 0;
|
int affected = 0;
|
||||||
|
|
||||||
HashSet<BlockPoint> visited = new HashSet<BlockPoint>();
|
HashSet<BlockPoint> visited = new HashSet<BlockPoint>();
|
||||||
|
Stack<BlockPoint> queue = new Stack<BlockPoint>();
|
||||||
|
|
||||||
for (int x = pos.getBlockX() - 1; x <= pos.getBlockX() + 1; x++) {
|
for (int x = pos.getBlockX() - 1; x <= pos.getBlockX() + 1; x++) {
|
||||||
for (int z = pos.getBlockZ() - 1; z <= pos.getBlockZ() + 1; z++) {
|
for (int z = pos.getBlockZ() - 1; z <= pos.getBlockZ() + 1; z++) {
|
||||||
for (int y = pos.getBlockY() - 1; y <= pos.getBlockY() + 1; y++) {
|
for (int y = pos.getBlockY() - 1; y <= pos.getBlockY() + 1; y++) {
|
||||||
affected += drainPool(new Point(x, y, z), pos, radius, visited);
|
queue.push(new BlockPoint(x, y, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return affected;
|
while (!queue.empty()) {
|
||||||
}
|
BlockPoint cur = queue.pop();
|
||||||
|
|
||||||
|
int type = getBlock(cur);
|
||||||
|
|
||||||
/**
|
// Check block type
|
||||||
* Drains a water or lava block and any lava/water blocks next to it.
|
if (type != 8 && type != 9 && type != 10 && type != 11) {
|
||||||
*
|
continue;
|
||||||
* @param pos
|
}
|
||||||
* @param origin
|
|
||||||
* @param radius
|
|
||||||
* @param visited
|
|
||||||
* @return number of blocks affected
|
|
||||||
* @throws MaxChangedBlocksException
|
|
||||||
*/
|
|
||||||
private int drainPool(Point pos, Point origin, int radius, HashSet<BlockPoint> visited)
|
|
||||||
throws MaxChangedBlocksException {
|
|
||||||
int type = getBlock(pos);
|
|
||||||
int affected = 0;
|
|
||||||
|
|
||||||
if (type != 8 && type != 9 && type != 10 && type != 11) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockPoint blockPos = new BlockPoint(pos);
|
// Don't want to revisit
|
||||||
|
if (visited.contains(cur)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
visited.add(cur);
|
||||||
|
|
||||||
if (visited.contains(blockPos)) {
|
// Check radius
|
||||||
return 0;
|
if (pos.distance(cur) > radius) {
|
||||||
}
|
continue;
|
||||||
visited.add(blockPos);
|
}
|
||||||
|
|
||||||
if (pos.distance(origin) > radius) {
|
for (int x = cur.getBlockX() - 1; x <= cur.getBlockX() + 1; x++) {
|
||||||
return 0;
|
for (int z = cur.getBlockZ() - 1; z <= cur.getBlockZ() + 1; z++) {
|
||||||
}
|
for (int y = cur.getBlockY() - 1; y <= cur.getBlockY() + 1; y++) {
|
||||||
|
BlockPoint newPos = new BlockPoint(x, y, z);
|
||||||
|
|
||||||
for (int x = pos.getBlockX() - 1; x <= pos.getBlockX() + 1; x++) {
|
if (!cur.equals(newPos)) {
|
||||||
for (int z = pos.getBlockZ() - 1; z <= pos.getBlockZ() + 1; z++) {
|
queue.push(newPos);
|
||||||
for (int y = pos.getBlockY() - 1; y <= pos.getBlockY() + 1; y++) {
|
}
|
||||||
Point newPos = new Point(x, y, z);
|
|
||||||
|
|
||||||
if (!pos.equals(newPos)) {
|
|
||||||
affected += drainPool(newPos, origin, radius, visited);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (setBlock(pos, 0)) {
|
if (setBlock(cur, 0)) {
|
||||||
affected++;
|
affected++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return affected;
|
return affected;
|
||||||
|
@ -33,6 +33,33 @@ public class BlockPoint extends Point {
|
|||||||
public BlockPoint(Point pt) {
|
public BlockPoint(Point pt) {
|
||||||
super(pt);
|
super(pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct the Point object.
|
||||||
|
*
|
||||||
|
* @param pt
|
||||||
|
*/
|
||||||
|
public BlockPoint(int x, int y, int z) {
|
||||||
|
super(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct the Point object.
|
||||||
|
*
|
||||||
|
* @param pt
|
||||||
|
*/
|
||||||
|
public BlockPoint(float x, float y, float z) {
|
||||||
|
super(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct the Point object.
|
||||||
|
*
|
||||||
|
* @param pt
|
||||||
|
*/
|
||||||
|
public BlockPoint(double x, double y, double z) {
|
||||||
|
super(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if another object is equivalent.
|
* Checks if another object is equivalent.
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren