From 88d71281359321cd64cedd2b96dd413c8fd673cd Mon Sep 17 00:00:00 2001 From: sk89q Date: Sun, 30 Jan 2011 22:15:08 -0800 Subject: [PATCH] Improved the speed (slightly?) of replaceNear and removeNear methods in EditSession. --- src/com/sk89q/worldedit/EditSession.java | 27 +++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/com/sk89q/worldedit/EditSession.java b/src/com/sk89q/worldedit/EditSession.java index dec9344e4..b59f41632 100755 --- a/src/com/sk89q/worldedit/EditSession.java +++ b/src/com/sk89q/worldedit/EditSession.java @@ -312,6 +312,27 @@ public class EditSession { return rawGetBlock(pt); } + /** + * Gets the block type at a position x, y, z. + * + * @param pt + * @return Block type + */ + public int getBlockType(Vector pt) { + // In the case of the queue, the block may have not actually been + // changed yet + if (queued) { + /* + * BlockVector blockPt = pt.toBlockVector(); + * + * if (current.containsKey(blockPt)) { return current.get(blockPt); + * } + */ + } + + return world.getBlockType(pt); + } + /** * Gets the block type at a position x, y, z. * @@ -693,7 +714,7 @@ public class EditSession { for (int y = oY; y <= maxY; y++) { Vector pt = new Vector(x, y, z); - if (!getBlock(pt).isAir()) { + if (getBlockType(pt) != 0) { setBlock(pt, new BaseBlock(0)); affected++; } @@ -727,7 +748,7 @@ public class EditSession { for (int y = oY; y >= minY; y--) { Vector pt = new Vector(x, y, z); - if (!getBlock(pt).isAir()) { + if (getBlockType(pt) != 0) { setBlock(pt, new BaseBlock(0)); affected++; } @@ -756,7 +777,7 @@ public class EditSession { for (int z = -size; z <= size; z++) { Vector p = pos.add(x, y, z); - if (getBlock(p).getType() == blockType) { + if (getBlockType(p) == blockType) { if (setBlock(p, air)) { affected++; }