From 767c445f4ccdd82f4070cbb43d18315dfa24be46 Mon Sep 17 00:00:00 2001 From: sk89q Date: Thu, 4 Nov 2010 23:29:38 -0700 Subject: [PATCH] Improved the prioritized block spawn list by adding more block types. --- src/EditSession.java | 21 +-------- src/com/sk89q/worldedit/blocks/BlockType.java | 44 +++++++++++++++++++ 2 files changed, 46 insertions(+), 19 deletions(-) diff --git a/src/EditSession.java b/src/EditSession.java index ad5c37fa7..4274a76e4 100644 --- a/src/EditSession.java +++ b/src/EditSession.java @@ -70,28 +70,11 @@ public class EditSession { * reproduction. */ private boolean queued = false; - /** - * List of object types to queue. - */ - private static final HashSet queuedBlocks = new HashSet(); /** * Random number generator. */ private static Random prng = new Random(); - static { - queuedBlocks.add(50); // Torch - queuedBlocks.add(37); // Yellow flower - queuedBlocks.add(38); // Red rose - queuedBlocks.add(39); // Brown mushroom - queuedBlocks.add(40); // Red mushroom - queuedBlocks.add(59); // Crops - queuedBlocks.add(63); // Sign - queuedBlocks.add(75); // Redstone torch (off) - queuedBlocks.add(76); // Redstone torch (on) - queuedBlocks.add(84); // Reed - } - /** * Default constructor. There is no maximum blocks limit. */ @@ -200,12 +183,12 @@ public class EditSession { */ private boolean smartSetBlock(Vector pt, BaseBlock block) { if (queued) { - if (!block.isAir() && queuedBlocks.contains(block.getID()) + if (!block.isAir() && BlockType.shouldPlaceLast(block.getID()) && rawGetBlock(pt.add(0, -1, 0)).isAir()) { queue.put(pt.toBlockVector(), block); return getBlock(pt).getID() != block.getID(); } else if (block.isAir() - && queuedBlocks.contains(rawGetBlock(pt.add(0, 1, 0)).getID())) { + && BlockType.shouldPlaceLast(rawGetBlock(pt.add(0, 1, 0)).getID())) { rawSetBlock(pt.add(0, 1, 0), new BaseBlock(0)); // Prevent items from being dropped } } diff --git a/src/com/sk89q/worldedit/blocks/BlockType.java b/src/com/sk89q/worldedit/blocks/BlockType.java index f0da66a29..85f966e5e 100644 --- a/src/com/sk89q/worldedit/blocks/BlockType.java +++ b/src/com/sk89q/worldedit/blocks/BlockType.java @@ -192,4 +192,48 @@ public enum BlockType { public String getName() { return name; } + + /** + * Checks to see whether a block should be placed last. + * + * @param id + * @return + */ + public boolean shouldPlaceLast() { + return shouldPlaceLast(id); + } + + /** + * Checks to see whether a block should be placed last. + * + * @param id + * @return + */ + public static boolean shouldPlaceLast(int id) { + return id == 6 // Saplings + || id == 37 // Yellow flower + || id == 38 // Red flower + || id == 39 // Brown mushroom + || id == 40 // Red mush room + || id == 50 // Torch + || id == 51 // Fire + || id == 55 // Redstone wire + || id == 59 // Crops + || id == 63 // Sign post + || id == 64 // Wooden door + || id == 65 // Ladder + || id == 66 // Minecart tracks + || 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 == 78 // Snow + || id == 81 // Cactus + || id == 83 // Reed + || id == 90; // Portal + } } \ No newline at end of file