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 index f7f460892..23bc91262 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockData.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockData.java @@ -95,12 +95,22 @@ public final class BlockData { } break; - case BlockID.LEVER: case BlockID.STONE_BUTTON: - case BlockID.WOODEN_BUTTON: + case BlockID.WOODEN_BUTTON: { int thrown = data & 0x8; - int withoutThrown = data & ~0x8; - switch (withoutThrown) { + 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; @@ -111,6 +121,7 @@ public final class BlockData { case 0: return 7 | thrown; } break; + } case BlockID.WOODEN_DOOR: case BlockID.IRON_DOOR: @@ -316,12 +327,22 @@ public final class BlockData { } break; - case BlockID.LEVER: case BlockID.STONE_BUTTON: - case BlockID.WOODEN_BUTTON: + case BlockID.WOODEN_BUTTON: { int thrown = data & 0x8; - int withoutThrown = data & ~0x8; - switch (withoutThrown) { + 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; @@ -332,6 +353,7 @@ public final class BlockData { case 7: return 0 | thrown; } break; + } case BlockID.WOODEN_DOOR: case BlockID.IRON_DOOR: @@ -509,11 +531,29 @@ public final class BlockData { case BlockID.REDSTONE_TORCH_OFF: case BlockID.REDSTONE_TORCH_ON: if (data < 1 || data > 4) break; - /* FALL-THROUGH */ + 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: - case BlockID.STONE_BUTTON: - case BlockID.WOODEN_BUTTON: switch (data & ~0x8) { case 1: return data + flipX; case 2: return data - flipX; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockType.java index e898eb600..eb83208a7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockType.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockType.java @@ -1842,6 +1842,10 @@ public enum BlockType { addCardinals(BlockID.STONE_BUTTON, offset + 4, offset + 1, offset + 3, offset + 2); addCardinals(BlockID.WOODEN_BUTTON, offset + 4, offset + 1, offset + 3, offset + 2); } + dataAttachments.put(typeDataKey(BlockID.STONE_BUTTON, 0), PlayerDirection.UP); + dataAttachments.put(typeDataKey(BlockID.STONE_BUTTON, 5), PlayerDirection.DOWN); + dataAttachments.put(typeDataKey(BlockID.WOODEN_BUTTON, 0), PlayerDirection.UP); + dataAttachments.put(typeDataKey(BlockID.WOODEN_BUTTON, 5), PlayerDirection.DOWN); nonDataAttachments.put(BlockID.CACTUS, PlayerDirection.DOWN); nonDataAttachments.put(BlockID.REED, PlayerDirection.DOWN); nonDataAttachments.put(BlockID.CAKE_BLOCK, PlayerDirection.DOWN); diff --git a/worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/blocks.json b/worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/blocks.json index f4a08d736..f745e2a09 100644 --- a/worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/blocks.json +++ b/worldedit-core/src/main/resources/com/sk89q/worldedit/world/registry/blocks.json @@ -2755,8 +2755,8 @@ "values": { "down": { "data": 0, "direction": [0, -1, 0] }, "east": { "data": 1, "direction": [1, 0, 0] }, - "south": { "data": 2, "direction": [0, 0, 1] }, - "west": { "data": 3, "direction": [-1, 0, 0] }, + "west": { "data": 2, "direction": [-1, 0, 0] }, + "south": { "data": 3, "direction": [0, 0, 1] }, "north": { "data": 4, "direction": [0, 0, -1] }, "up": { "data": 5, "direction": [0, 1, 0] } } @@ -4943,8 +4943,8 @@ "values": { "down": { "data": 0, "direction": [0, -1, 0] }, "east": { "data": 1, "direction": [1, 0, 0] }, - "south": { "data": 2, "direction": [0, 0, 1] }, - "west": { "data": 3, "direction": [-1, 0, 0] }, + "west": { "data": 2, "direction": [-1, 0, 0] }, + "south": { "data": 3, "direction": [0, 0, 1] }, "north": { "data": 4, "direction": [0, 0, -1] }, "up": { "data": 5, "direction": [0, 1, 0] } } 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 index b3ae0763f..7da91e5f7 100644 --- 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 @@ -46,8 +46,6 @@ public class BlockTransformExtentTest { ignored.add(BlockType.BED); // Broken in existing rotation code? ignored.add(BlockType.WOODEN_DOOR); // Complicated ignored.add(BlockType.IRON_DOOR); // Complicated - ignored.add(BlockType.STONE_BUTTON); // Existing rotation code doesn't handle down/up directions - ignored.add(BlockType.WOODEN_BUTTON); // Existing rotation code doesn't handle down/up directions ignored.add(BlockType.END_PORTAL); // Not supported in existing rotation code }