From e1c2ea3a3bddda1ce68b8a7277dc46631467b6da Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Thu, 5 Jul 2018 23:22:33 +1000 Subject: [PATCH] Update configs, and remove unused BlockData methods. --- .../src/main/resources/defaults/config.yml | 66 +- .../sk89q/worldedit/LocalConfiguration.java | 2 +- .../com/sk89q/worldedit/blocks/BlockData.java | 1050 ----------------- .../com/sk89q/worldedit/blocks/BlockID.java | 28 - .../command/tool/BlockDataCyler.java | 23 +- .../worldedit/util/YAMLConfiguration.java | 2 +- .../sk89q/worldedit/CuboidClipboardTest.java | 38 - .../sk89q/worldedit/blocks/BlockDataTest.java | 64 - .../transform/BlockTransformExtentTest.java | 90 -- .../com/sk89q/worldedit/forge/ForgeWorld.java | 4 +- .../worldedit/forge/TileEntityBaseBlock.java | 6 +- .../resources/defaults/worldedit.properties | 6 +- .../config/ConfigurateConfiguration.java | 2 +- 13 files changed, 83 insertions(+), 1298 deletions(-) delete mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockData.java delete mode 100644 worldedit-core/src/test/java/com/sk89q/worldedit/CuboidClipboardTest.java delete mode 100644 worldedit-core/src/test/java/com/sk89q/worldedit/blocks/BlockDataTest.java delete mode 100644 worldedit-core/src/test/java/com/sk89q/worldedit/extent/transform/BlockTransformExtentTest.java diff --git a/worldedit-bukkit/src/main/resources/defaults/config.yml b/worldedit-bukkit/src/main/resources/defaults/config.yml index a0e0013ee..fd931081f 100644 --- a/worldedit-bukkit/src/main/resources/defaults/config.yml +++ b/worldedit-bukkit/src/main/resources/defaults/config.yml @@ -30,7 +30,67 @@ limits: butcher-radius: default: -1 maximum: -1 - disallowed-blocks: [6, 7, 14, 15, 16, 26, 27, 28, 29, 39, 31, 32, 33, 34, 36, 37, 38, 39, 40, 46, 50, 51, 56, 59, 69, 73, 74, 75, 76, 77, 81, 83, 137, 210, 211, 255] + disallowed-blocks: + - "minecraft:oak_sapling" + - "minecraft:jungle_sapling" + - "minecraft:dark_oak_sapling:" + - "minecraft:spruce_sapling" + - "minecraft:birch_sapling" + - "minecraft:acacia_sapling" + - "minecraft:black_bed" + - "minecraft:blue_bed" + - "minecraft:brown_bed" + - "minecraft:cyan_bed" + - "minecraft:gray_bed" + - "minecraft:green_bed" + - "minecraft:light_blue_bed" + - "minecraft:light_gray_bed" + - "minecraft:lime_bed" + - "minecraft:magenta_bed" + - "minecraft:orange_bed" + - "minecraft:pink_bed" + - "minecraft:purple_bed" + - "minecraft:red_bed" + - "minecraft:white_bed" + - "minecraft:yellow_bed" + - "minecraft:powered_rail" + - "minecraft:detector_rail" + - "minecraft:grass" + - "minecraft:dead_bush" + - "minecraft:moving_piston" + - "minecraft:piston_head" + - "minecraft:sunflower" + - "minecraft:rose_bush" + - "minecraft:dandelion" + - "minecraft:poppy" + - "minecraft:brown_mushroom" + - "minecraft:red_mushroom" + - "minecraft:tnt" + - "minecraft:torch" + - "minecraft:fire" + - "minecraft:redstone_wire" + - "minecraft:wheat" + - "minecraft:potatoes" + - "minecraft:carrots" + - "minecraft:melon_stem" + - "minecraft:pumpkin_stem" + - "minecraft:beetroots" + - "minecraft:rail" + - "minecraft:lever" + - "minecraft:redstone_torch" + - "minecraft:redstone_wall_torch" + - "minecraft:repeater" + - "minecraft:comparator" + - "minecraft:stone_button" + - "minecraft:birch_button" + - "minecraft:acacia_button" + - "minecraft:dark_oak_button" + - "minecraft:jungle_button" + - "minecraft:oak_button" + - "minecraft:spruce_button" + - "minecraft:cactus" + - "minecraft:sugar_cane" + - "minecraft:bedrock" use-inventory: enable: false @@ -60,7 +120,7 @@ snapshots: directory: navigation-wand: - item: 345 + item: minecraft:compass max-distance: 100 scripting: @@ -77,7 +137,7 @@ history: size: 15 expiration: 10 -wand-item: 271 +wand-item: minecraft:wooden_axe shell-save-type: no-double-slash: false no-op-permissions: false diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java index 8822c2a25..f6c2e9209 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java @@ -126,7 +126,7 @@ public abstract class LocalConfiguration { public String navigationWand = ItemTypes.COMPASS.getId(); public int navigationWandMaxDistance = 50; public int scriptTimeout = 3000; - public Set allowedDataCycleBlocks = new HashSet<>(); + public Set allowedDataCycleBlocks = new HashSet<>(); public String saveDir = "schematics"; public String scriptsDir = "craftscripts"; public boolean showHelpInfo = true; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockData.java b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockData.java deleted file mode 100644 index ebdfae894..000000000 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockData.java +++ /dev/null @@ -1,1050 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldedit.blocks; - -import com.sk89q.worldedit.CuboidClipboard.FlipDirection; - -/** - * Block data related classes. - */ -public final class BlockData { - - private BlockData() { - } - - /** - * Rotate a block's data value 90 degrees (north->east->south->west->north); - * - * @param type the type ID of the bock - * @param data the data ID of the block - * @return the new data value - */ - public static int rotate90(int type, int data) { - switch (type) { - case BlockID.TORCH: - case BlockID.REDSTONE_TORCH_OFF: - case BlockID.REDSTONE_TORCH_ON: - switch (data) { - case 1: return 3; - case 2: return 4; - case 3: return 2; - case 4: return 1; - } - break; - - case BlockID.MINECART_TRACKS: - switch (data) { - case 6: return 7; - case 7: return 8; - case 8: return 9; - case 9: return 6; - } - /* FALL-THROUGH */ - - case BlockID.POWERED_RAIL: - case BlockID.DETECTOR_RAIL: - case BlockID.ACTIVATOR_RAIL: - switch (data & 0x7) { - case 0: return 1 | (data & ~0x7); - case 1: return 0 | (data & ~0x7); - case 2: return 5 | (data & ~0x7); - case 3: return 4 | (data & ~0x7); - case 4: return 2 | (data & ~0x7); - case 5: return 3 | (data & ~0x7); - } - break; - - case BlockID.OAK_WOOD_STAIRS: - case BlockID.COBBLESTONE_STAIRS: - case BlockID.BRICK_STAIRS: - case BlockID.STONE_BRICK_STAIRS: - case BlockID.NETHER_BRICK_STAIRS: - case BlockID.SANDSTONE_STAIRS: - case BlockID.SPRUCE_WOOD_STAIRS: - case BlockID.BIRCH_WOOD_STAIRS: - case BlockID.JUNGLE_WOOD_STAIRS: - case BlockID.QUARTZ_STAIRS: - case BlockID.ACACIA_STAIRS: - case BlockID.DARK_OAK_STAIRS: - switch (data) { - case 0: return 2; - case 1: return 3; - case 2: return 1; - case 3: return 0; - case 4: return 6; - case 5: return 7; - case 6: return 5; - case 7: return 4; - } - break; - - case BlockID.STONE_BUTTON: - case BlockID.WOODEN_BUTTON: { - int thrown = data & 0x8; - switch (data & ~0x8) { - case 1: return 3 | thrown; - case 2: return 4 | thrown; - case 3: return 2 | thrown; - case 4: return 1 | thrown; - // 0 and 5 are vertical - } - break; - } - - case BlockID.LEVER: { - int thrown = data & 0x8; - switch (data & ~0x8) { - case 1: return 3 | thrown; - case 2: return 4 | thrown; - case 3: return 2 | thrown; - case 4: return 1 | thrown; - case 5: return 6 | thrown; - case 6: return 5 | thrown; - case 7: return 0 | thrown; - case 0: return 7 | thrown; - } - break; - } - - case BlockID.WOODEN_DOOR: - case BlockID.IRON_DOOR: - if ((data & 0x8) != 0) { - // door top halves contain no orientation information - break; - } - - /* FALL-THROUGH */ - - case BlockID.COCOA_PLANT: - case BlockID.TRIPWIRE_HOOK: { - int extra = data & ~0x3; - int withoutFlags = data & 0x3; - switch (withoutFlags) { - case 0: return 1 | extra; - case 1: return 2 | extra; - case 2: return 3 | extra; - case 3: return 0 | extra; - } - break; - } - case BlockID.SIGN_POST: - return (data + 4) % 16; - - case BlockID.LADDER: - case BlockID.WALL_SIGN: - case BlockID.CHEST: - case BlockID.FURNACE: - case BlockID.BURNING_FURNACE: - case BlockID.ENDER_CHEST: - case BlockID.TRAPPED_CHEST: - case BlockID.HOPPER: { - int extra = data & 0x8; - int withoutFlags = data & ~0x8; - switch (withoutFlags) { - case 2: return 5 | extra; - case 3: return 4 | extra; - case 4: return 2 | extra; - case 5: return 3 | extra; - } - break; - } - case BlockID.DISPENSER: - case BlockID.DROPPER: - int dispPower = data & 0x8; - switch (data & ~0x8) { - case 2: return 5 | dispPower; - case 3: return 4 | dispPower; - case 4: return 2 | dispPower; - case 5: return 3 | dispPower; - } - break; - - case BlockID.PUMPKIN: - case BlockID.JACKOLANTERN: - switch (data) { - case 0: return 1; - case 1: return 2; - case 2: return 3; - case 3: return 0; - } - break; - - case BlockID.HAY_BLOCK: - case BlockID.LOG: - case BlockID.LOG2: - if (data >= 4 && data <= 11) data ^= 0xc; - break; - - case BlockID.COMPARATOR_OFF: - case BlockID.COMPARATOR_ON: - case BlockID.REDSTONE_REPEATER_OFF: - case BlockID.REDSTONE_REPEATER_ON: - int dir = data & 0x03; - int delay = data - dir; - switch (dir) { - case 0: return 1 | delay; - case 1: return 2 | delay; - case 2: return 3 | delay; - case 3: return 0 | delay; - } - break; - - case BlockID.TRAP_DOOR: - case BlockID.IRON_TRAP_DOOR: - int withoutOrientation = data & ~0x3; - int orientation = data & 0x3; - switch (orientation) { - case 0: return 3 | withoutOrientation; - case 1: return 2 | withoutOrientation; - case 2: return 0 | withoutOrientation; - case 3: return 1 | withoutOrientation; - } - break; - - case BlockID.PISTON_BASE: - case BlockID.PISTON_STICKY_BASE: - case BlockID.PISTON_EXTENSION: - final int rest = data & ~0x7; - switch (data & 0x7) { - case 2: return 5 | rest; - case 3: return 4 | rest; - case 4: return 2 | rest; - case 5: return 3 | rest; - } - break; - - case BlockID.BROWN_MUSHROOM_CAP: - case BlockID.RED_MUSHROOM_CAP: - if (data >= 10) return data; - return (data * 3) % 10; - - case BlockID.VINE: - return ((data << 1) | (data >> 3)) & 0xf; - - case BlockID.FENCE_GATE: - return ((data + 1) & 0x3) | (data & ~0x3); - - case BlockID.ANVIL: - int damage = data & ~0x3; - switch (data & 0x3) { - case 0: return 3 | damage; - case 2: return 1 | damage; - case 1: return 0 | damage; - case 3: return 2 | damage; - } - break; - - case BlockID.BED: - return data & ~0x3 | (data + 1) & 0x3; - - case BlockID.HEAD: - switch (data) { - case 2: return 5; - case 3: return 4; - case 4: return 2; - case 5: return 3; - } - } - - return data; - } - - /** - * Rotate a block's data value -90 degrees (north<-east<-south<-west<-north); - * - * @param type the type ID of the bock - * @param data the data ID of the block - * @return the new data value - */ - public static int rotate90Reverse(int type, int data) { - // case ([0-9]+): return ([0-9]+) -> case \2: return \1 - - switch (type) { - case BlockID.TORCH: - case BlockID.REDSTONE_TORCH_OFF: - case BlockID.REDSTONE_TORCH_ON: - switch (data) { - case 3: return 1; - case 4: return 2; - case 2: return 3; - case 1: return 4; - } - break; - - case BlockID.MINECART_TRACKS: - switch (data) { - case 7: return 6; - case 8: return 7; - case 9: return 8; - case 6: return 9; - } - /* FALL-THROUGH */ - - case BlockID.POWERED_RAIL: - case BlockID.DETECTOR_RAIL: - case BlockID.ACTIVATOR_RAIL: - int power = data & ~0x7; - switch (data & 0x7) { - case 1: return 0 | power; - case 0: return 1 | power; - case 5: return 2 | power; - case 4: return 3 | power; - case 2: return 4 | power; - case 3: return 5 | power; - } - break; - - case BlockID.OAK_WOOD_STAIRS: - case BlockID.COBBLESTONE_STAIRS: - case BlockID.BRICK_STAIRS: - case BlockID.STONE_BRICK_STAIRS: - case BlockID.NETHER_BRICK_STAIRS: - case BlockID.SANDSTONE_STAIRS: - case BlockID.SPRUCE_WOOD_STAIRS: - case BlockID.BIRCH_WOOD_STAIRS: - case BlockID.JUNGLE_WOOD_STAIRS: - case BlockID.QUARTZ_STAIRS: - case BlockID.ACACIA_STAIRS: - case BlockID.DARK_OAK_STAIRS: - switch (data) { - case 2: return 0; - case 3: return 1; - case 1: return 2; - case 0: return 3; - case 6: return 4; - case 7: return 5; - case 5: return 6; - case 4: return 7; - } - break; - - case BlockID.STONE_BUTTON: - case BlockID.WOODEN_BUTTON: { - int thrown = data & 0x8; - switch (data & ~0x8) { - case 3: return 1 | thrown; - case 4: return 2 | thrown; - case 2: return 3 | thrown; - case 1: return 4 | thrown; - // 0 and 5 are vertical - } - break; - } - - case BlockID.LEVER: { - int thrown = data & 0x8; - switch (data & ~0x8) { - case 3: return 1 | thrown; - case 4: return 2 | thrown; - case 2: return 3 | thrown; - case 1: return 4 | thrown; - case 6: return 5 | thrown; - case 5: return 6 | thrown; - case 0: return 7 | thrown; - case 7: return 0 | thrown; - } - break; - } - - case BlockID.WOODEN_DOOR: - case BlockID.IRON_DOOR: - if ((data & 0x8) != 0) { - // door top halves contain no orientation information - break; - } - - /* FALL-THROUGH */ - - case BlockID.COCOA_PLANT: - case BlockID.TRIPWIRE_HOOK: { - int extra = data & ~0x3; - int withoutFlags = data & 0x3; - switch (withoutFlags) { - case 1: return 0 | extra; - case 2: return 1 | extra; - case 3: return 2 | extra; - case 0: return 3 | extra; - } - break; - } - case BlockID.SIGN_POST: - return (data + 12) % 16; - - case BlockID.LADDER: - case BlockID.WALL_SIGN: - case BlockID.CHEST: - case BlockID.FURNACE: - case BlockID.BURNING_FURNACE: - case BlockID.ENDER_CHEST: - case BlockID.TRAPPED_CHEST: - case BlockID.HOPPER: { - int extra = data & 0x8; - int withoutFlags = data & ~0x8; - switch (withoutFlags) { - case 5: return 2 | extra; - case 4: return 3 | extra; - case 2: return 4 | extra; - case 3: return 5 | extra; - } - break; - } - case BlockID.DISPENSER: - case BlockID.DROPPER: - int dispPower = data & 0x8; - switch (data & ~0x8) { - case 5: return 2 | dispPower; - case 4: return 3 | dispPower; - case 2: return 4 | dispPower; - case 3: return 5 | dispPower; - } - break; - case BlockID.PUMPKIN: - case BlockID.JACKOLANTERN: - switch (data) { - case 1: return 0; - case 2: return 1; - case 3: return 2; - case 0: return 3; - } - break; - - case BlockID.HAY_BLOCK: - case BlockID.LOG: - case BlockID.LOG2: - if (data >= 4 && data <= 11) data ^= 0xc; - break; - - case BlockID.COMPARATOR_OFF: - case BlockID.COMPARATOR_ON: - case BlockID.REDSTONE_REPEATER_OFF: - case BlockID.REDSTONE_REPEATER_ON: - int dir = data & 0x03; - int delay = data - dir; - switch (dir) { - case 1: return 0 | delay; - case 2: return 1 | delay; - case 3: return 2 | delay; - case 0: return 3 | delay; - } - break; - - case BlockID.TRAP_DOOR: - case BlockID.IRON_TRAP_DOOR: - int withoutOrientation = data & ~0x3; - int orientation = data & 0x3; - switch (orientation) { - case 3: return 0 | withoutOrientation; - case 2: return 1 | withoutOrientation; - case 0: return 2 | withoutOrientation; - case 1: return 3 | withoutOrientation; - } - - case BlockID.PISTON_BASE: - case BlockID.PISTON_STICKY_BASE: - case BlockID.PISTON_EXTENSION: - final int rest = data & ~0x7; - switch (data & 0x7) { - case 5: return 2 | rest; - case 4: return 3 | rest; - case 2: return 4 | rest; - case 3: return 5 | rest; - } - break; - - case BlockID.BROWN_MUSHROOM_CAP: - case BlockID.RED_MUSHROOM_CAP: - if (data >= 10) return data; - return (data * 7) % 10; - - case BlockID.VINE: - return ((data >> 1) | (data << 3)) & 0xf; - - case BlockID.FENCE_GATE: - return ((data + 3) & 0x3) | (data & ~0x3); - - case BlockID.ANVIL: - int damage = data & ~0x3; - switch (data & 0x3) { - case 0: return 1 | damage; - case 2: return 3 | damage; - case 1: return 2 | damage; - case 3: return 0 | damage; - } - break; - - case BlockID.BED: - return data & ~0x3 | (data - 1) & 0x3; - - case BlockID.HEAD: - switch (data) { - case 2: return 4; - case 3: return 5; - case 4: return 3; - case 5: return 2; - } - } - - return data; - } - - /** - * Flip a block's data value. - * - * @param type the type ID of the bock - * @param data the data ID of the block - * @return the new data value - */ - public static int flip(int type, int data) { - return rotate90(type, rotate90(type, data)); - } - - /** - * Flip a block's data value. - * - * @param type the type ID of the bock - * @param data the data ID of the block - * @param direction the direction to flip - * @return the new data value - */ - public static int flip(int type, int data, FlipDirection direction) { - int flipX = 0; - int flipY = 0; - int flipZ = 0; - - switch (direction) { - case NORTH_SOUTH: - flipZ = 1; - break; - - case WEST_EAST: - flipX = 1; - break; - - case UP_DOWN: - flipY = 1; - break; - } - - switch (type) { - case BlockID.TORCH: - case BlockID.REDSTONE_TORCH_OFF: - case BlockID.REDSTONE_TORCH_ON: - if (data < 1 || data > 4) break; - switch (data) { - case 1: return data + flipX; - case 2: return data - flipX; - case 3: return data + flipZ; - case 4: return data - flipZ; - } - break; - - case BlockID.STONE_BUTTON: - case BlockID.WOODEN_BUTTON: { - switch (data & ~0x8) { - case 1: return data + flipX; - case 2: return data - flipX; - case 3: return data + flipZ; - case 4: return data - flipZ; - case 0: - case 5: - return data ^ (flipY * 5); - } - break; - } - - case BlockID.LEVER: - switch (data & ~0x8) { - case 1: return data + flipX; - case 2: return data - flipX; - case 3: return data + flipZ; - case 4: return data - flipZ; - case 5: - case 7: - return data ^ flipY << 1; - case 6: - case 0: - return data ^ flipY * 6; - } - break; - - case BlockID.MINECART_TRACKS: - switch (data) { - case 6: return data + flipX + flipZ * 3; - case 7: return data - flipX + flipZ; - case 8: return data + flipX - flipZ; - case 9: return data - flipX - flipZ * 3; - } - /* FALL-THROUGH */ - - case BlockID.POWERED_RAIL: - case BlockID.DETECTOR_RAIL: - case BlockID.ACTIVATOR_RAIL: - switch (data & 0x7) { - case 0: - case 1: - return data; - case 2: - case 3: - return data ^ flipX; - case 4: - case 5: - return data ^ flipZ; - } - break; - - case BlockID.STEP: - case BlockID.WOODEN_STEP: - return data ^ (flipY << 3); - - case BlockID.OAK_WOOD_STAIRS: - case BlockID.COBBLESTONE_STAIRS: - case BlockID.BRICK_STAIRS: - case BlockID.STONE_BRICK_STAIRS: - case BlockID.NETHER_BRICK_STAIRS: - case BlockID.SANDSTONE_STAIRS: - case BlockID.SPRUCE_WOOD_STAIRS: - case BlockID.BIRCH_WOOD_STAIRS: - case BlockID.JUNGLE_WOOD_STAIRS: - case BlockID.QUARTZ_STAIRS: - case BlockID.ACACIA_STAIRS: - case BlockID.DARK_OAK_STAIRS: - data ^= flipY << 2; - switch (data) { - case 0: - case 1: - case 4: - case 5: - return data ^ flipX; - case 2: - case 3: - case 6: - case 7: - return data ^ flipZ; - } - break; - - case BlockID.WOODEN_DOOR: - case BlockID.IRON_DOOR: - if ((data & 0x8) != 0) { - // door top halves contain no orientation information - break; - } - - switch (data & 0x3) { - case 0: return data + flipX + flipZ * 3; - case 1: return data - flipX + flipZ; - case 2: return data + flipX - flipZ; - case 3: return data - flipX - flipZ * 3; - } - break; - - case BlockID.SIGN_POST: - switch (direction) { - case NORTH_SOUTH: - return (16 - data) & 0xf; - case WEST_EAST: - return (8 - data) & 0xf; - default: - } - break; - - case BlockID.LADDER: - case BlockID.WALL_SIGN: - case BlockID.CHEST: - case BlockID.FURNACE: - case BlockID.BURNING_FURNACE: - case BlockID.ENDER_CHEST: - case BlockID.TRAPPED_CHEST: - case BlockID.HOPPER: - int extra = data & 0x8; - int withoutFlags = data & ~0x8; - switch (withoutFlags) { - case 2: - case 3: - return (data ^ flipZ) | extra; - case 4: - case 5: - return (data ^ flipX) | extra; - } - break; - - case BlockID.DROPPER: - case BlockID.DISPENSER: - int dispPower = data & 0x8; - switch (data & ~0x8) { - case 2: - case 3: - return (data ^ flipZ) | dispPower; - case 4: - case 5: - return (data ^ flipX) | dispPower; - case 0: - case 1: - return (data ^ flipY) | dispPower; - } - break; - - case BlockID.PUMPKIN: - case BlockID.JACKOLANTERN: - if (data > 3) break; - /* FALL-THROUGH */ - - case BlockID.REDSTONE_REPEATER_OFF: - case BlockID.REDSTONE_REPEATER_ON: - case BlockID.COMPARATOR_OFF: - case BlockID.COMPARATOR_ON: - case BlockID.COCOA_PLANT: - case BlockID.TRIPWIRE_HOOK: - switch (data & 0x3) { - case 0: - case 2: - return data ^ (flipZ << 1); - case 1: - case 3: - return data ^ (flipX << 1); - } - break; - - case BlockID.TRAP_DOOR: - case BlockID.IRON_TRAP_DOOR: - switch (data & 0x3) { - case 0: - case 1: - return data ^ flipZ; - case 2: - case 3: - return data ^ flipX; - } - break; - - case BlockID.PISTON_BASE: - case BlockID.PISTON_STICKY_BASE: - case BlockID.PISTON_EXTENSION: - switch (data & ~0x8) { - case 0: - case 1: - return data ^ flipY; - case 2: - case 3: - return data ^ flipZ; - case 4: - case 5: - return data ^ flipX; - } - break; - - case BlockID.RED_MUSHROOM_CAP: - case BlockID.BROWN_MUSHROOM_CAP: - switch (data) { - case 1: - case 4: - case 7: - data += flipX * 2; - break; - case 3: - case 6: - case 9: - data -= flipX * 2; - break; - } - switch (data) { - case 1: - case 2: - case 3: - return data + flipZ * 6; - case 7: - case 8: - case 9: - return data - flipZ * 6; - } - break; - - case BlockID.VINE: - final int bit1, bit2; - switch (direction) { - case NORTH_SOUTH: - bit1 = 0x2; - bit2 = 0x8; - break; - case WEST_EAST: - bit1 = 0x1; - bit2 = 0x4; - break; - default: - return data; - } - int newData = data & ~(bit1 | bit2); - if ((data & bit1) != 0) newData |= bit2; - if ((data & bit2) != 0) newData |= bit1; - return newData; - - case BlockID.FENCE_GATE: - switch (data & 0x3) { - case 0: - case 2: - return data ^ flipZ << 1; - case 1: - case 3: - return data ^ flipX << 1; - } - break; - - case BlockID.BED: - switch (data & 0x3) { - case 0: - case 2: - return data ^ flipZ << 1; - case 1: - case 3: - return data ^ flipX << 1; - } - break; - - case BlockID.HEAD: - switch (data) { - case 2: - case 3: - return data ^ flipZ; - case 4: - case 5: - return data ^ flipX; - } - break; - - case BlockID.ANVIL: - switch (data & 0x3) { - case 0: - case 2: - return data ^ flipZ << 1; - case 1: - case 3: - return data ^ flipX << 1; - } - break; - - } - - return data; - } - - /** - * Cycle a block's data value. This usually goes through some rotational pattern - * depending on the block. If it returns -1, it means the id and data specified - * do not have anything to cycle to. - * - * @param type block id to be cycled - * @param data block data value that it starts at - * @param increment whether to go forward (1) or backward (-1) in the cycle - * @return the new data value for the block - */ - public static int cycle(int type, int data, int increment) { - return data + increment; - // TODO Fix -// if (increment != -1 && increment != 1) { -// throw new IllegalArgumentException("Increment must be 1 or -1."); -// } -// -// int store; -// switch (type) { -// -// // special case here, going to use "forward" for type and "backward" for orientation -// case BlockID.LOG: -// case BlockID.LOG2: -// if (increment == -1) { -// store = data & 0x3; // copy bottom (type) bits -// return mod((data & ~0x3) + 4, 16) | store; // switch orientation with top bits and reapply bottom bits; -// } else { -// store = data & ~0x3; // copy top (orientation) bits -// return mod((data & 0x3) + 1, 4) | store; // switch type with bottom bits and reapply top bits -// } -// -// // same here - screw you unit tests -// /*case BlockID.QUARTZ_BLOCK: -// if (increment == -1 && data > 2) { -// switch (data) { -// case 2: return 3; -// case 3: return 4; -// case 4: return 2; -// } -// } else if (increment == 1) { -// switch (data) { -// case 0: -// return 1; -// case 1: -// return 2; -// case 2: -// case 3: -// case 4: -// return 0; -// } -// } else { -// return -1; -// }*/ -// -// case BlockID.LONG_GRASS: -// case BlockID.SANDSTONE: -// case BlockID.DIRT: -// if (data > 2) return -1; -// return mod((data + increment), 3); -// -// case BlockID.TORCH: -// case BlockID.REDSTONE_TORCH_ON: -// case BlockID.REDSTONE_TORCH_OFF: -// if (data < 1 || data > 4) return -1; -// return mod((data - 1 + increment), 4) + 1; -// -// case BlockID.OAK_WOOD_STAIRS: -// case BlockID.COBBLESTONE_STAIRS: -// case BlockID.BRICK_STAIRS: -// case BlockID.STONE_BRICK_STAIRS: -// case BlockID.NETHER_BRICK_STAIRS: -// case BlockID.SANDSTONE_STAIRS: -// case BlockID.SPRUCE_WOOD_STAIRS: -// case BlockID.BIRCH_WOOD_STAIRS: -// case BlockID.JUNGLE_WOOD_STAIRS: -// case BlockID.QUARTZ_STAIRS: -// case BlockID.ACACIA_STAIRS: -// case BlockID.DARK_OAK_STAIRS: -// if (data > 7) return -1; -// return mod((data + increment), 8); -// -// case BlockID.STONE_BRICK: -// case BlockID.QUARTZ_BLOCK: -// case BlockID.PUMPKIN: -// case BlockID.JACKOLANTERN: -// case BlockID.NETHER_WART: -// case BlockID.CAULDRON: -// case BlockID.WOODEN_STEP: -// case BlockID.DOUBLE_WOODEN_STEP: -// case BlockID.HAY_BLOCK: -// if (data > 3) return -1; -// return mod((data + increment), 4); -// -// case BlockID.STEP: -// case BlockID.DOUBLE_STEP: -// case BlockID.CAKE_BLOCK: -// case BlockID.PISTON_BASE: -// case BlockID.PISTON_STICKY_BASE: -// case BlockID.SILVERFISH_BLOCK: -// if (data > 5) return -1; -// return mod((data + increment), 6); -// -// case BlockID.DOUBLE_PLANT: -// store = data & 0x8; // top half flag -// data &= ~0x8; -// if (data > 5) return -1; -// return mod((data + increment), 6) | store; -// -// case BlockID.CROPS: -// case BlockID.PUMPKIN_STEM: -// case BlockID.MELON_STEM: -// if (data > 6) return -1; -// return mod((data + increment), 7); -// -// case BlockID.SOIL: -// case BlockID.RED_FLOWER: -// if (data > 8) return -1; -// return mod((data + increment), 9); -// -// case BlockID.RED_MUSHROOM_CAP: -// case BlockID.BROWN_MUSHROOM_CAP: -// if (data > 10) return -1; -// return mod((data + increment), 11); -// -// case BlockID.CACTUS: -// case BlockID.REED: -// case BlockID.SIGN_POST: -// case BlockID.VINE: -// case BlockID.SNOW: -// case BlockID.COCOA_PLANT: -// if (data > 15) return -1; -// return mod((data + increment), 16); -// -// case BlockID.FURNACE: -// case BlockID.BURNING_FURNACE: -// case BlockID.WALL_SIGN: -// case BlockID.LADDER: -// case BlockID.CHEST: -// case BlockID.ENDER_CHEST: -// case BlockID.TRAPPED_CHEST: -// case BlockID.HOPPER: -// int extra = data & 0x8; -// int withoutFlags = data & ~0x8; -// if (withoutFlags < 2 || withoutFlags > 5) return -1; -// return (mod((withoutFlags - 2 + increment), 4) + 2) | extra; -// -// case BlockID.DISPENSER: -// case BlockID.DROPPER: -// store = data & 0x8; -// data &= ~0x8; -// if (data > 5) return -1; -// return mod((data + increment), 6) | store; -// -// case BlockID.REDSTONE_REPEATER_OFF: -// case BlockID.REDSTONE_REPEATER_ON: -// case BlockID.COMPARATOR_OFF: -// case BlockID.COMPARATOR_ON: -// case BlockID.TRAP_DOOR: -// case BlockID.FENCE_GATE: -// case BlockID.LEAVES: -// case BlockID.LEAVES2: -// if (data > 7) return -1; -// store = data & ~0x3; -// return mod(((data & 0x3) + increment), 4) | store; -// -// case BlockID.MINECART_TRACKS: -// if (data < 6 || data > 9) return -1; -// return mod((data - 6 + increment), 4) + 6; -// -// case BlockID.SAPLING: -// if ((data & 0x3) == 3 || data > 15) return -1; -// store = data & ~0x3; -// return mod(((data & 0x3) + increment), 3) | store; -// -// case BlockID.FLOWER_POT: -// if (data > 13) return -1; -// return mod((data + increment), 14); -// -// case BlockID.CLOTH: -// case BlockID.STAINED_CLAY: -// case BlockID.CARPET: -// case BlockID.STAINED_GLASS: -// case BlockID.STAINED_GLASS_PANE: -// if (increment == 1) { -// data = nextClothColor(data); -// } else if (increment == -1) { -// data = prevClothColor(data); -// } -// return data; -// -// default: -// return -1; -// } - } - - /** - * Better modulo, not just remainder. - */ - private static int mod(int x, int y) { - int res = x % y; - return res < 0 ? res + y : res; - } - -} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockID.java b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockID.java index eb145bf78..c9f382617 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockID.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockID.java @@ -29,15 +29,11 @@ import com.sk89q.worldedit.world.block.BlockTypes; @Deprecated public final class BlockID { public static final int SAPLING = 6; - public static final int LOG = 17; - public static final int DISPENSER = 23; public static final int BED = 26; public static final int POWERED_RAIL = 27; // GOLDEN_RAIL public static final int DETECTOR_RAIL = 28; - public static final int PISTON_STICKY_BASE = 29; // STICKY_PISTON public static final int LONG_GRASS = 31; // TALLGRASS public static final int DEAD_BUSH = 32; // DEADBUSH - public static final int PISTON_BASE = 33; // PISTON public static final int PISTON_EXTENSION = 34; // PISTON_HEAD public static final int YELLOW_FLOWER = 37; public static final int RED_FLOWER = 38; @@ -45,17 +41,12 @@ public final class BlockID { public static final int RED_MUSHROOM = 40; public static final int STEP = 44; // STONE_SLAB public static final int TORCH = 50; - public static final int OAK_WOOD_STAIRS = 53; // OAK_STAIRS - public static final int CHEST = 54; public static final int REDSTONE_WIRE = 55; public static final int CROPS = 59; // WHEAT - public static final int FURNACE = 61; - public static final int BURNING_FURNACE = 62; // LIT_FURNACE public static final int SIGN_POST = 63; // STANDING_SIGN public static final int WOODEN_DOOR = 64; // WOODEN_DOOR public static final int LADDER = 65; public static final int MINECART_TRACKS = 66; // RAIL - public static final int COBBLESTONE_STAIRS = 67; // STONE_STAIRS public static final int WALL_SIGN = 68; public static final int LEVER = 69; public static final int STONE_PRESSURE_PLATE = 70; @@ -68,23 +59,16 @@ public final class BlockID { public static final int CACTUS = 81; public static final int REED = 83; // REEDS public static final int FENCE = 85; - public static final int PUMPKIN = 86; public static final int SLOW_SAND = 88; // SOUL_SAND - public static final int JACKOLANTERN = 91; // LIT_PUMPKIN public static final int CAKE_BLOCK = 92; // CAKE public static final int REDSTONE_REPEATER_OFF = 93; // UNPOWERED_REPEATER public static final int REDSTONE_REPEATER_ON = 94; // POWERED_REPEATER public static final int TRAP_DOOR = 96; // TRAPDOOR - public static final int BROWN_MUSHROOM_CAP = 99; // BROWN_MUSHROOM_BLOCK - public static final int RED_MUSHROOM_CAP = 100; // RED_MUSHROOM_BLOCK 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; public static final int LILY_PAD = 111; // WATERLILY - public static final int NETHER_BRICK_STAIRS = 114; public static final int NETHER_WART = 115; public static final int ENCHANTMENT_TABLE = 116; // ENCHANTING_TABLE public static final int BREWING_STAND = 117; @@ -92,13 +76,8 @@ public final class BlockID { public static final int END_PORTAL_FRAME = 120; public static final int WOODEN_STEP = 126; // WOODEN_SLAB public static final int COCOA_PLANT = 127; // COCOA - public static final int SANDSTONE_STAIRS = 128; - public static final int ENDER_CHEST = 130; public static final int TRIPWIRE_HOOK = 131; public static final int TRIPWIRE = 132; - public static final int SPRUCE_WOOD_STAIRS = 134; // SPRUCE_STAIRS - public static final int BIRCH_WOOD_STAIRS = 135; // BRUCE_STAIRS - public static final int JUNGLE_WOOD_STAIRS = 136; // JUNGLE_STAIRS public static final int COBBLESTONE_WALL = 139; public static final int FLOWER_POT = 140; public static final int CARROTS = 141; @@ -106,21 +85,14 @@ public final class BlockID { public static final int WOODEN_BUTTON = 143; public static final int HEAD = 144; // SKULL public static final int ANVIL = 145; - public static final int TRAPPED_CHEST = 146; public static final int PRESSURE_PLATE_LIGHT = 147; // LIGHT_WEIGHTED_PRESSURE_PLATE public static final int PRESSURE_PLATE_HEAVY = 148; // HEAVY_WEIGHTED_PRESSURE_PLATE public static final int COMPARATOR_OFF = 149; // UNPOWERED_COMPARATOR public static final int COMPARATOR_ON = 150; // COMPARATOR public static final int DAYLIGHT_SENSOR = 151; // DAYLIGHT_DETECTOR public static final int HOPPER = 154; - public static final int QUARTZ_STAIRS = 156; public static final int ACTIVATOR_RAIL = 157; - public static final int DROPPER = 158; - public static final int LOG2 = 162; - public static final int ACACIA_STAIRS = 163; - public static final int DARK_OAK_STAIRS = 164; public static final int IRON_TRAP_DOOR = 167; - public static final int HAY_BLOCK = 170; public static final int CARPET = 171; public static final int DOUBLE_PLANT = 175; public static final int STANDING_BANNER = 176; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java index b99af7a3f..4e025ff7e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java @@ -23,15 +23,12 @@ import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.MaxChangedBlocksException; -import com.sk89q.worldedit.blocks.BaseBlock; -import com.sk89q.worldedit.blocks.BlockData; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.World; -import com.sk89q.worldedit.world.registry.LegacyMapper; +import com.sk89q.worldedit.world.block.BlockState; /** * A mode that cycles the data values of supported blocks. @@ -49,24 +46,24 @@ public class BlockDataCyler implements DoubleActionBlockTool { World world = (World) clicked.getExtent(); BlockState block = world.getBlock(clicked.toVector()); - int[] datas = LegacyMapper.getInstance().getLegacyFromBlock(block); - int type = datas[0]; - int data = datas[1]; if (!config.allowedDataCycleBlocks.isEmpty() && !player.hasPermission("worldedit.override.data-cycler") - && !config.allowedDataCycleBlocks.contains(type)) { + && !config.allowedDataCycleBlocks.contains(block.getBlockType().getId())) { player.printError("You are not permitted to cycle the data value of that block."); return true; } - int increment = forward ? 1 : -1; - BaseBlock newBlock = new BaseBlock(type, BlockData.cycle(type, data, increment)); - EditSession editSession = session.createEditSession(player); - - if (newBlock.getData() < 0) { + if (block.getStates().keySet().isEmpty()) { player.printError("That block's data cannot be cycled!"); } else { + BlockState newBlock = block; + + // TODO Forward = cycle value, Backward = Next property + // int increment = forward ? 1 : -1; + // BaseBlock newBlock = new BaseBlock(type, BlockData.cycle(type, data, increment)); + EditSession editSession = session.createEditSession(player); + try { editSession.setBlock(clicked.toVector(), newBlock); } catch (MaxChangedBlocksException e) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java index 24705db26..b6c3a0f1e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java @@ -84,7 +84,7 @@ public class YAMLConfiguration extends LocalConfiguration { butcherMaxRadius = Math.max(-1, config.getInt("limits.butcher-radius.maximum", butcherMaxRadius)); disallowedBlocks = new HashSet<>(config.getStringList("limits.disallowed-blocks", Lists.newArrayList(defaultDisallowedBlocks))); - allowedDataCycleBlocks = new HashSet<>(config.getIntList("limits.allowed-data-cycle-blocks", null)); + allowedDataCycleBlocks = new HashSet<>(config.getStringList("limits.allowed-data-cycle-blocks", null)); registerHelp = config.getBoolean("register-help", true); logCommands = config.getBoolean("logging.log-commands", logCommands); diff --git a/worldedit-core/src/test/java/com/sk89q/worldedit/CuboidClipboardTest.java b/worldedit-core/src/test/java/com/sk89q/worldedit/CuboidClipboardTest.java deleted file mode 100644 index 64afecfe5..000000000 --- a/worldedit-core/src/test/java/com/sk89q/worldedit/CuboidClipboardTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldedit; - -// TODO FIX -public class CuboidClipboardTest { -// @Test -// public void testFlipCenterPlane() throws Exception { -// testFlip(0, 1, CuboidClipboard.FlipDirection.UP_DOWN); -// testFlip(2, 3, CuboidClipboard.FlipDirection.NORTH_SOUTH); -// testFlip(4, 5, CuboidClipboard.FlipDirection.WEST_EAST); -// } -// -// private void testFlip(int data, int expectedDataAfterFlip, CuboidClipboard.FlipDirection flipDirection) { -// BlockType blockType = new BlockType("minecraft:piston_base"); -// final CuboidClipboard clipboard = new CuboidClipboard(new Vector(1, 1, 1)); -// clipboard.setBlock(Vector.ZERO, new BaseBlock(blockType, data)); -// clipboard.flip(flipDirection); -// assertEquals(expectedDataAfterFlip, clipboard.getBlock(Vector.ZERO).getData()); -// } -} diff --git a/worldedit-core/src/test/java/com/sk89q/worldedit/blocks/BlockDataTest.java b/worldedit-core/src/test/java/com/sk89q/worldedit/blocks/BlockDataTest.java deleted file mode 100644 index 1a44ddeb0..000000000 --- a/worldedit-core/src/test/java/com/sk89q/worldedit/blocks/BlockDataTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldedit.blocks; - -import com.sk89q.worldedit.CuboidClipboard.FlipDirection; -import org.junit.Test; - -import java.util.TreeSet; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -public class BlockDataTest { - - @Test - public void testRotateFlip() { - for (int type = 0; type < 256; ++type) { - for (int data = 0; data < 16; ++data) { - final String message = type + "/" + data; - - //Test r90(r-90(x))==x - assertEquals(message, data, BlockData.rotate90(type, BlockData.rotate90Reverse(type, data))); - //Test r-90(r90(x))==x - assertEquals(message, data, BlockData.rotate90Reverse(type, BlockData.rotate90(type, data))); - - final int flipped = BlockData.flip(type, BlockData.flip(type, data, FlipDirection.WEST_EAST), FlipDirection.NORTH_SOUTH); - - //Test r90(r90(x))==flipNS(flipWE(x)) - assertEquals(message, flipped, BlockData.rotate90(type, BlockData.rotate90(type, data))); - //Test r-90(r-90(x))==flipNS(flipWE(x)) - assertEquals(message, flipped, BlockData.rotate90Reverse(type, BlockData.rotate90Reverse(type, data))); - - //Test flipNS(flipNS(x))==x - assertEquals(message, data, BlockData.flip(type, BlockData.flip(type, data, FlipDirection.NORTH_SOUTH), FlipDirection.NORTH_SOUTH)); - //Test flipWE(flipWE(x))==x - assertEquals(message, data, BlockData.flip(type, BlockData.flip(type, data, FlipDirection.WEST_EAST), FlipDirection.WEST_EAST)); - //Test flipUD(flipUD(x))==x - assertEquals(message, data, BlockData.flip(type, BlockData.flip(type, data, FlipDirection.UP_DOWN), FlipDirection.UP_DOWN)); - - //Test r90(r90(r90(r90(x))))==x - assertEquals(message, data, BlockData.rotate90(type, BlockData.rotate90(type, BlockData.rotate90(type, BlockData.rotate90(type, data))))); - //Test r-90(r-90(r-90(r-90(x))))==x - assertEquals(message, data, BlockData.rotate90Reverse(type, BlockData.rotate90Reverse(type, BlockData.rotate90Reverse(type, BlockData.rotate90Reverse(type, data))))); - } - } - } -} diff --git a/worldedit-core/src/test/java/com/sk89q/worldedit/extent/transform/BlockTransformExtentTest.java b/worldedit-core/src/test/java/com/sk89q/worldedit/extent/transform/BlockTransformExtentTest.java deleted file mode 100644 index 740a6d653..000000000 --- a/worldedit-core/src/test/java/com/sk89q/worldedit/extent/transform/BlockTransformExtentTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldedit.extent.transform; - -import com.sk89q.worldedit.blocks.BaseBlock; -import com.sk89q.worldedit.blocks.BlockData; -import com.sk89q.worldedit.world.block.BlockType; -import com.sk89q.worldedit.world.block.BlockTypes; -import com.sk89q.worldedit.math.transform.AffineTransform; -import com.sk89q.worldedit.math.transform.Transform; -import com.sk89q.worldedit.world.registry.BlockRegistry; -import com.sk89q.worldedit.world.registry.BundledBlockRegistry; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import java.util.HashSet; -import java.util.Set; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; - -@Ignore("Old BlockData class needs to be updated manually. Current block definitions are in blocks.json, " + - "which is automatically generated and generally accurate.") -public class BlockTransformExtentTest { - - private static final Transform ROTATE_90 = new AffineTransform().rotateY(-90); - private static final Transform ROTATE_NEG_90 = new AffineTransform().rotateY(90); - private final Set ignored = new HashSet<>(); - - @Before - public void setUp() throws Exception { - ignored.add(BlockTypes.BLACK_BED); // Broken in existing rotation code? - ignored.add(BlockTypes.BLUE_BED); // Complicated - ignored.add(BlockTypes.BROWN_BED); // Complicated - ignored.add(BlockTypes.CYAN_BED); // Complicated - ignored.add(BlockTypes.GRAY_BED); // Complicated - ignored.add(BlockTypes.GREEN_BED); // Complicated - ignored.add(BlockTypes.LIGHT_BLUE_BED); // Complicated - ignored.add(BlockTypes.LIGHT_GRAY_BED); // Complicated - ignored.add(BlockTypes.LIME_BED); // Complicated - ignored.add(BlockTypes.OAK_DOOR); // Complicated - ignored.add(BlockTypes.IRON_DOOR); // Complicated - ignored.add(BlockTypes.END_PORTAL); // Not supported in existing rotation code - } - - @Test - public void testTransform() throws Exception { - BlockRegistry blockRegistry = new BundledBlockRegistry(); - for (BlockType type : BlockTypes.values()) { - if (ignored.contains(type)) { - continue; - } - - BaseBlock orig = new BaseBlock(type); - for (int i = 1; i < 4; i++) { - BaseBlock rotated = BlockTransformExtent.transform(new BaseBlock(orig), ROTATE_90); - BaseBlock reference = new BaseBlock(orig.getBlockType().getLegacyId(), BlockData.rotate90(orig.getBlockType().getLegacyId(), orig.getData())); - assertThat(type + "#" + type.getId() + " rotated " + (90 * i) + " degrees did not match BlockData.rotate90()'s expected result", rotated, - equalTo(reference)); - orig = rotated; - } - - orig = new BaseBlock(type); - for (int i = 0; i < 4; i++) { - BaseBlock rotated = BlockTransformExtent.transform(new BaseBlock(orig), ROTATE_NEG_90); - BaseBlock reference = new BaseBlock(orig.getBlockType().getLegacyId(), BlockData.rotate90Reverse(orig.getBlockType().getLegacyId(), orig.getData())); - assertThat(type + "#" + type.getId() + " rotated " + (-90 * i) + " degrees did not match BlockData.rotate90Reverse()'s expected result", rotated, equalTo(reference)); - orig = rotated; - } - } - } -} \ No newline at end of file diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java index 62756cbc8..7a3400b82 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java @@ -366,13 +366,11 @@ public class ForgeWorld extends AbstractWorld { @Override public BaseBlock getFullBlock(Vector position) { - World world = getWorld(); BlockPos pos = new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()); - IBlockState state = world.getBlockState(pos); TileEntity tile = getWorld().getTileEntity(pos); if (tile != null) { - return new TileEntityBaseBlock(Block.getIdFromBlock(state.getBlock()), state.getBlock().getMetaFromState(state), tile); + return new TileEntityBaseBlock(getBlock(position), tile); } else { return new BaseBlock(getBlock(position)); } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/TileEntityBaseBlock.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/TileEntityBaseBlock.java index 068482408..6aa0ff73a 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/TileEntityBaseBlock.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/TileEntityBaseBlock.java @@ -21,14 +21,14 @@ package com.sk89q.worldedit.forge; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.TileEntityBlock; +import com.sk89q.worldedit.world.block.BlockState; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; public class TileEntityBaseBlock extends BaseBlock implements TileEntityBlock { - public TileEntityBaseBlock(int type, int data, TileEntity tile) { - super(type, data); - setNbtData(NBTConverter.fromNative(copyNbtData(tile))); + public TileEntityBaseBlock(BlockState state, TileEntity tile) { + super(state, NBTConverter.fromNative(copyNbtData(tile))); } private static NBTTagCompound copyNbtData(TileEntity tile) { diff --git a/worldedit-forge/src/main/resources/defaults/worldedit.properties b/worldedit-forge/src/main/resources/defaults/worldedit.properties index d84d56faf..4fa5671d5 100644 --- a/worldedit-forge/src/main/resources/defaults/worldedit.properties +++ b/worldedit-forge/src/main/resources/defaults/worldedit.properties @@ -4,15 +4,15 @@ schematic-save-dir=schematics allow-extra-data-values=false super-pickaxe-many-drop-items=true register-help=true -nav-wand-item=345 +nav-wand-item=minecraft:compass profile=false super-pickaxe-drop-items=true -disallowed-blocks=6,26,27,28,31,32,34,36,37,38,39,40,46,50,51,55,59,66,69,75,76,93,94,77,81,83,7,14,15,16,56 +disallowed-blocks=minecraft:oak_sapling,minecraft:jungle_sapling,minecraft:dark_oak_sapling:,minecraft:spruce_sapling,minecraft:birch_sapling,minecraft:acacia_sapling,minecraft:black_bed,minecraft:blue_bed,minecraft:brown_bed,minecraft:cyan_bed,minecraft:gray_bed,minecraft:green_bed,minecraft:light_blue_bed,minecraft:light_gray_bed,minecraft:lime_bed,minecraft:magenta_bed,minecraft:orange_bed,minecraft:pink_bed,minecraft:purple_bed,minecraft:red_bed,minecraft:white_bed,minecraft:yellow_bed,minecraft:powered_rail,minecraft:detector_rail,minecraft:grass,minecraft:dead_bush,minecraft:moving_piston,minecraft:piston_head,minecraft:sunflower,minecraft:rose_bush,minecraft:dandelion,minecraft:poppy,minecraft:brown_mushroom,minecraft:red_mushroom,minecraft:tnt,minecraft:torch,minecraft:fire,minecraft:redstone_wire,minecraft:wheat,minecraft:potatoes,minecraft:carrots,minecraft:melon_stem,minecraft:pumpkin_stem,minecraft:beetroots,minecraft:rail,minecraft:lever,minecraft:redstone_torch,minecraft:redstone_wall_torch,minecraft:repeater,minecraft:comparator,minecraft:stone_button,minecraft:birch_button,minecraft:acacia_button,minecraft:dark_oak_button,minecraft:jungle_button,minecraft:oak_button,minecraft:spruce_button,minecraft:cactus,minecraft:sugar_cane,minecraft:bedrock max-super-pickaxe-size=5 max-brush-radius=10 craftscript-dir=craftscripts no-double-slash=false -wand-item=271 +wand-item=minecraft:wooden_axe shell-save-type= scripting-timeout=3000 snapshots-dir= diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java index 80ff1e0e9..e38140bb4 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java @@ -83,7 +83,7 @@ public class ConfigurateConfiguration extends LocalConfiguration { logger.warn("Error loading WorldEdit configuration", e); } try { - allowedDataCycleBlocks = new HashSet<>(node.getNode("limits", "allowed-data-cycle-blocks").getList(TypeToken.of(Integer.class))); + allowedDataCycleBlocks = new HashSet<>(node.getNode("limits", "allowed-data-cycle-blocks").getList(TypeToken.of(String.class))); } catch (ObjectMappingException e) { logger.warn("Error loading WorldEdit configuration", e); }