From 6f43c6a312b748566cec247d1a9a3c43f715f40e Mon Sep 17 00:00:00 2001 From: zml2008 Date: Tue, 13 Sep 2011 22:45:47 -0700 Subject: [PATCH] Updated for 1.8 blocks and items --- .../com/sk89q/worldedit/blocks/BlockID.java | 13 ++++++ .../com/sk89q/worldedit/blocks/BlockType.java | 46 +++++++++++++++++-- .../com/sk89q/worldedit/blocks/ItemType.java | 27 +++++++++-- .../sk89q/worldedit/bukkit/BukkitWorld.java | 2 +- .../sk89q/worldedit/tools/BlockDataCyler.java | 11 +++-- 5 files changed, 86 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/blocks/BlockID.java b/src/main/java/com/sk89q/worldedit/blocks/BlockID.java index 446e1e863..f7fb9e924 100644 --- a/src/main/java/com/sk89q/worldedit/blocks/BlockID.java +++ b/src/main/java/com/sk89q/worldedit/blocks/BlockID.java @@ -123,4 +123,17 @@ public final class BlockID { public static final int REDSTONE_REPEATER_ON = 94; public static final int LOCKED_CHEST = 95; public static final int TRAP_DOOR = 96; + public static final int SILVERFISH_BLOCK = 97; + public static final int STONE_BRICK = 98; + public static final int BROWN_MUSHROOM_CAP = 99; + public static final int RED_MUSHROOM_CAP = 100; + public static final int IRON_BARS = 101; + public static final int GLASS_PANE = 102; + public static final int MELON_BLOCK = 103; + public static final int PUMPKIN_STEM = 104; + public static final int MELON_STEM = 105; + public static final int VINE = 106; + public static final int FENCE_GATE = 107; + public static final int BRICK_STAIRS = 108; + public static final int STONE_BRICK_STAIRS = 109; } diff --git a/src/main/java/com/sk89q/worldedit/blocks/BlockType.java b/src/main/java/com/sk89q/worldedit/blocks/BlockType.java index 7b3bd41e2..798a6f39b 100644 --- a/src/main/java/com/sk89q/worldedit/blocks/BlockType.java +++ b/src/main/java/com/sk89q/worldedit/blocks/BlockType.java @@ -127,7 +127,20 @@ public enum BlockType { REDSTONE_REPEATER_OFF(BlockID.REDSTONE_REPEATER_OFF, "Redstone repeater (off)", "diodeoff", "redstonerepeater", "repeateroff", "delayeroff"), REDSTONE_REPEATER_ON(BlockID.REDSTONE_REPEATER_ON, "Redstone repeater (on)", "diodeon", "redstonerepeateron", "repeateron", "delayeron"), LOCKED_CHEST(BlockID.LOCKED_CHEST, "Locked chest", "lockedchest", "steveco", "supplycrate", "valveneedstoworkonep3nottf2kthx"), - TRAP_DOOR(BlockID.TRAP_DOOR, "Trap door", "trapdoor", "hatch", "floordoor"); + TRAP_DOOR(BlockID.TRAP_DOOR, "Trap door", "trapdoor", "hatch", "floordoor"), + SILVERFISH_BLOCK(BlockID.SILVERFISH_BLOCK, "Silverfish block", "silverfish", "silver"), + STONE_BRICK(BlockID.STONE_BRICK, "Stone brick", "stonebrick", "sbrick", "smoothstonebrick"), + RED_MUSHROOM_CAP(BlockID.RED_MUSHROOM_CAP, "Red mushroom cap", "giantmushroomred", "redgiantmushroom", "redmushroomcap"), + BROWN_MUSHROOM_CAP(BlockID.BROWN_MUSHROOM_CAP, "Brown mushroom cap", "giantmushroombrown", "browngiantmushoom", "brownmushroomcap"), + IRON_BARS(BlockID.IRON_BARS, "Iron bars", "ironbars", "ironfence"), + GLASS_PANE(BlockID.GLASS_PANE, "Glass pane", "window", "glasspane", "glasswindow"), + MELON_BLOCK(BlockID.MELON_BLOCK, "Melon (block)", "melonblock"), + PUMPKIN_STEM(BlockID.PUMPKIN_STEM, "Pumpkin stem", "pumpkinstem"), + MELON_STEM(BlockID.MELON_STEM, "Melon stem", "melonstem"), + VINE(BlockID.VINE, "Vine", "vine", "vines", "creepers"), + FENCE_GATE(BlockID.FENCE_GATE, "Fence gate", "fencegate", "gate"), + BRICK_STAIRS(BlockID.BRICK_STAIRS, "Brick stairs", "brickstairs", "bricksteps"), + STONE_BRICK_STAIRS(BlockID.STONE_BRICK_STAIRS, "Stone brick stairs", "stonebrickstairs", "smoothstonebrickstairs"); /** * Stores a list of dropped blocks for blocks. @@ -221,6 +234,19 @@ public enum BlockType { blockDrops.put(94, 356); blockDrops.put(95, 95); blockDrops.put(96, 96); + blockDrops.put(97, -1); + blockDrops.put(98, 98); + blockDrops.put(99, 99); + blockDrops.put(100, 100); + blockDrops.put(101, 101); + blockDrops.put(102, 102); + blockDrops.put(103, 103); + blockDrops.put(104, 104); + blockDrops.put(105, 105); + blockDrops.put(106, -1); + blockDrops.put(107, 107); + blockDrops.put(108, 45); + blockDrops.put(109, 98); } /** @@ -395,7 +421,10 @@ public enum BlockType { || id == BlockID.CAKE_BLOCK || id == BlockID.REDSTONE_REPEATER_OFF || id == BlockID.REDSTONE_REPEATER_ON - || id == BlockID.TRAP_DOOR; + || id == BlockID.TRAP_DOOR + || id == BlockID.FENCE_GATE + || id == BlockID.GLASS_PANE + || id == BlockID.VINE; } /** @@ -436,7 +465,9 @@ public enum BlockType { || id == BlockID.REED || id == BlockID.PORTAL || id == BlockID.REDSTONE_REPEATER_OFF - || id == BlockID.REDSTONE_REPEATER_ON; + || id == BlockID.REDSTONE_REPEATER_ON + || id == BlockID.FENCE_GATE + || id == BlockID.VINE; } /** @@ -492,7 +523,14 @@ public enum BlockType { || id == BlockID.CAKE_BLOCK || id == BlockID.REDSTONE_REPEATER_OFF || id == BlockID.REDSTONE_REPEATER_ON - || id == BlockID.TRAP_DOOR; + || id == BlockID.TRAP_DOOR + || id == BlockID.BRICK_STAIRS + || id == BlockID.STONE_BRICK_STAIRS + || id == BlockID.VINE + || id == BlockID.RED_MUSHROOM_CAP + || id == BlockID.BROWN_MUSHROOM_CAP + || id == BlockID.PUMPKIN_STEM + || id == BlockID.MELON_STEM; } /** diff --git a/src/main/java/com/sk89q/worldedit/blocks/ItemType.java b/src/main/java/com/sk89q/worldedit/blocks/ItemType.java index a284ff46b..9e83b3b6f 100644 --- a/src/main/java/com/sk89q/worldedit/blocks/ItemType.java +++ b/src/main/java/com/sk89q/worldedit/blocks/ItemType.java @@ -130,6 +130,19 @@ public enum ItemType { REDSTONE_REPEATER_ON(BlockID.REDSTONE_REPEATER_ON, "Redstone repeater (on)", "diodeon", "redstonerepeateron", "repeateron", "delayeron"), LOCKED_CHEST(BlockID.LOCKED_CHEST, "Locked chest", "lockedchest", "steveco", "supplycrate", "valveneedstoworkonep3nottf2kthx"), TRAP_DOOR(BlockID.TRAP_DOOR, "Trap door", "trapdoor", "hatch", "floordoor"), + SILVERFISH_BLOCK(BlockID.SILVERFISH_BLOCK, "Silverfish block", "silverfish", "silver"), + STONE_BRICK(BlockID.STONE_BRICK, "Stone brick", "stonebrick", "sbrick", "smoothstonebrick"), + RED_MUSHROOM_CAP(BlockID.RED_MUSHROOM_CAP, "Red mushroom cap", "giantmushroomred", "redgiantmushroom", "redmushroomcap"), + BROWN_MUSHROOM_CAP(BlockID.BROWN_MUSHROOM_CAP, "Brown mushroom cap", "giantmushroombrown", "browngiantmushoom", "brownmushroomcap"), + IRON_BARS(BlockID.IRON_BARS, "Iron bars", "ironbars", "ironfence"), + GLASS_PANE(BlockID.GLASS_PANE, "Glass pane", "window", "glasspane", "glasswindow"), + MELON_BLOCK(BlockID.MELON_BLOCK, "Melon (block)", "melonblock"), + PUMPKIN_STEM(BlockID.PUMPKIN_STEM, "Pumpkin stem", "pumpkinstem"), + MELON_STEM(BlockID.MELON_STEM, "Melon stem", "melonstem"), + VINE(BlockID.VINE, "Vine", "vine", "vines", "creepers"), + FENCE_GATE(BlockID.FENCE_GATE, "Fence gate", "fencegate", "gate"), + BRICK_STAIRS(BlockID.BRICK_STAIRS, "Brick stairs", "brickstairs", "bricksteps"), + STONE_BRICK_STAIRS(BlockID.STONE_BRICK_STAIRS, "Stone brick stairs", "stonebrickstairs", "smoothstonebrickstairs"), // Items IRON_SHOVEL(256, "Iron shovel", "ironshovel"), @@ -236,6 +249,15 @@ public enum ItemType { COOKIE(357, "Cookie", "cookie"), MAP(358, "Map", "map"), SHEARS(359, "Shears", "shears", "scissors"), + MELON(360, "Melon Slice", "melon", "melonslice"), + PUMPKIN_SEEDS(361, "Pumpkin seeds", "pumpkinseed", "pumpkinseeds"), + MELON_SEEDS(362, "Melon seeds", "melonseed", "melonseeds"), + RAW_BEEF(363, "Raw beef", "rawbeef", "rawcow", "beef"), + COOKED_BEEF(364, "Steak", "steak", "cookedbeef", "cookedcow"), + RAW_CHICKEN(365, "Raw chicken", "rawchicken"), + COOKED_CHICKEN(366, "Cooked chicken", "cookedchicken", "chicken", "grilledchicken"), + ROTTEN_FLESH(367, "Rotten flesh", "rottenflesh", "zombiemeat", "flesh"), + ENDER_PEARL(368, "Ender pearl", "pearl", "enderpearl"), GOLD_RECORD(2256, "Gold Record", "goldrecord", "golddisc"), GREEN_RECORD(2257, "Green Record", "greenrecord", "greenddisc"); @@ -441,7 +463,6 @@ public enum ItemType { || t == ItemType.IRON_HOE || t == ItemType.DIAMOND_HOE || t == ItemType.GOLD_HOE - || t == ItemType.BREAD || t == ItemType.LEATHER_HELMET || t == ItemType.LEATHER_CHEST || t == ItemType.LEATHER_PANTS @@ -462,8 +483,6 @@ public enum ItemType { || t == ItemType.GOLD_CHEST || t == ItemType.GOLD_PANTS || t == ItemType.GOLD_BOOTS - || t == ItemType.RAW_PORKCHOP - || t == ItemType.COOKED_PORKCHOP || t == ItemType.SIGN || t == ItemType.WOODEN_DOOR_ITEM || t == ItemType.BUCKET @@ -477,8 +496,6 @@ public enum ItemType { || t == ItemType.STORAGE_MINECART || t == ItemType.POWERED_MINECART || t == ItemType.WATCH - || t == ItemType.RAW_FISH - || t == ItemType.COOKED_FISH || t == ItemType.CAKE_ITEM || t == ItemType.BED_ITEM || t == ItemType.MAP diff --git a/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java index 2584ee4c3..dc162ed02 100644 --- a/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java +++ b/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java @@ -670,7 +670,7 @@ public class BukkitWorld extends LocalWorld { */ @Override public boolean isValidBlockType(int type) { - return type <= 255 && Material.getMaterial(type) != null; + return type <= 255 && (Material.getMaterial(type) != null || BlockType.fromID(type) != null); // Bukkit isn't always updated before WorldEdit is } @Override diff --git a/src/main/java/com/sk89q/worldedit/tools/BlockDataCyler.java b/src/main/java/com/sk89q/worldedit/tools/BlockDataCyler.java index 6885ad44f..ba59ae274 100644 --- a/src/main/java/com/sk89q/worldedit/tools/BlockDataCyler.java +++ b/src/main/java/com/sk89q/worldedit/tools/BlockDataCyler.java @@ -71,16 +71,19 @@ public class BlockDataCyler implements DoubleActionBlockTool { player.printError("This minecart track orientation is not supported."); return true; } - } else if (type == BlockID.WOODEN_STAIRS || type == BlockID.COBBLESTONE_STAIRS) { + } else if (type == BlockID.WOODEN_STAIRS + || type == BlockID.COBBLESTONE_STAIRS + || type == BlockID.BRICK_STAIRS + || type == BlockID.STONE_BRICK_STAIRS) { data = (data + increment) % 4; } else if (type == BlockID.SIGN_POST) { data = (data + increment) % 16; } else if (type == BlockID.WALL_SIGN) { data = ((data + increment) - 2) % 4 + 2; } else if (type == BlockID.STEP) { - data = (data + increment) % 4; + data = (data + increment) % 6; } else if (type == BlockID.DOUBLE_STEP) { - data = (data + increment) % 4; + data = (data + increment) % 6; } else if (type == BlockID.FURNACE || type == BlockID.BURNING_FURNACE || type == BlockID.DISPENSER) { data = (data + increment) % 4 + 2; @@ -92,6 +95,8 @@ public class BlockDataCyler implements DoubleActionBlockTool { } else { data = prevClothColor(data); } + } else if (type == BlockID.RED_MUSHROOM_CAP || type == BlockID.BROWN_MUSHROOM_CAP) { + data = (data + increment) % 2; } else { player.printError("That block's data cannot be cycled."); return true;