From 83d5e2fd22e60379202497ca80d6adcdd4486f76 Mon Sep 17 00:00:00 2001 From: wizjany Date: Sun, 17 Mar 2013 11:11:41 -0400 Subject: [PATCH] Fix block rotations --- .../com/sk89q/worldedit/blocks/BlockData.java | 52 ++++++++++++++++--- .../worldedit/bukkit/DefaultNmsBlock.java | 4 +- 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/blocks/BlockData.java b/src/main/java/com/sk89q/worldedit/blocks/BlockData.java index f6385a140..f3fae8c14 100644 --- a/src/main/java/com/sk89q/worldedit/blocks/BlockData.java +++ b/src/main/java/com/sk89q/worldedit/blocks/BlockData.java @@ -126,10 +126,8 @@ public final class BlockData { case BlockID.CHEST: case BlockID.FURNACE: case BlockID.BURNING_FURNACE: - case BlockID.DISPENSER: case BlockID.ENDER_CHEST: case BlockID.TRAPPED_CHEST: - case BlockID.DROPPER: switch (data) { case 2: return 5; case 3: return 4; @@ -138,6 +136,17 @@ public final class BlockData { } 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) { @@ -309,10 +318,8 @@ public final class BlockData { case BlockID.CHEST: case BlockID.FURNACE: case BlockID.BURNING_FURNACE: - case BlockID.DISPENSER: case BlockID.ENDER_CHEST: case BlockID.TRAPPED_CHEST: - case BlockID.DROPPER: switch (data) { case 5: return 2; case 4: return 3; @@ -321,6 +328,16 @@ public final class BlockData { } 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) { @@ -526,10 +543,8 @@ public final class BlockData { case BlockID.CHEST: case BlockID.FURNACE: case BlockID.BURNING_FURNACE: - case BlockID.DISPENSER: case BlockID.ENDER_CHEST: case BlockID.TRAPPED_CHEST: - case BlockID.DROPPER: switch (data) { case 2: case 3: @@ -540,6 +555,22 @@ public final class BlockData { } 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; @@ -768,16 +799,21 @@ public final class BlockData { case BlockID.FURNACE: case BlockID.BURNING_FURNACE: - case BlockID.DISPENSER: case BlockID.WALL_SIGN: case BlockID.LADDER: case BlockID.CHEST: case BlockID.ENDER_CHEST: case BlockID.TRAPPED_CHEST: - case BlockID.DROPPER: if (data < 2 || data > 5) return -1; return mod((data - 2 + increment), 4) + 2; + 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: diff --git a/src/main/java/com/sk89q/worldedit/bukkit/DefaultNmsBlock.java b/src/main/java/com/sk89q/worldedit/bukkit/DefaultNmsBlock.java index 66327d9a1..6ff3cf308 100644 --- a/src/main/java/com/sk89q/worldedit/bukkit/DefaultNmsBlock.java +++ b/src/main/java/com/sk89q/worldedit/bukkit/DefaultNmsBlock.java @@ -253,12 +253,14 @@ public class DefaultNmsBlock extends NmsBlock { // TileEntity te = craftWorld.getHandle().getTileEntity(x, y, z); // craftWorld.getHandle().tileEntityList.remove(te); - boolean changed = craftWorld.getHandle().setTypeIdAndData(x, y, z, block.getId(), block.getData(), 0); + boolean changed = craftWorld.getHandle().setTypeIdAndData(x, y, z, block.getId(), 0, 0); if (block instanceof BaseBlock) { world.copyToWorld(position, (BaseBlock) block); } + changed = craftWorld.getHandle().setData(x, y, z, block.getData(), 0); + if (changed) { if (notifyAdjacent) { craftWorld.getHandle().update(x, y, z, block.getId());