Fill routine is now no longer dependent on the state of a block as reported by the server (infinite recursion fixed on non-block items).

Dieser Commit ist enthalten in:
sk89q 2010-10-14 12:06:14 -07:00
Ursprung 92dc88562c
Commit 9dc324f00a

Datei anzeigen

@ -23,6 +23,7 @@ import com.sk89q.worldedit.blocks.SignBlock;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import java.util.Map; import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
import java.util.Set;
import java.util.HashSet; import java.util.HashSet;
import java.util.Stack; import java.util.Stack;
import com.sk89q.worldedit.*; import com.sk89q.worldedit.*;
@ -328,8 +329,37 @@ public class EditSession {
* @param depth * @param depth
* @return number of blocks affected * @return number of blocks affected
*/ */
public int fillXZ(int x, int z, Vector origin, BaseBlock block, int radius, int depth) public int fillXZ(int x, int z, Vector origin, BaseBlock block,
int radius, int depth)
throws MaxChangedBlocksException { throws MaxChangedBlocksException {
return _fillXZ(x, z, origin, block, radius, depth,
new HashSet<BlockVector>());
}
/**
* Fills an area recursively in the X/Z directions.
*
* @param x
* @param z
* @param origin
* @param block
* @param radius
* @param depth
* @param visited
* @return
* @throws MaxChangedBlocksException
*/
private int _fillXZ(int x, int z, Vector origin, BaseBlock block, int radius,
int depth, Set<BlockVector> visited)
throws MaxChangedBlocksException {
BlockVector pt = new BlockVector(x, 0, z);
if (visited.contains(pt)) {
return 0;
}
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(origin.getX() - x, 2) + Math.pow(origin.getZ() - z, 2));
int minY = origin.getBlockY() - depth + 1; int minY = origin.getBlockY() - depth + 1;
int affected = 0; int affected = 0;