From 6945ddd258c96bd0b15e5eb6b1d1583f172e9d53 Mon Sep 17 00:00:00 2001 From: sk89q Date: Tue, 16 Nov 2010 20:39:48 -0800 Subject: [PATCH] Changed WorldEdit to not set block data for blocks that don't require it. --- src/EditSession.java | 14 ++++++-- src/com/sk89q/worldedit/blocks/BlockType.java | 33 +++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/EditSession.java b/src/EditSession.java index acdacd027..39e28db9a 100644 --- a/src/EditSession.java +++ b/src/EditSession.java @@ -70,6 +70,10 @@ public class EditSession { * Random number generator. */ private static Random prng = new Random(); + /** + * Total number of blocks set over time. + */ + private int blockIndex = 0; /** * Construct the object with a maximum number of blocks. @@ -98,10 +102,14 @@ public class EditSession { if (ServerInterface.getBlockType(pt) == 54) { ServerInterface.clearChest(pt); } + + int id = block.getID(); - boolean result = ServerInterface.setBlockType(pt, block.getID()); - if (block.getID() != 0) { - ServerInterface.setBlockData(pt, block.getData()); + boolean result = ServerInterface.setBlockType(pt, id); + if (id != 0) { + if (BlockType.usesData(id)) { + ServerInterface.setBlockData(pt, block.getData()); + } // Signs if (block instanceof SignBlock) { diff --git a/src/com/sk89q/worldedit/blocks/BlockType.java b/src/com/sk89q/worldedit/blocks/BlockType.java index befa1048b..89de10e9c 100644 --- a/src/com/sk89q/worldedit/blocks/BlockType.java +++ b/src/com/sk89q/worldedit/blocks/BlockType.java @@ -268,4 +268,37 @@ public enum BlockType { || id == 83 // Reed || id == 90; // Portal } + + /** + * Returns true if the block uses its data value. + * + * @param id + * @return + */ + public static boolean usesData(int id) { + return id == 6 // Saplings + || id == 8 // Water + || id == 9 // Water + || id == 10 // Lava + || id == 11 // Lava + || id == 50 // Torch + || id == 53 // Wooden stairs + || id == 55 // Redstone wire + || id == 59 // Crops + || id == 60 // Soil + || id == 63 // Sign post + || id == 64 // Wooden door + || id == 65 // Ladder + || id == 66 // Minecart track + || id == 67 // Cobblestone stairs + || id == 68 // Wall sign + || id == 69 // Lever + || id == 70 // Stone pressure plate + || id == 71 // Iron door + || id == 72 // Wooden pressure plate + || id == 75 // Redstone torch (off) + || id == 76 // Redstone torch (on) + || id == 77 // Stone button + || id == 81; // Cactus + } } \ No newline at end of file