From 09f3364d9f4e8a8051f7b05a0261a5fd76702d78 Mon Sep 17 00:00:00 2001 From: sk89q Date: Sun, 5 Feb 2012 17:46:26 -0800 Subject: [PATCH] Moved the block data check to LocalWorld, adding preliminary support for custom blocks. All unknown blocks are now assumed to carry data, and so this will also future proof WorldEdit (for the immediate future). However, be aware that full custom block support requires carrying TileEntity data (and perhaps other data) and that is not yet supported. --- src/main/java/com/sk89q/worldedit/EditSession.java | 2 +- src/main/java/com/sk89q/worldedit/LocalWorld.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sk89q/worldedit/EditSession.java b/src/main/java/com/sk89q/worldedit/EditSession.java index 6c1044f0b..369f6cc47 100644 --- a/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/src/main/java/com/sk89q/worldedit/EditSession.java @@ -217,7 +217,7 @@ public class EditSession { final boolean result; - if (BlockType.usesData(type)) { + if (world.usesBlockData(type)) { if (fastMode) { result = world.setTypeIdAndDataFast(pt, type, block.getData() > -1 ? block.getData() : 0); } else { diff --git a/src/main/java/com/sk89q/worldedit/LocalWorld.java b/src/main/java/com/sk89q/worldedit/LocalWorld.java index e8ef88317..b226c525c 100644 --- a/src/main/java/com/sk89q/worldedit/LocalWorld.java +++ b/src/main/java/com/sk89q/worldedit/LocalWorld.java @@ -327,6 +327,17 @@ public abstract class LocalWorld { public boolean isValidBlockType(int type) { return BlockType.fromID(type) != null; } + + /** + * Returns whether a block uses its data value. + * + * @param type block ID type + * @return true if the block uses data value + */ + public boolean usesBlockData(int type) { + // We future proof here by assuming all unknown blocks use data + return BlockType.usesData(type) || BlockType.fromID(type) == null; + } /** * Checks if the chunk pt is in is loaded. if not, loads the chunk