From 26302260521c50ab5b933cd7f22d76954723e9e9 Mon Sep 17 00:00:00 2001 From: sk89q Date: Sun, 30 Jan 2011 23:42:18 -0800 Subject: [PATCH] Improved overall performance by using EditSession.getBlockType() instead of EditSession.getBlock().getType(). --- src/com/sk89q/worldedit/EditSession.java | 36 +++++++++---------- .../bukkit/EditSessionBlockChangeDegate.java | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/com/sk89q/worldedit/EditSession.java b/src/com/sk89q/worldedit/EditSession.java index b59f41632..001cb35db 100755 --- a/src/com/sk89q/worldedit/EditSession.java +++ b/src/com/sk89q/worldedit/EditSession.java @@ -278,13 +278,13 @@ public class EditSession { // Place torches, etc. last if (BlockType.shouldPlaceLast(block.getType())) { queueLast.put(pt.toBlockVector(), block); - return getBlock(pt).getType() != block.getType(); + return getBlockType(pt) != block.getType(); // Destroy torches, etc. first - } else if (BlockType.shouldPlaceLast(getBlock(pt).getType())) { + } else if (BlockType.shouldPlaceLast(getBlockType(pt))) { rawSetBlock(pt, new BaseBlock(0)); } else { queueAfter.put(pt.toBlockVector(), block); - return getBlock(pt).getType() != block.getType(); + return getBlockType(pt) != block.getType(); } } @@ -911,7 +911,7 @@ public class EditSession { for (int y = minY; y <= maxY; y++) { for (int z = minZ; z <= maxZ; z++) { Vector pt = new Vector(x, y, z); - int curBlockType = getBlock(pt).getType(); + int curBlockType = getBlockType(pt); if ((fromBlockTypes == null && curBlockType != 0) || (fromBlockTypes != null && fromBlockTypes @@ -925,7 +925,7 @@ public class EditSession { } } else { for (Vector pt : region) { - int curBlockType = getBlock(pt).getType(); + int curBlockType = getBlockType(pt); if (fromBlockTypes == null && curBlockType != 0 || fromBlockTypes.contains(curBlockType)) { @@ -969,7 +969,7 @@ public class EditSession { for (int y = minY; y <= maxY; y++) { for (int z = minZ; z <= maxZ; z++) { Vector pt = new Vector(x, y, z); - int curBlockType = getBlock(pt).getType(); + int curBlockType = getBlockType(pt); if ((fromBlockTypes == null && curBlockType != 0) || (fromBlockTypes != null && fromBlockTypes @@ -983,7 +983,7 @@ public class EditSession { } } else { for (Vector pt : region) { - int curBlockType = getBlock(pt).getType(); + int curBlockType = getBlockType(pt); if (fromBlockTypes == null && curBlockType != 0 || fromBlockTypes.contains(curBlockType)) { @@ -1331,7 +1331,7 @@ public class EditSession { while (!queue.empty()) { BlockVector cur = queue.pop(); - int type = getBlock(cur).getType(); + int type = getBlockType(cur); // Check block type if (type != 8 && type != 9 && type != 10 && type != 11) { @@ -1403,7 +1403,7 @@ public class EditSession { while (!queue.empty()) { BlockVector cur = queue.pop(); - int type = getBlock(cur).getType(); + int type = getBlockType(cur); // Check block type if (type != moving && type != stationary && type != 0) { @@ -1698,7 +1698,7 @@ public class EditSession { for (int y = 127; y >= 1; y--) { Vector pt = new Vector(x, y, z); - int id = getBlock(pt).getType(); + int id = getBlockType(pt); if (id == BlockID.ICE) { // Ice if (setBlock(pt, water)) { @@ -1746,7 +1746,7 @@ public class EditSession { for (int y = 127; y >= 1; y--) { Vector pt = new Vector(x, y, z); - int id = getBlock(pt).getType(); + int id = getBlockType(pt); // Snow should not cover these blocks if (id == 6 // Saplings @@ -1847,12 +1847,12 @@ public class EditSession { throws MaxChangedBlocksException { if (pos.distance(basePos) > 4) return; - if (getBlock(pos).getType() != 0) + if (getBlockType(pos) != 0) return; for (int i = -1; i > -3; i--) { Vector testPos = pos.add(0, i, 0); - if (getBlock(testPos).getType() == 0) { + if (getBlockType(testPos) == 0) { pos = testPos; } else { break; @@ -2000,7 +2000,7 @@ public class EditSession { for (int z = minZ; z <= maxZ; z++) { Vector pt = new Vector(x, y, z); - if (searchIDs.contains(getBlock(pt).getType())) { + if (searchIDs.contains(getBlockType(pt))) { count++; } } @@ -2008,7 +2008,7 @@ public class EditSession { } } else { for (Vector pt : region) { - if (searchIDs.contains(getBlock(pt).getType())) { + if (searchIDs.contains(getBlockType(pt))) { count++; } } @@ -2044,7 +2044,7 @@ public class EditSession { for (int z = minZ; z <= maxZ; z++) { Vector pt = new Vector(x, y, z); - int id = getBlock(pt).getType(); + int id = getBlockType(pt); if (map.containsKey(id)) { map.get(id).increment(); @@ -2058,7 +2058,7 @@ public class EditSession { } } else { for (Vector pt : region) { - int id = getBlock(pt).getType(); + int id = getBlockType(pt); if (map.containsKey(id)) { map.get(id).increment(); @@ -2091,7 +2091,7 @@ public class EditSession { public int getHighestTerrainBlock(int x, int z, int minY, int maxY) { for (int y = maxY; y >= minY; y--) { Vector pt = new Vector(x, y, z); - int id = getBlock(pt).getType(); + int id = getBlockType(pt); if (id == 1 // stone || id == 2 // grass diff --git a/src/com/sk89q/worldedit/bukkit/EditSessionBlockChangeDegate.java b/src/com/sk89q/worldedit/bukkit/EditSessionBlockChangeDegate.java index f431c8890..a77129ffb 100644 --- a/src/com/sk89q/worldedit/bukkit/EditSessionBlockChangeDegate.java +++ b/src/com/sk89q/worldedit/bukkit/EditSessionBlockChangeDegate.java @@ -54,6 +54,6 @@ public class EditSessionBlockChangeDegate implements BlockChangeDelegate { } public int getTypeId(int x, int y, int z) { - return editSession.getBlock(new Vector(x, y, z)).getType(); + return editSession.getBlockType(new Vector(x, y, z)); } }