From 711f3f100762a852778d91ee1f77072a18fa2de6 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Sat, 1 Dec 2012 00:21:22 -0600 Subject: [PATCH] [BREAKING] Update BlockFace directions. Fixes BUKKIT-1567, BUKKIT-3069 If you use BlockFace in any way, to compensate the directionals being incorrect, you can still have backwards compatibility if you add in the handling in your plugin: boolean legacyBlockFace = BlockFace.NORTH().getModX() == -1; (and then handle it accordingly) If you didn't special case your directions to fix what's being fixed here... Hurray! Your plugin should now work. By: feildmaster --- .../main/java/org/bukkit/block/BlockFace.java | 8 +-- .../main/java/org/bukkit/material/Bed.java | 16 ++--- .../main/java/org/bukkit/material/Button.java | 18 +++--- .../java/org/bukkit/material/CocoaPlant.java | 28 ++++----- .../main/java/org/bukkit/material/Diode.java | 16 ++--- .../bukkit/material/DirectionalContainer.java | 16 ++--- .../main/java/org/bukkit/material/Door.java | 14 ++--- .../org/bukkit/material/ExtendedRails.java | 2 +- .../main/java/org/bukkit/material/Gate.java | 22 +++---- .../main/java/org/bukkit/material/Ladder.java | 22 +++---- .../main/java/org/bukkit/material/Lever.java | 40 ++++++------- .../java/org/bukkit/material/Mushroom.java | 48 +++++++-------- .../bukkit/material/PistonBaseMaterial.java | 18 +++--- .../material/PistonExtensionMaterial.java | 18 +++--- .../java/org/bukkit/material/Pumpkin.java | 16 ++--- .../main/java/org/bukkit/material/Rails.java | 30 +++++----- .../main/java/org/bukkit/material/Sign.java | 38 ++++++------ .../main/java/org/bukkit/material/Skull.java | 16 ++--- .../main/java/org/bukkit/material/Stairs.java | 20 +++---- .../main/java/org/bukkit/material/Torch.java | 18 +++--- .../java/org/bukkit/material/TrapDoor.java | 20 +++---- .../main/java/org/bukkit/material/Tree.java | 16 ++--- .../org/bukkit/material/TripwireHook.java | 20 +++---- .../main/java/org/bukkit/material/Vine.java | 60 +++++++++---------- .../java/org/bukkit/util/BlockIterator.java | 4 +- 25 files changed, 272 insertions(+), 272 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/block/BlockFace.java b/paper-api/src/main/java/org/bukkit/block/BlockFace.java index 4344764800..58fb195d01 100644 --- a/paper-api/src/main/java/org/bukkit/block/BlockFace.java +++ b/paper-api/src/main/java/org/bukkit/block/BlockFace.java @@ -4,10 +4,10 @@ package org.bukkit.block; * Represents the face of a block */ public enum BlockFace { - NORTH(-1, 0, 0), - EAST(0, 0, -1), - SOUTH(1, 0, 0), - WEST(0, 0, 1), + NORTH(0, 0, -1), + EAST(1, 0, 0), + SOUTH(0, 0, 1), + WEST(-1, 0, 0), UP(0, 1, 0), DOWN(0, -1, 0), NORTH_EAST(NORTH, EAST), diff --git a/paper-api/src/main/java/org/bukkit/material/Bed.java b/paper-api/src/main/java/org/bukkit/material/Bed.java index 63e9206340..77f1e5f307 100644 --- a/paper-api/src/main/java/org/bukkit/material/Bed.java +++ b/paper-api/src/main/java/org/bukkit/material/Bed.java @@ -67,19 +67,19 @@ public class Bed extends MaterialData implements Directional { byte data; switch (face) { - case WEST: + case SOUTH: data = 0x0; break; - case NORTH: + case WEST: data = 0x1; break; - case EAST: + case NORTH: data = 0x2; break; - case SOUTH: + case EAST: default: data = 0x3; } @@ -101,17 +101,17 @@ public class Bed extends MaterialData implements Directional { switch (data) { case 0x0: - return BlockFace.WEST; + return BlockFace.SOUTH; case 0x1: - return BlockFace.NORTH; + return BlockFace.WEST; case 0x2: - return BlockFace.EAST; + return BlockFace.NORTH; case 0x3: default: - return BlockFace.SOUTH; + return BlockFace.EAST; } } diff --git a/paper-api/src/main/java/org/bukkit/material/Button.java b/paper-api/src/main/java/org/bukkit/material/Button.java index d80e11ecd9..1b72042aaa 100644 --- a/paper-api/src/main/java/org/bukkit/material/Button.java +++ b/paper-api/src/main/java/org/bukkit/material/Button.java @@ -57,16 +57,16 @@ public class Button extends SimpleAttachableMaterialData implements Redstone { switch (data) { case 0x1: - return BlockFace.NORTH; + return BlockFace.WEST; case 0x2: - return BlockFace.SOUTH; - - case 0x3: return BlockFace.EAST; + case 0x3: + return BlockFace.NORTH; + case 0x4: - return BlockFace.WEST; + return BlockFace.SOUTH; } return null; @@ -79,19 +79,19 @@ public class Button extends SimpleAttachableMaterialData implements Redstone { byte data = (byte) (getData() & 0x8); switch (face) { - case SOUTH: + case EAST: data |= 0x1; break; - case NORTH: + case WEST: data |= 0x2; break; - case WEST: + case SOUTH: data |= 0x3; break; - case EAST: + case NORTH: data |= 0x4; break; } diff --git a/paper-api/src/main/java/org/bukkit/material/CocoaPlant.java b/paper-api/src/main/java/org/bukkit/material/CocoaPlant.java index ad19e052ac..9a5413eab7 100644 --- a/paper-api/src/main/java/org/bukkit/material/CocoaPlant.java +++ b/paper-api/src/main/java/org/bukkit/material/CocoaPlant.java @@ -13,7 +13,7 @@ public class CocoaPlant extends MaterialData implements Directional { MEDIUM, LARGE } - + public CocoaPlant() { super(Material.COCOA); } @@ -51,7 +51,7 @@ public class CocoaPlant extends MaterialData implements Directional { return CocoaPlantSize.LARGE; } } - + /** * Set size of plant * @param sz - size of plant @@ -70,19 +70,19 @@ public class CocoaPlant extends MaterialData implements Directional { } setData((byte) dat); } - + public void setFacingDirection(BlockFace face) { int dat = getData() & 0xC; switch (face) { - case WEST: + case SOUTH: break; - case NORTH: + case WEST: dat |= 0x1; break; - case EAST: + case NORTH: dat |= 0x2; break; - case SOUTH: + case EAST: dat |= 0x3; break; default: @@ -94,17 +94,17 @@ public class CocoaPlant extends MaterialData implements Directional { public BlockFace getFacing() { switch (getData() & 0x3) { case 0: - return BlockFace.WEST; - case 1: - return BlockFace.NORTH; - case 2: - return BlockFace.EAST; - case 3: return BlockFace.SOUTH; + case 1: + return BlockFace.WEST; + case 2: + return BlockFace.NORTH; + case 3: + return BlockFace.EAST; } return null; } - + @Override public CocoaPlant clone() { return (CocoaPlant) super.clone(); diff --git a/paper-api/src/main/java/org/bukkit/material/Diode.java b/paper-api/src/main/java/org/bukkit/material/Diode.java index 6c1930c416..54853f1829 100644 --- a/paper-api/src/main/java/org/bukkit/material/Diode.java +++ b/paper-api/src/main/java/org/bukkit/material/Diode.java @@ -56,19 +56,19 @@ public class Diode extends MaterialData implements Directional { byte data; switch (face) { - case SOUTH: + case EAST: data = 0x1; break; - case WEST: + case SOUTH: data = 0x2; break; - case NORTH: + case WEST: data = 0x3; break; - case EAST: + case NORTH: default: data = 0x0; } @@ -83,16 +83,16 @@ public class Diode extends MaterialData implements Directional { switch (data) { case 0x0: default: - return BlockFace.EAST; + return BlockFace.NORTH; case 0x1: - return BlockFace.SOUTH; + return BlockFace.EAST; case 0x2: - return BlockFace.WEST; + return BlockFace.SOUTH; case 0x3: - return BlockFace.NORTH; + return BlockFace.WEST; } } diff --git a/paper-api/src/main/java/org/bukkit/material/DirectionalContainer.java b/paper-api/src/main/java/org/bukkit/material/DirectionalContainer.java index de9bd36363..790b6bd3b2 100644 --- a/paper-api/src/main/java/org/bukkit/material/DirectionalContainer.java +++ b/paper-api/src/main/java/org/bukkit/material/DirectionalContainer.java @@ -27,19 +27,19 @@ public class DirectionalContainer extends MaterialData implements Directional { byte data; switch (face) { - case EAST: + case NORTH: data = 0x2; break; - case WEST: + case SOUTH: data = 0x3; break; - case NORTH: + case WEST: data = 0x4; break; - case SOUTH: + case EAST: default: data = 0x5; } @@ -52,17 +52,17 @@ public class DirectionalContainer extends MaterialData implements Directional { switch (data) { case 0x2: - return BlockFace.EAST; + return BlockFace.NORTH; case 0x3: - return BlockFace.WEST; + return BlockFace.SOUTH; case 0x4: - return BlockFace.NORTH; + return BlockFace.WEST; case 0x5: default: - return BlockFace.SOUTH; + return BlockFace.EAST; } } diff --git a/paper-api/src/main/java/org/bukkit/material/Door.java b/paper-api/src/main/java/org/bukkit/material/Door.java index e992c28e21..732f1bd394 100644 --- a/paper-api/src/main/java/org/bukkit/material/Door.java +++ b/paper-api/src/main/java/org/bukkit/material/Door.java @@ -81,15 +81,15 @@ public class Door extends MaterialData implements Directional, Openable { public void setFacingDirection(BlockFace face) { byte data = (byte) (getData() & 0x12); switch (face) { - case EAST: + case NORTH: data |= 0x1; break; - case SOUTH: + case EAST: data |= 0x2; break; - case WEST: + case SOUTH: data |= 0x3; break; } @@ -105,16 +105,16 @@ public class Door extends MaterialData implements Directional, Openable { byte data = (byte) (getData() & 0x3); switch (data) { case 0: - return BlockFace.NORTH; + return BlockFace.WEST; case 1: - return BlockFace.EAST; + return BlockFace.NORTH; case 2: - return BlockFace.SOUTH; + return BlockFace.EAST; case 3: - return BlockFace.WEST; + return BlockFace.SOUTH; } return null; // shouldn't happen } diff --git a/paper-api/src/main/java/org/bukkit/material/ExtendedRails.java b/paper-api/src/main/java/org/bukkit/material/ExtendedRails.java index 5d3a9d929f..e89e82fdbb 100644 --- a/paper-api/src/main/java/org/bukkit/material/ExtendedRails.java +++ b/paper-api/src/main/java/org/bukkit/material/ExtendedRails.java @@ -37,7 +37,7 @@ public class ExtendedRails extends Rails { public void setDirection(BlockFace face, boolean isOnSlope) { boolean extraBitSet = (getData() & 0x8) == 0x8; - if (face != BlockFace.NORTH && face != BlockFace.SOUTH && face != BlockFace.EAST && face != BlockFace.WEST) { + if (face != BlockFace.WEST && face != BlockFace.EAST && face != BlockFace.NORTH && face != BlockFace.SOUTH) { throw new IllegalArgumentException("Detector rails and powered rails cannot be set on a curve!"); } diff --git a/paper-api/src/main/java/org/bukkit/material/Gate.java b/paper-api/src/main/java/org/bukkit/material/Gate.java index e80abe7aa4..8adc1cfbc6 100644 --- a/paper-api/src/main/java/org/bukkit/material/Gate.java +++ b/paper-api/src/main/java/org/bukkit/material/Gate.java @@ -31,16 +31,16 @@ public class Gate extends MaterialData implements Directional, Openable { switch (face) { default: - case SOUTH: + case EAST: data |= GATE_SOUTH; break; - case WEST: + case SOUTH: data |= GATE_WEST; break; - case NORTH: + case WEST: data |= GATE_NORTH; break; - case EAST: + case NORTH: data |= GATE_EAST; break; } @@ -51,16 +51,16 @@ public class Gate extends MaterialData implements Directional, Openable { public BlockFace getFacing() { switch (getData() & DIR_BIT) { case GATE_SOUTH: - return BlockFace.SOUTH; - case GATE_WEST: - return BlockFace.WEST; - case GATE_NORTH: - return BlockFace.NORTH; - case GATE_EAST: return BlockFace.EAST; + case GATE_WEST: + return BlockFace.SOUTH; + case GATE_NORTH: + return BlockFace.WEST; + case GATE_EAST: + return BlockFace.NORTH; } - return BlockFace.SOUTH; + return BlockFace.EAST; } public boolean isOpen() { diff --git a/paper-api/src/main/java/org/bukkit/material/Ladder.java b/paper-api/src/main/java/org/bukkit/material/Ladder.java index aea01f8ef5..31991a672f 100644 --- a/paper-api/src/main/java/org/bukkit/material/Ladder.java +++ b/paper-api/src/main/java/org/bukkit/material/Ladder.java @@ -37,16 +37,16 @@ public class Ladder extends SimpleAttachableMaterialData { switch (data) { case 0x2: - return BlockFace.WEST; - - case 0x3: - return BlockFace.EAST; - - case 0x4: return BlockFace.SOUTH; - case 0x5: + case 0x3: return BlockFace.NORTH; + + case 0x4: + return BlockFace.EAST; + + case 0x5: + return BlockFace.WEST; } return null; @@ -59,19 +59,19 @@ public class Ladder extends SimpleAttachableMaterialData { byte data = (byte) 0x0; switch (face) { - case WEST: + case SOUTH: data = 0x2; break; - case EAST: + case NORTH: data = 0x3; break; - case SOUTH: + case EAST: data = 0x4; break; - case NORTH: + case WEST: data = 0x5; break; } diff --git a/paper-api/src/main/java/org/bukkit/material/Lever.java b/paper-api/src/main/java/org/bukkit/material/Lever.java index 395b62ce1f..bc4dd3a1e6 100644 --- a/paper-api/src/main/java/org/bukkit/material/Lever.java +++ b/paper-api/src/main/java/org/bukkit/material/Lever.java @@ -56,25 +56,25 @@ public class Lever extends SimpleAttachableMaterialData implements Redstone { switch (data) { case 0x1: - return BlockFace.NORTH; + return BlockFace.WEST; case 0x2: - return BlockFace.SOUTH; - - case 0x3: return BlockFace.EAST; + case 0x3: + return BlockFace.NORTH; + case 0x4: - return BlockFace.WEST; + return BlockFace.SOUTH; case 0x5: case 0x6: return BlockFace.DOWN; - + case 0x0: case 0x7: return BlockFace.UP; - + } return null; @@ -86,46 +86,46 @@ public class Lever extends SimpleAttachableMaterialData implements Redstone { public void setFacingDirection(BlockFace face) { byte data = (byte) (getData() & 0x8); BlockFace attach = getAttachedFace(); - + if (attach == BlockFace.DOWN) { switch (face) { - case WEST: - case EAST: + case SOUTH: + case NORTH: data |= 0x5; break; - case SOUTH: - case NORTH: + case EAST: + case WEST: data |= 0x6; break; } } else if (attach == BlockFace.UP) { switch (face) { - case WEST: - case EAST: + case SOUTH: + case NORTH: data |= 0x7; break; - case SOUTH: - case NORTH: + case EAST: + case WEST: data |= 0x0; break; } } else { switch (face) { - case SOUTH: + case EAST: data |= 0x1; break; - case NORTH: + case WEST: data |= 0x2; break; - case WEST: + case SOUTH: data |= 0x3; break; - case EAST: + case NORTH: data |= 0x4; break; } diff --git a/paper-api/src/main/java/org/bukkit/material/Mushroom.java b/paper-api/src/main/java/org/bukkit/material/Mushroom.java index 237a17a515..f651ed84f2 100644 --- a/paper-api/src/main/java/org/bukkit/material/Mushroom.java +++ b/paper-api/src/main/java/org/bukkit/material/Mushroom.java @@ -63,13 +63,13 @@ public class Mushroom extends MaterialData { } switch (face) { - case NORTH: - return data < NORTH_LIMIT; - case SOUTH: - return data > SOUTH_LIMIT; - case EAST: - return data % EAST_WEST_LIMIT == EAST_REMAINDER; case WEST: + return data < NORTH_LIMIT; + case EAST: + return data > SOUTH_LIMIT; + case NORTH: + return data % EAST_WEST_LIMIT == EAST_REMAINDER; + case SOUTH: return data % EAST_WEST_LIMIT == WEST_REMAINDER; case UP: return true; @@ -96,23 +96,23 @@ public class Mushroom extends MaterialData { } switch (face) { - case NORTH: + case WEST: if (painted) { data -= NORTH_SOUTH_MOD; } else { data += NORTH_SOUTH_MOD; } - break; - case SOUTH: - if (painted) { - data += NORTH_SOUTH_MOD; - } else { - data -= NORTH_SOUTH_MOD; - } - break; case EAST: + if (painted) { + data += NORTH_SOUTH_MOD; + } else { + data -= NORTH_SOUTH_MOD; + } + + break; + case NORTH: if (painted) { data += EAST_WEST_MOD; } else { @@ -120,7 +120,7 @@ public class Mushroom extends MaterialData { } break; - case WEST: + case SOUTH: if (painted) { data -= EAST_WEST_MOD; } else { @@ -147,22 +147,22 @@ public class Mushroom extends MaterialData { public Set getPaintedFaces() { EnumSet faces = EnumSet.noneOf(BlockFace.class); - if (isFacePainted(BlockFace.NORTH)) { - faces.add(BlockFace.NORTH); - } - - if (isFacePainted(BlockFace.EAST)) { - faces.add(BlockFace.EAST); - } - if (isFacePainted(BlockFace.WEST)) { faces.add(BlockFace.WEST); } + if (isFacePainted(BlockFace.NORTH)) { + faces.add(BlockFace.NORTH); + } + if (isFacePainted(BlockFace.SOUTH)) { faces.add(BlockFace.SOUTH); } + if (isFacePainted(BlockFace.EAST)) { + faces.add(BlockFace.EAST); + } + if (isFacePainted(BlockFace.UP)) { faces.add(BlockFace.UP); } diff --git a/paper-api/src/main/java/org/bukkit/material/PistonBaseMaterial.java b/paper-api/src/main/java/org/bukkit/material/PistonBaseMaterial.java index 8231553098..f5e2fc94ec 100644 --- a/paper-api/src/main/java/org/bukkit/material/PistonBaseMaterial.java +++ b/paper-api/src/main/java/org/bukkit/material/PistonBaseMaterial.java @@ -30,16 +30,16 @@ public class PistonBaseMaterial extends MaterialData implements Directional, Red case UP: data |= 1; break; - case EAST: + case NORTH: data |= 2; break; - case WEST: + case SOUTH: data |= 3; break; - case NORTH: + case WEST: data |= 4; break; - case SOUTH: + case EAST: data |= 5; break; } @@ -55,13 +55,13 @@ public class PistonBaseMaterial extends MaterialData implements Directional, Red case 1: return BlockFace.UP; case 2: - return BlockFace.EAST; - case 3: - return BlockFace.WEST; - case 4: return BlockFace.NORTH; - case 5: + case 3: return BlockFace.SOUTH; + case 4: + return BlockFace.WEST; + case 5: + return BlockFace.EAST; default: return BlockFace.SELF; } diff --git a/paper-api/src/main/java/org/bukkit/material/PistonExtensionMaterial.java b/paper-api/src/main/java/org/bukkit/material/PistonExtensionMaterial.java index f513f23191..37323a616b 100644 --- a/paper-api/src/main/java/org/bukkit/material/PistonExtensionMaterial.java +++ b/paper-api/src/main/java/org/bukkit/material/PistonExtensionMaterial.java @@ -30,16 +30,16 @@ public class PistonExtensionMaterial extends MaterialData implements Attachable case UP: data |= 1; break; - case EAST: + case NORTH: data |= 2; break; - case WEST: + case SOUTH: data |= 3; break; - case NORTH: + case WEST: data |= 4; break; - case SOUTH: + case EAST: data |= 5; break; } @@ -55,13 +55,13 @@ public class PistonExtensionMaterial extends MaterialData implements Attachable case 1: return BlockFace.UP; case 2: - return BlockFace.EAST; - case 3: - return BlockFace.WEST; - case 4: return BlockFace.NORTH; - case 5: + case 3: return BlockFace.SOUTH; + case 4: + return BlockFace.WEST; + case 5: + return BlockFace.EAST; default: return BlockFace.SELF; } diff --git a/paper-api/src/main/java/org/bukkit/material/Pumpkin.java b/paper-api/src/main/java/org/bukkit/material/Pumpkin.java index 4acc6bb029..47837dd1c8 100644 --- a/paper-api/src/main/java/org/bukkit/material/Pumpkin.java +++ b/paper-api/src/main/java/org/bukkit/material/Pumpkin.java @@ -46,19 +46,19 @@ public class Pumpkin extends MaterialData implements Directional { byte data; switch (face) { - case EAST: + case NORTH: data = 0x0; break; - case SOUTH: + case EAST: data = 0x1; break; - case WEST: + case SOUTH: data = 0x2; break; - case NORTH: + case WEST: default: data = 0x3; } @@ -71,17 +71,17 @@ public class Pumpkin extends MaterialData implements Directional { switch (data) { case 0x0: - return BlockFace.EAST; + return BlockFace.NORTH; case 0x1: - return BlockFace.SOUTH; + return BlockFace.EAST; case 0x2: - return BlockFace.WEST; + return BlockFace.SOUTH; case 0x3: default: - return BlockFace.SOUTH; + return BlockFace.EAST; } } diff --git a/paper-api/src/main/java/org/bukkit/material/Rails.java b/paper-api/src/main/java/org/bukkit/material/Rails.java index 406675dc22..84d2f1f1d3 100644 --- a/paper-api/src/main/java/org/bukkit/material/Rails.java +++ b/paper-api/src/main/java/org/bukkit/material/Rails.java @@ -59,23 +59,23 @@ public class Rails extends MaterialData { switch (d) { case 0x0: default: - return BlockFace.WEST; + return BlockFace.SOUTH; case 0x1: - return BlockFace.SOUTH; - - case 0x2: - return BlockFace.SOUTH; - - case 0x3: - return BlockFace.NORTH; - - case 0x4: return BlockFace.EAST; - case 0x5: + case 0x2: + return BlockFace.EAST; + + case 0x3: return BlockFace.WEST; + case 0x4: + return BlockFace.NORTH; + + case 0x5: + return BlockFace.SOUTH; + case 0x6: return BlockFace.NORTH_EAST; @@ -116,19 +116,19 @@ public class Rails extends MaterialData { */ public void setDirection(BlockFace face, boolean isOnSlope) { switch (face) { - case SOUTH: + case EAST: setData((byte) (isOnSlope ? 0x2 : 0x1)); break; - case NORTH: + case WEST: setData((byte) (isOnSlope ? 0x3 : 0x1)); break; - case EAST: + case NORTH: setData((byte) (isOnSlope ? 0x4 : 0x0)); break; - case WEST: + case SOUTH: setData((byte) (isOnSlope ? 0x5 : 0x0)); break; diff --git a/paper-api/src/main/java/org/bukkit/material/Sign.java b/paper-api/src/main/java/org/bukkit/material/Sign.java index ceb15d87e4..a83b7cb0ea 100644 --- a/paper-api/src/main/java/org/bukkit/material/Sign.java +++ b/paper-api/src/main/java/org/bukkit/material/Sign.java @@ -48,16 +48,16 @@ public class Sign extends MaterialData implements Attachable { switch (data) { case 0x2: - return BlockFace.WEST; - - case 0x3: - return BlockFace.EAST; - - case 0x4: return BlockFace.SOUTH; - case 0x5: + case 0x3: return BlockFace.NORTH; + + case 0x4: + return BlockFace.EAST; + + case 0x5: + return BlockFace.WEST; } return null; @@ -77,7 +77,7 @@ public class Sign extends MaterialData implements Attachable { if (!isWallSign()) { switch (data) { case 0x0: - return BlockFace.WEST; + return BlockFace.SOUTH; case 0x1: return BlockFace.WEST_NORTH_WEST; @@ -89,7 +89,7 @@ public class Sign extends MaterialData implements Attachable { return BlockFace.NORTH_NORTH_WEST; case 0x4: - return BlockFace.NORTH; + return BlockFace.WEST; case 0x5: return BlockFace.NORTH_NORTH_EAST; @@ -101,7 +101,7 @@ public class Sign extends MaterialData implements Attachable { return BlockFace.EAST_NORTH_EAST; case 0x8: - return BlockFace.EAST; + return BlockFace.NORTH; case 0x9: return BlockFace.EAST_SOUTH_EAST; @@ -113,7 +113,7 @@ public class Sign extends MaterialData implements Attachable { return BlockFace.SOUTH_SOUTH_EAST; case 0xC: - return BlockFace.SOUTH; + return BlockFace.EAST; case 0xD: return BlockFace.SOUTH_SOUTH_WEST; @@ -136,25 +136,25 @@ public class Sign extends MaterialData implements Attachable { if (isWallSign()) { switch (face) { - case EAST: + case NORTH: data = 0x2; break; - case WEST: + case SOUTH: data = 0x3; break; - case NORTH: + case WEST: data = 0x4; break; - case SOUTH: + case EAST: default: data = 0x5; } } else { switch (face) { - case WEST: + case SOUTH: data = 0x0; break; @@ -170,7 +170,7 @@ public class Sign extends MaterialData implements Attachable { data = 0x3; break; - case NORTH: + case WEST: data = 0x4; break; @@ -186,7 +186,7 @@ public class Sign extends MaterialData implements Attachable { data = 0x7; break; - case EAST: + case NORTH: data = 0x8; break; @@ -202,7 +202,7 @@ public class Sign extends MaterialData implements Attachable { data = 0xB; break; - case SOUTH: + case EAST: data = 0xC; break; diff --git a/paper-api/src/main/java/org/bukkit/material/Skull.java b/paper-api/src/main/java/org/bukkit/material/Skull.java index 77130fb9ff..bd2bbf3147 100644 --- a/paper-api/src/main/java/org/bukkit/material/Skull.java +++ b/paper-api/src/main/java/org/bukkit/material/Skull.java @@ -41,19 +41,19 @@ public class Skull extends MaterialData implements Directional { int data; switch (face) { - case EAST: + case NORTH: data = 0x1; break; - case SOUTH: + case EAST: data = 0x2; break; - case WEST: + case SOUTH: data = 0x3; break; - case NORTH: + case WEST: default: data = 0x4; } @@ -66,17 +66,17 @@ public class Skull extends MaterialData implements Directional { switch (data) { case 0x1: - return BlockFace.EAST; + return BlockFace.NORTH; case 0x2: - return BlockFace.SOUTH; + return BlockFace.EAST; case 0x3: - return BlockFace.WEST; + return BlockFace.SOUTH; case 0x4: default: - return BlockFace.SOUTH; + return BlockFace.EAST; } } diff --git a/paper-api/src/main/java/org/bukkit/material/Stairs.java b/paper-api/src/main/java/org/bukkit/material/Stairs.java index 67ff745ac7..3eb1418ca2 100644 --- a/paper-api/src/main/java/org/bukkit/material/Stairs.java +++ b/paper-api/src/main/java/org/bukkit/material/Stairs.java @@ -33,16 +33,16 @@ public class Stairs extends MaterialData implements Directional { switch (data & 0x3) { case 0x0: default: - return BlockFace.SOUTH; + return BlockFace.EAST; case 0x1: - return BlockFace.NORTH; - - case 0x2: return BlockFace.WEST; + case 0x2: + return BlockFace.SOUTH; + case 0x3: - return BlockFace.EAST; + return BlockFace.NORTH; } } @@ -60,20 +60,20 @@ public class Stairs extends MaterialData implements Directional { byte data; switch (face) { - case NORTH: + case WEST: default: data = 0x0; break; - case SOUTH: + case EAST: data = 0x1; break; - case EAST: + case NORTH: data = 0x2; break; - case WEST: + case SOUTH: data = 0x3; break; } @@ -95,7 +95,7 @@ public class Stairs extends MaterialData implements Directional { public boolean isInverted() { return ((getData() & 0x4) != 0); } - + /** * Set step inverted state * @param inv - true if step is inverted (top half), false if step is normal (bottom half) diff --git a/paper-api/src/main/java/org/bukkit/material/Torch.java b/paper-api/src/main/java/org/bukkit/material/Torch.java index 13a9777ecb..90c1874769 100644 --- a/paper-api/src/main/java/org/bukkit/material/Torch.java +++ b/paper-api/src/main/java/org/bukkit/material/Torch.java @@ -37,16 +37,16 @@ public class Torch extends SimpleAttachableMaterialData { switch (data) { case 0x1: - return BlockFace.NORTH; + return BlockFace.WEST; case 0x2: - return BlockFace.SOUTH; - - case 0x3: return BlockFace.EAST; + case 0x3: + return BlockFace.NORTH; + case 0x4: - return BlockFace.WEST; + return BlockFace.SOUTH; case 0x5: return BlockFace.DOWN; @@ -59,19 +59,19 @@ public class Torch extends SimpleAttachableMaterialData { byte data; switch (face) { - case SOUTH: + case EAST: data = 0x1; break; - case NORTH: + case WEST: data = 0x2; break; - case WEST: + case SOUTH: data = 0x3; break; - case EAST: + case NORTH: data = 0x4; break; diff --git a/paper-api/src/main/java/org/bukkit/material/TrapDoor.java b/paper-api/src/main/java/org/bukkit/material/TrapDoor.java index c280c78faa..5041a5c126 100644 --- a/paper-api/src/main/java/org/bukkit/material/TrapDoor.java +++ b/paper-api/src/main/java/org/bukkit/material/TrapDoor.java @@ -48,16 +48,16 @@ public class TrapDoor extends SimpleAttachableMaterialData implements Openable { switch (data) { case 0x0: - return BlockFace.WEST; - - case 0x1: - return BlockFace.EAST; - - case 0x2: return BlockFace.SOUTH; - case 0x3: + case 0x1: return BlockFace.NORTH; + + case 0x2: + return BlockFace.EAST; + + case 0x3: + return BlockFace.WEST; } return null; @@ -68,13 +68,13 @@ public class TrapDoor extends SimpleAttachableMaterialData implements Openable { byte data = (byte) (getData() & 0x4); switch (face) { - case WEST: + case SOUTH: data |= 0x1; break; - case NORTH: + case WEST: data |= 0x2; break; - case SOUTH: + case EAST: data |= 0x3; break; } diff --git a/paper-api/src/main/java/org/bukkit/material/Tree.java b/paper-api/src/main/java/org/bukkit/material/Tree.java index 31548354b8..86ac0fa281 100644 --- a/paper-api/src/main/java/org/bukkit/material/Tree.java +++ b/paper-api/src/main/java/org/bukkit/material/Tree.java @@ -59,8 +59,8 @@ public class Tree extends MaterialData { /** * Get direction of the log - * - * @return BlockFace.TOP for upright (default), BlockFace.EAST (east-west), BlockFace.NORTH (north-sout), BlockFace.SELF (directionless) + * + * @return BlockFace.TOP for upright (default), BlockFace.NORTH (east-west), BlockFace.WEST (north-sout), BlockFace.SELF (directionless) */ public BlockFace getDirection() { switch ((getData() >> 2) & 0x3) { @@ -68,9 +68,9 @@ public class Tree extends MaterialData { default: return BlockFace.UP; case 1: // North-south - return BlockFace.NORTH; + return BlockFace.WEST; case 2: // East-west - return BlockFace.EAST; + return BlockFace.NORTH; case 3: // Directionless (bark on all sides) return BlockFace.SELF; } @@ -87,12 +87,12 @@ public class Tree extends MaterialData { default: dat = 0; break; - case NORTH: - case SOUTH: + case WEST: + case EAST: dat = 1; break; - case EAST: - case WEST: + case NORTH: + case SOUTH: dat = 2; break; case SELF: diff --git a/paper-api/src/main/java/org/bukkit/material/TripwireHook.java b/paper-api/src/main/java/org/bukkit/material/TripwireHook.java index 9f8e13d318..bf8066bf9b 100644 --- a/paper-api/src/main/java/org/bukkit/material/TripwireHook.java +++ b/paper-api/src/main/java/org/bukkit/material/TripwireHook.java @@ -68,16 +68,16 @@ public class TripwireHook extends SimpleAttachableMaterialData implements Redsto public void setFacingDirection(BlockFace face) { int dat = getData() & 0xC; switch (face) { - case NORTH: + case WEST: dat |= 0x1; break; - case EAST: + case NORTH: dat |= 0x2; break; - case SOUTH: + case EAST: dat |= 0x3; break; - case WEST: + case SOUTH: default: break; } @@ -87,13 +87,13 @@ public class TripwireHook extends SimpleAttachableMaterialData implements Redsto public BlockFace getAttachedFace() { switch (getData() & 0x3) { case 0: - return BlockFace.EAST; - case 1: - return BlockFace.SOUTH; - case 2: - return BlockFace.WEST; - case 3: return BlockFace.NORTH; + case 1: + return BlockFace.EAST; + case 2: + return BlockFace.SOUTH; + case 3: + return BlockFace.WEST; } return null; } diff --git a/paper-api/src/main/java/org/bukkit/material/Vine.java b/paper-api/src/main/java/org/bukkit/material/Vine.java index beb9248069..722cbc98b5 100644 --- a/paper-api/src/main/java/org/bukkit/material/Vine.java +++ b/paper-api/src/main/java/org/bukkit/material/Vine.java @@ -14,7 +14,7 @@ public class Vine extends MaterialData { private static final int VINE_EAST = 0x8; private static final int VINE_WEST = 0x2; private static final int VINE_SOUTH = 0x1; - EnumSet possibleFaces = EnumSet.of(BlockFace.NORTH, BlockFace.EAST, BlockFace.WEST, BlockFace.SOUTH); + EnumSet possibleFaces = EnumSet.of(BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST); public Vine() { super(Material.VINE); @@ -38,19 +38,19 @@ public class Vine extends MaterialData { byte data = 0; - if (faces.contains(BlockFace.NORTH)) { + if (faces.contains(BlockFace.WEST)) { data |= VINE_NORTH; } - if (faces.contains(BlockFace.EAST)) { + if (faces.contains(BlockFace.NORTH)) { data |= VINE_EAST; } - if (faces.contains(BlockFace.WEST)) { + if (faces.contains(BlockFace.SOUTH)) { data |= VINE_WEST; } - if (faces.contains(BlockFace.SOUTH)) { + if (faces.contains(BlockFace.EAST)) { data |= VINE_SOUTH; } @@ -66,22 +66,22 @@ public class Vine extends MaterialData { */ public boolean isOnFace(BlockFace face) { switch (face) { - case NORTH: - return (getData() & VINE_NORTH) > 0; - case EAST: - return (getData() & VINE_EAST) > 0; case WEST: - return (getData() & VINE_WEST) > 0; + return (getData() & VINE_NORTH) > 0; + case NORTH: + return (getData() & VINE_EAST) > 0; case SOUTH: + return (getData() & VINE_WEST) > 0; + case EAST: return (getData() & VINE_SOUTH) > 0; case NORTH_EAST: - return isOnFace(BlockFace.NORTH) && isOnFace(BlockFace.EAST); + return isOnFace(BlockFace.WEST) && isOnFace(BlockFace.NORTH); case NORTH_WEST: - return isOnFace(BlockFace.NORTH) && isOnFace(BlockFace.WEST); + return isOnFace(BlockFace.WEST) && isOnFace(BlockFace.SOUTH); case SOUTH_EAST: - return isOnFace(BlockFace.SOUTH) && isOnFace(BlockFace.EAST); + return isOnFace(BlockFace.EAST) && isOnFace(BlockFace.NORTH); case SOUTH_WEST: - return isOnFace(BlockFace.SOUTH) && isOnFace(BlockFace.WEST); + return isOnFace(BlockFace.EAST) && isOnFace(BlockFace.SOUTH); case UP: // It's impossible to be accurate with this since it's contextual return true; default: @@ -96,33 +96,33 @@ public class Vine extends MaterialData { */ public void putOnFace(BlockFace face) { switch(face) { - case NORTH: + case WEST: setData((byte) (getData() | VINE_NORTH)); break; - case EAST: + case NORTH: setData((byte) (getData() | VINE_EAST)); break; - case WEST: + case SOUTH: setData((byte) (getData() | VINE_WEST)); break; - case SOUTH: + case EAST: setData((byte) (getData() | VINE_SOUTH)); break; case NORTH_EAST: + putOnFace(BlockFace.WEST); putOnFace(BlockFace.NORTH); - putOnFace(BlockFace.EAST); break; case NORTH_WEST: - putOnFace(BlockFace.NORTH); putOnFace(BlockFace.WEST); + putOnFace(BlockFace.SOUTH); break; case SOUTH_EAST: - putOnFace(BlockFace.SOUTH); putOnFace(BlockFace.EAST); + putOnFace(BlockFace.NORTH); break; case SOUTH_WEST: + putOnFace(BlockFace.EAST); putOnFace(BlockFace.SOUTH); - putOnFace(BlockFace.WEST); break; case UP: break; @@ -138,33 +138,33 @@ public class Vine extends MaterialData { */ public void removeFromFace(BlockFace face) { switch(face) { - case NORTH: + case WEST: setData((byte) (getData() &~ VINE_NORTH)); break; - case EAST: + case NORTH: setData((byte) (getData() &~ VINE_EAST)); break; - case WEST: + case SOUTH: setData((byte) (getData() &~ VINE_WEST)); break; - case SOUTH: + case EAST: setData((byte) (getData() &~ VINE_SOUTH)); break; case NORTH_EAST: + removeFromFace(BlockFace.WEST); removeFromFace(BlockFace.NORTH); - removeFromFace(BlockFace.EAST); break; case NORTH_WEST: - removeFromFace(BlockFace.NORTH); removeFromFace(BlockFace.WEST); + removeFromFace(BlockFace.SOUTH); break; case SOUTH_EAST: - removeFromFace(BlockFace.SOUTH); removeFromFace(BlockFace.EAST); + removeFromFace(BlockFace.NORTH); break; case SOUTH_WEST: + removeFromFace(BlockFace.EAST); removeFromFace(BlockFace.SOUTH); - removeFromFace(BlockFace.WEST); break; case UP: break; diff --git a/paper-api/src/main/java/org/bukkit/util/BlockIterator.java b/paper-api/src/main/java/org/bukkit/util/BlockIterator.java index 672cc0f1da..d6ff014279 100644 --- a/paper-api/src/main/java/org/bukkit/util/BlockIterator.java +++ b/paper-api/src/main/java/org/bukkit/util/BlockIterator.java @@ -179,7 +179,7 @@ public class BlockIterator implements Iterator { } private BlockFace getXFace(Vector direction) { - return ((direction.getX() > 0) ? BlockFace.SOUTH : BlockFace.NORTH); + return ((direction.getX() > 0) ? BlockFace.EAST : BlockFace.WEST); } private BlockFace getYFace(Vector direction) { @@ -187,7 +187,7 @@ public class BlockIterator implements Iterator { } private BlockFace getZFace(Vector direction) { - return ((direction.getZ() > 0) ? BlockFace.WEST : BlockFace.EAST); + return ((direction.getZ() > 0) ? BlockFace.SOUTH : BlockFace.NORTH); } private double getXLength(Vector direction) {