From faf03079d63478dcc77e3a7a50fd8f071236f17b Mon Sep 17 00:00:00 2001 From: sk89q Date: Mon, 31 Jan 2011 01:16:49 -0800 Subject: [PATCH] Improved Bukkit performance drastically. --- src/com/sk89q/worldedit/EditSession.java | 15 +++++++++++---- src/com/sk89q/worldedit/bukkit/BukkitWorld.java | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/com/sk89q/worldedit/EditSession.java b/src/com/sk89q/worldedit/EditSession.java index 001cb35db..912de5c42 100755 --- a/src/com/sk89q/worldedit/EditSession.java +++ b/src/com/sk89q/worldedit/EditSession.java @@ -772,10 +772,17 @@ public class EditSession { int affected = 0; BaseBlock air = new BaseBlock(0); - for (int x = -size; x <= size; x++) { - for (int y = -size; y <= size; y++) { - for (int z = -size; z <= size; z++) { - Vector p = pos.add(x, y, z); + int minX = pos.getBlockX() - size; + int maxX = pos.getBlockX() + size; + int minY = Math.max(0, pos.getBlockY() - size); + int maxY = Math.min(127, pos.getBlockY() + size); + int minZ = pos.getBlockZ() - size; + int maxZ = pos.getBlockZ() + size; + + for (int x = minX; x <= maxX; x++) { + for (int y = minY; y <= maxY; y++) { + for (int z = minZ; z <= maxZ; z++) { + Vector p = new Vector(x, y, z); if (getBlockType(p) == blockType) { if (setBlock(p, air)) { diff --git a/src/com/sk89q/worldedit/bukkit/BukkitWorld.java b/src/com/sk89q/worldedit/bukkit/BukkitWorld.java index f30b1b0dc..352c3d7b2 100644 --- a/src/com/sk89q/worldedit/bukkit/BukkitWorld.java +++ b/src/com/sk89q/worldedit/bukkit/BukkitWorld.java @@ -76,7 +76,7 @@ public class BukkitWorld extends LocalWorld { */ @Override public int getBlockType(Vector pt) { - return world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).getTypeId(); + return world.getBlockTypeIdAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); } /**