mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
EditSession.fillXZ() is now longer recursive.
This commit is contained in:
parent
385e25e14c
commit
749649a80b
@ -355,52 +355,47 @@ public class EditSession {
|
|||||||
public int fillXZ(int x, int z, Vector origin, BaseBlock block,
|
public int fillXZ(int x, int z, Vector origin, BaseBlock block,
|
||||||
int radius, int depth)
|
int radius, int depth)
|
||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
return _fillXZ(x, z, origin, block, radius, depth,
|
|
||||||
new HashSet<BlockVector>());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
int affected = 0;
|
||||||
* Fills an area recursively in the X/Z directions.
|
int originX = origin.getBlockX();
|
||||||
*
|
int originY = origin.getBlockY();
|
||||||
* @param x
|
int originZ = origin.getBlockZ();
|
||||||
* @param z
|
|
||||||
* @param origin
|
HashSet<BlockVector> visited = new HashSet<BlockVector>();
|
||||||
* @param block
|
Stack<BlockVector> queue = new Stack<BlockVector>();
|
||||||
* @param radius
|
|
||||||
* @param depth
|
queue.push(new BlockVector(x, 0, z));
|
||||||
* @param visited
|
|
||||||
* @return
|
while (!queue.empty()) {
|
||||||
* @throws MaxChangedBlocksException
|
BlockVector pt = queue.pop();
|
||||||
*/
|
int cx = pt.getBlockX();
|
||||||
private int _fillXZ(int x, int z, Vector origin, BaseBlock block, int radius,
|
int cz = pt.getBlockZ();
|
||||||
int depth, Set<BlockVector> visited)
|
|
||||||
throws MaxChangedBlocksException {
|
|
||||||
BlockVector pt = new BlockVector(x, 0, z);
|
|
||||||
|
|
||||||
if (visited.contains(pt)) {
|
if (visited.contains(pt)) {
|
||||||
return 0;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
visited.add(pt);
|
visited.add(pt);
|
||||||
|
|
||||||
double dist = Math.sqrt(Math.pow(origin.getX() - x, 2) + Math.pow(origin.getZ() - z, 2));
|
double dist = Math.sqrt(Math.pow(originX - cx, 2)
|
||||||
int minY = origin.getBlockY() - depth + 1;
|
+ Math.pow(originZ - cz, 2));
|
||||||
int affected = 0;
|
int minY = originY - depth + 1;
|
||||||
|
|
||||||
if (dist > radius) {
|
if (dist > radius) {
|
||||||
return 0;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getBlock(new Vector(x, origin.getY(), z)).isAir()) {
|
if (getBlock(new Vector(cx, originY, cz)).isAir()) {
|
||||||
affected = fillY(x, (int)origin.getY(), z, block, minY);
|
affected += fillY(cx, originY, cz, block, minY);
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
affected += fillXZ(x + 1, z, origin, block, radius, depth);
|
queue.push(new BlockVector(cx + 1, 0, cz));
|
||||||
affected += fillXZ(x - 1, z, origin, block, radius, depth);
|
queue.push(new BlockVector(cx - 1, 0, cz));
|
||||||
affected += fillXZ(x, z + 1, origin, block, radius, depth);
|
queue.push(new BlockVector(cx, 0, cz + 1));
|
||||||
affected += fillXZ(x, z - 1, origin, block, radius, depth);
|
queue.push(new BlockVector(cx, 0, cz - 1));
|
||||||
|
}
|
||||||
|
|
||||||
return affected;
|
return affected;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user