13
0
geforkt von Mirrors/Paper

[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 <admin@feildmaster.com>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2012-12-01 00:21:22 -06:00
Ursprung 9e0336d03c
Commit 711f3f1007
25 geänderte Dateien mit 272 neuen und 272 gelöschten Zeilen

Datei anzeigen

@ -4,10 +4,10 @@ package org.bukkit.block;
* Represents the face of a block * Represents the face of a block
*/ */
public enum BlockFace { public enum BlockFace {
NORTH(-1, 0, 0), NORTH(0, 0, -1),
EAST(0, 0, -1), EAST(1, 0, 0),
SOUTH(1, 0, 0), SOUTH(0, 0, 1),
WEST(0, 0, 1), WEST(-1, 0, 0),
UP(0, 1, 0), UP(0, 1, 0),
DOWN(0, -1, 0), DOWN(0, -1, 0),
NORTH_EAST(NORTH, EAST), NORTH_EAST(NORTH, EAST),

Datei anzeigen

@ -67,19 +67,19 @@ public class Bed extends MaterialData implements Directional {
byte data; byte data;
switch (face) { switch (face) {
case WEST: case SOUTH:
data = 0x0; data = 0x0;
break; break;
case NORTH: case WEST:
data = 0x1; data = 0x1;
break; break;
case EAST: case NORTH:
data = 0x2; data = 0x2;
break; break;
case SOUTH: case EAST:
default: default:
data = 0x3; data = 0x3;
} }
@ -101,17 +101,17 @@ public class Bed extends MaterialData implements Directional {
switch (data) { switch (data) {
case 0x0: case 0x0:
return BlockFace.WEST; return BlockFace.SOUTH;
case 0x1: case 0x1:
return BlockFace.NORTH; return BlockFace.WEST;
case 0x2: case 0x2:
return BlockFace.EAST; return BlockFace.NORTH;
case 0x3: case 0x3:
default: default:
return BlockFace.SOUTH; return BlockFace.EAST;
} }
} }

Datei anzeigen

@ -57,16 +57,16 @@ public class Button extends SimpleAttachableMaterialData implements Redstone {
switch (data) { switch (data) {
case 0x1: case 0x1:
return BlockFace.NORTH; return BlockFace.WEST;
case 0x2: case 0x2:
return BlockFace.SOUTH;
case 0x3:
return BlockFace.EAST; return BlockFace.EAST;
case 0x3:
return BlockFace.NORTH;
case 0x4: case 0x4:
return BlockFace.WEST; return BlockFace.SOUTH;
} }
return null; return null;
@ -79,19 +79,19 @@ public class Button extends SimpleAttachableMaterialData implements Redstone {
byte data = (byte) (getData() & 0x8); byte data = (byte) (getData() & 0x8);
switch (face) { switch (face) {
case SOUTH: case EAST:
data |= 0x1; data |= 0x1;
break; break;
case NORTH: case WEST:
data |= 0x2; data |= 0x2;
break; break;
case WEST: case SOUTH:
data |= 0x3; data |= 0x3;
break; break;
case EAST: case NORTH:
data |= 0x4; data |= 0x4;
break; break;
} }

Datei anzeigen

@ -74,15 +74,15 @@ public class CocoaPlant extends MaterialData implements Directional {
public void setFacingDirection(BlockFace face) { public void setFacingDirection(BlockFace face) {
int dat = getData() & 0xC; int dat = getData() & 0xC;
switch (face) { switch (face) {
case WEST: case SOUTH:
break; break;
case NORTH: case WEST:
dat |= 0x1; dat |= 0x1;
break; break;
case EAST: case NORTH:
dat |= 0x2; dat |= 0x2;
break; break;
case SOUTH: case EAST:
dat |= 0x3; dat |= 0x3;
break; break;
default: default:
@ -94,13 +94,13 @@ public class CocoaPlant extends MaterialData implements Directional {
public BlockFace getFacing() { public BlockFace getFacing() {
switch (getData() & 0x3) { switch (getData() & 0x3) {
case 0: case 0:
return BlockFace.WEST;
case 1:
return BlockFace.NORTH;
case 2:
return BlockFace.EAST;
case 3:
return BlockFace.SOUTH; return BlockFace.SOUTH;
case 1:
return BlockFace.WEST;
case 2:
return BlockFace.NORTH;
case 3:
return BlockFace.EAST;
} }
return null; return null;
} }

Datei anzeigen

@ -56,19 +56,19 @@ public class Diode extends MaterialData implements Directional {
byte data; byte data;
switch (face) { switch (face) {
case SOUTH: case EAST:
data = 0x1; data = 0x1;
break; break;
case WEST: case SOUTH:
data = 0x2; data = 0x2;
break; break;
case NORTH: case WEST:
data = 0x3; data = 0x3;
break; break;
case EAST: case NORTH:
default: default:
data = 0x0; data = 0x0;
} }
@ -83,16 +83,16 @@ public class Diode extends MaterialData implements Directional {
switch (data) { switch (data) {
case 0x0: case 0x0:
default: default:
return BlockFace.EAST; return BlockFace.NORTH;
case 0x1: case 0x1:
return BlockFace.SOUTH; return BlockFace.EAST;
case 0x2: case 0x2:
return BlockFace.WEST; return BlockFace.SOUTH;
case 0x3: case 0x3:
return BlockFace.NORTH; return BlockFace.WEST;
} }
} }

Datei anzeigen

@ -27,19 +27,19 @@ public class DirectionalContainer extends MaterialData implements Directional {
byte data; byte data;
switch (face) { switch (face) {
case EAST: case NORTH:
data = 0x2; data = 0x2;
break; break;
case WEST: case SOUTH:
data = 0x3; data = 0x3;
break; break;
case NORTH: case WEST:
data = 0x4; data = 0x4;
break; break;
case SOUTH: case EAST:
default: default:
data = 0x5; data = 0x5;
} }
@ -52,17 +52,17 @@ public class DirectionalContainer extends MaterialData implements Directional {
switch (data) { switch (data) {
case 0x2: case 0x2:
return BlockFace.EAST; return BlockFace.NORTH;
case 0x3: case 0x3:
return BlockFace.WEST; return BlockFace.SOUTH;
case 0x4: case 0x4:
return BlockFace.NORTH; return BlockFace.WEST;
case 0x5: case 0x5:
default: default:
return BlockFace.SOUTH; return BlockFace.EAST;
} }
} }

Datei anzeigen

@ -81,15 +81,15 @@ public class Door extends MaterialData implements Directional, Openable {
public void setFacingDirection(BlockFace face) { public void setFacingDirection(BlockFace face) {
byte data = (byte) (getData() & 0x12); byte data = (byte) (getData() & 0x12);
switch (face) { switch (face) {
case EAST: case NORTH:
data |= 0x1; data |= 0x1;
break; break;
case SOUTH: case EAST:
data |= 0x2; data |= 0x2;
break; break;
case WEST: case SOUTH:
data |= 0x3; data |= 0x3;
break; break;
} }
@ -105,16 +105,16 @@ public class Door extends MaterialData implements Directional, Openable {
byte data = (byte) (getData() & 0x3); byte data = (byte) (getData() & 0x3);
switch (data) { switch (data) {
case 0: case 0:
return BlockFace.NORTH; return BlockFace.WEST;
case 1: case 1:
return BlockFace.EAST; return BlockFace.NORTH;
case 2: case 2:
return BlockFace.SOUTH; return BlockFace.EAST;
case 3: case 3:
return BlockFace.WEST; return BlockFace.SOUTH;
} }
return null; // shouldn't happen return null; // shouldn't happen
} }

Datei anzeigen

@ -37,7 +37,7 @@ public class ExtendedRails extends Rails {
public void setDirection(BlockFace face, boolean isOnSlope) { public void setDirection(BlockFace face, boolean isOnSlope) {
boolean extraBitSet = (getData() & 0x8) == 0x8; 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!"); throw new IllegalArgumentException("Detector rails and powered rails cannot be set on a curve!");
} }

Datei anzeigen

@ -31,16 +31,16 @@ public class Gate extends MaterialData implements Directional, Openable {
switch (face) { switch (face) {
default: default:
case SOUTH: case EAST:
data |= GATE_SOUTH; data |= GATE_SOUTH;
break; break;
case WEST: case SOUTH:
data |= GATE_WEST; data |= GATE_WEST;
break; break;
case NORTH: case WEST:
data |= GATE_NORTH; data |= GATE_NORTH;
break; break;
case EAST: case NORTH:
data |= GATE_EAST; data |= GATE_EAST;
break; break;
} }
@ -51,16 +51,16 @@ public class Gate extends MaterialData implements Directional, Openable {
public BlockFace getFacing() { public BlockFace getFacing() {
switch (getData() & DIR_BIT) { switch (getData() & DIR_BIT) {
case GATE_SOUTH: case GATE_SOUTH:
return BlockFace.SOUTH;
case GATE_WEST:
return BlockFace.WEST;
case GATE_NORTH:
return BlockFace.NORTH;
case GATE_EAST:
return BlockFace.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() { public boolean isOpen() {

Datei anzeigen

@ -37,16 +37,16 @@ public class Ladder extends SimpleAttachableMaterialData {
switch (data) { switch (data) {
case 0x2: case 0x2:
return BlockFace.WEST;
case 0x3:
return BlockFace.EAST;
case 0x4:
return BlockFace.SOUTH; return BlockFace.SOUTH;
case 0x5: case 0x3:
return BlockFace.NORTH; return BlockFace.NORTH;
case 0x4:
return BlockFace.EAST;
case 0x5:
return BlockFace.WEST;
} }
return null; return null;
@ -59,19 +59,19 @@ public class Ladder extends SimpleAttachableMaterialData {
byte data = (byte) 0x0; byte data = (byte) 0x0;
switch (face) { switch (face) {
case WEST: case SOUTH:
data = 0x2; data = 0x2;
break; break;
case EAST: case NORTH:
data = 0x3; data = 0x3;
break; break;
case SOUTH: case EAST:
data = 0x4; data = 0x4;
break; break;
case NORTH: case WEST:
data = 0x5; data = 0x5;
break; break;
} }

Datei anzeigen

@ -56,16 +56,16 @@ public class Lever extends SimpleAttachableMaterialData implements Redstone {
switch (data) { switch (data) {
case 0x1: case 0x1:
return BlockFace.NORTH; return BlockFace.WEST;
case 0x2: case 0x2:
return BlockFace.SOUTH;
case 0x3:
return BlockFace.EAST; return BlockFace.EAST;
case 0x3:
return BlockFace.NORTH;
case 0x4: case 0x4:
return BlockFace.WEST; return BlockFace.SOUTH;
case 0x5: case 0x5:
case 0x6: case 0x6:
@ -89,43 +89,43 @@ public class Lever extends SimpleAttachableMaterialData implements Redstone {
if (attach == BlockFace.DOWN) { if (attach == BlockFace.DOWN) {
switch (face) { switch (face) {
case WEST: case SOUTH:
case EAST: case NORTH:
data |= 0x5; data |= 0x5;
break; break;
case SOUTH: case EAST:
case NORTH: case WEST:
data |= 0x6; data |= 0x6;
break; break;
} }
} else if (attach == BlockFace.UP) { } else if (attach == BlockFace.UP) {
switch (face) { switch (face) {
case WEST: case SOUTH:
case EAST: case NORTH:
data |= 0x7; data |= 0x7;
break; break;
case SOUTH: case EAST:
case NORTH: case WEST:
data |= 0x0; data |= 0x0;
break; break;
} }
} else { } else {
switch (face) { switch (face) {
case SOUTH: case EAST:
data |= 0x1; data |= 0x1;
break; break;
case NORTH: case WEST:
data |= 0x2; data |= 0x2;
break; break;
case WEST: case SOUTH:
data |= 0x3; data |= 0x3;
break; break;
case EAST: case NORTH:
data |= 0x4; data |= 0x4;
break; break;
} }

Datei anzeigen

@ -63,13 +63,13 @@ public class Mushroom extends MaterialData {
} }
switch (face) { 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: 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; return data % EAST_WEST_LIMIT == WEST_REMAINDER;
case UP: case UP:
return true; return true;
@ -96,23 +96,23 @@ public class Mushroom extends MaterialData {
} }
switch (face) { switch (face) {
case NORTH: case WEST:
if (painted) { if (painted) {
data -= NORTH_SOUTH_MOD; data -= NORTH_SOUTH_MOD;
} else { } else {
data += NORTH_SOUTH_MOD; data += NORTH_SOUTH_MOD;
} }
break;
case SOUTH:
if (painted) {
data += NORTH_SOUTH_MOD;
} else {
data -= NORTH_SOUTH_MOD;
}
break; break;
case EAST: case EAST:
if (painted) {
data += NORTH_SOUTH_MOD;
} else {
data -= NORTH_SOUTH_MOD;
}
break;
case NORTH:
if (painted) { if (painted) {
data += EAST_WEST_MOD; data += EAST_WEST_MOD;
} else { } else {
@ -120,7 +120,7 @@ public class Mushroom extends MaterialData {
} }
break; break;
case WEST: case SOUTH:
if (painted) { if (painted) {
data -= EAST_WEST_MOD; data -= EAST_WEST_MOD;
} else { } else {
@ -147,22 +147,22 @@ public class Mushroom extends MaterialData {
public Set<BlockFace> getPaintedFaces() { public Set<BlockFace> getPaintedFaces() {
EnumSet<BlockFace> faces = EnumSet.noneOf(BlockFace.class); EnumSet<BlockFace> 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)) { if (isFacePainted(BlockFace.WEST)) {
faces.add(BlockFace.WEST); faces.add(BlockFace.WEST);
} }
if (isFacePainted(BlockFace.NORTH)) {
faces.add(BlockFace.NORTH);
}
if (isFacePainted(BlockFace.SOUTH)) { if (isFacePainted(BlockFace.SOUTH)) {
faces.add(BlockFace.SOUTH); faces.add(BlockFace.SOUTH);
} }
if (isFacePainted(BlockFace.EAST)) {
faces.add(BlockFace.EAST);
}
if (isFacePainted(BlockFace.UP)) { if (isFacePainted(BlockFace.UP)) {
faces.add(BlockFace.UP); faces.add(BlockFace.UP);
} }

Datei anzeigen

@ -30,16 +30,16 @@ public class PistonBaseMaterial extends MaterialData implements Directional, Red
case UP: case UP:
data |= 1; data |= 1;
break; break;
case EAST: case NORTH:
data |= 2; data |= 2;
break; break;
case WEST: case SOUTH:
data |= 3; data |= 3;
break; break;
case NORTH: case WEST:
data |= 4; data |= 4;
break; break;
case SOUTH: case EAST:
data |= 5; data |= 5;
break; break;
} }
@ -55,13 +55,13 @@ public class PistonBaseMaterial extends MaterialData implements Directional, Red
case 1: case 1:
return BlockFace.UP; return BlockFace.UP;
case 2: case 2:
return BlockFace.EAST;
case 3:
return BlockFace.WEST;
case 4:
return BlockFace.NORTH; return BlockFace.NORTH;
case 5: case 3:
return BlockFace.SOUTH; return BlockFace.SOUTH;
case 4:
return BlockFace.WEST;
case 5:
return BlockFace.EAST;
default: default:
return BlockFace.SELF; return BlockFace.SELF;
} }

Datei anzeigen

@ -30,16 +30,16 @@ public class PistonExtensionMaterial extends MaterialData implements Attachable
case UP: case UP:
data |= 1; data |= 1;
break; break;
case EAST: case NORTH:
data |= 2; data |= 2;
break; break;
case WEST: case SOUTH:
data |= 3; data |= 3;
break; break;
case NORTH: case WEST:
data |= 4; data |= 4;
break; break;
case SOUTH: case EAST:
data |= 5; data |= 5;
break; break;
} }
@ -55,13 +55,13 @@ public class PistonExtensionMaterial extends MaterialData implements Attachable
case 1: case 1:
return BlockFace.UP; return BlockFace.UP;
case 2: case 2:
return BlockFace.EAST;
case 3:
return BlockFace.WEST;
case 4:
return BlockFace.NORTH; return BlockFace.NORTH;
case 5: case 3:
return BlockFace.SOUTH; return BlockFace.SOUTH;
case 4:
return BlockFace.WEST;
case 5:
return BlockFace.EAST;
default: default:
return BlockFace.SELF; return BlockFace.SELF;
} }

Datei anzeigen

@ -46,19 +46,19 @@ public class Pumpkin extends MaterialData implements Directional {
byte data; byte data;
switch (face) { switch (face) {
case EAST: case NORTH:
data = 0x0; data = 0x0;
break; break;
case SOUTH: case EAST:
data = 0x1; data = 0x1;
break; break;
case WEST: case SOUTH:
data = 0x2; data = 0x2;
break; break;
case NORTH: case WEST:
default: default:
data = 0x3; data = 0x3;
} }
@ -71,17 +71,17 @@ public class Pumpkin extends MaterialData implements Directional {
switch (data) { switch (data) {
case 0x0: case 0x0:
return BlockFace.EAST; return BlockFace.NORTH;
case 0x1: case 0x1:
return BlockFace.SOUTH; return BlockFace.EAST;
case 0x2: case 0x2:
return BlockFace.WEST; return BlockFace.SOUTH;
case 0x3: case 0x3:
default: default:
return BlockFace.SOUTH; return BlockFace.EAST;
} }
} }

Datei anzeigen

@ -59,23 +59,23 @@ public class Rails extends MaterialData {
switch (d) { switch (d) {
case 0x0: case 0x0:
default: default:
return BlockFace.WEST; return BlockFace.SOUTH;
case 0x1: case 0x1:
return BlockFace.SOUTH;
case 0x2:
return BlockFace.SOUTH;
case 0x3:
return BlockFace.NORTH;
case 0x4:
return BlockFace.EAST; return BlockFace.EAST;
case 0x5: case 0x2:
return BlockFace.EAST;
case 0x3:
return BlockFace.WEST; return BlockFace.WEST;
case 0x4:
return BlockFace.NORTH;
case 0x5:
return BlockFace.SOUTH;
case 0x6: case 0x6:
return BlockFace.NORTH_EAST; return BlockFace.NORTH_EAST;
@ -116,19 +116,19 @@ public class Rails extends MaterialData {
*/ */
public void setDirection(BlockFace face, boolean isOnSlope) { public void setDirection(BlockFace face, boolean isOnSlope) {
switch (face) { switch (face) {
case SOUTH: case EAST:
setData((byte) (isOnSlope ? 0x2 : 0x1)); setData((byte) (isOnSlope ? 0x2 : 0x1));
break; break;
case NORTH: case WEST:
setData((byte) (isOnSlope ? 0x3 : 0x1)); setData((byte) (isOnSlope ? 0x3 : 0x1));
break; break;
case EAST: case NORTH:
setData((byte) (isOnSlope ? 0x4 : 0x0)); setData((byte) (isOnSlope ? 0x4 : 0x0));
break; break;
case WEST: case SOUTH:
setData((byte) (isOnSlope ? 0x5 : 0x0)); setData((byte) (isOnSlope ? 0x5 : 0x0));
break; break;

Datei anzeigen

@ -48,16 +48,16 @@ public class Sign extends MaterialData implements Attachable {
switch (data) { switch (data) {
case 0x2: case 0x2:
return BlockFace.WEST;
case 0x3:
return BlockFace.EAST;
case 0x4:
return BlockFace.SOUTH; return BlockFace.SOUTH;
case 0x5: case 0x3:
return BlockFace.NORTH; return BlockFace.NORTH;
case 0x4:
return BlockFace.EAST;
case 0x5:
return BlockFace.WEST;
} }
return null; return null;
@ -77,7 +77,7 @@ public class Sign extends MaterialData implements Attachable {
if (!isWallSign()) { if (!isWallSign()) {
switch (data) { switch (data) {
case 0x0: case 0x0:
return BlockFace.WEST; return BlockFace.SOUTH;
case 0x1: case 0x1:
return BlockFace.WEST_NORTH_WEST; return BlockFace.WEST_NORTH_WEST;
@ -89,7 +89,7 @@ public class Sign extends MaterialData implements Attachable {
return BlockFace.NORTH_NORTH_WEST; return BlockFace.NORTH_NORTH_WEST;
case 0x4: case 0x4:
return BlockFace.NORTH; return BlockFace.WEST;
case 0x5: case 0x5:
return BlockFace.NORTH_NORTH_EAST; return BlockFace.NORTH_NORTH_EAST;
@ -101,7 +101,7 @@ public class Sign extends MaterialData implements Attachable {
return BlockFace.EAST_NORTH_EAST; return BlockFace.EAST_NORTH_EAST;
case 0x8: case 0x8:
return BlockFace.EAST; return BlockFace.NORTH;
case 0x9: case 0x9:
return BlockFace.EAST_SOUTH_EAST; return BlockFace.EAST_SOUTH_EAST;
@ -113,7 +113,7 @@ public class Sign extends MaterialData implements Attachable {
return BlockFace.SOUTH_SOUTH_EAST; return BlockFace.SOUTH_SOUTH_EAST;
case 0xC: case 0xC:
return BlockFace.SOUTH; return BlockFace.EAST;
case 0xD: case 0xD:
return BlockFace.SOUTH_SOUTH_WEST; return BlockFace.SOUTH_SOUTH_WEST;
@ -136,25 +136,25 @@ public class Sign extends MaterialData implements Attachable {
if (isWallSign()) { if (isWallSign()) {
switch (face) { switch (face) {
case EAST: case NORTH:
data = 0x2; data = 0x2;
break; break;
case WEST: case SOUTH:
data = 0x3; data = 0x3;
break; break;
case NORTH: case WEST:
data = 0x4; data = 0x4;
break; break;
case SOUTH: case EAST:
default: default:
data = 0x5; data = 0x5;
} }
} else { } else {
switch (face) { switch (face) {
case WEST: case SOUTH:
data = 0x0; data = 0x0;
break; break;
@ -170,7 +170,7 @@ public class Sign extends MaterialData implements Attachable {
data = 0x3; data = 0x3;
break; break;
case NORTH: case WEST:
data = 0x4; data = 0x4;
break; break;
@ -186,7 +186,7 @@ public class Sign extends MaterialData implements Attachable {
data = 0x7; data = 0x7;
break; break;
case EAST: case NORTH:
data = 0x8; data = 0x8;
break; break;
@ -202,7 +202,7 @@ public class Sign extends MaterialData implements Attachable {
data = 0xB; data = 0xB;
break; break;
case SOUTH: case EAST:
data = 0xC; data = 0xC;
break; break;

Datei anzeigen

@ -41,19 +41,19 @@ public class Skull extends MaterialData implements Directional {
int data; int data;
switch (face) { switch (face) {
case EAST: case NORTH:
data = 0x1; data = 0x1;
break; break;
case SOUTH: case EAST:
data = 0x2; data = 0x2;
break; break;
case WEST: case SOUTH:
data = 0x3; data = 0x3;
break; break;
case NORTH: case WEST:
default: default:
data = 0x4; data = 0x4;
} }
@ -66,17 +66,17 @@ public class Skull extends MaterialData implements Directional {
switch (data) { switch (data) {
case 0x1: case 0x1:
return BlockFace.EAST; return BlockFace.NORTH;
case 0x2: case 0x2:
return BlockFace.SOUTH; return BlockFace.EAST;
case 0x3: case 0x3:
return BlockFace.WEST; return BlockFace.SOUTH;
case 0x4: case 0x4:
default: default:
return BlockFace.SOUTH; return BlockFace.EAST;
} }
} }

Datei anzeigen

@ -33,16 +33,16 @@ public class Stairs extends MaterialData implements Directional {
switch (data & 0x3) { switch (data & 0x3) {
case 0x0: case 0x0:
default: default:
return BlockFace.SOUTH; return BlockFace.EAST;
case 0x1: case 0x1:
return BlockFace.NORTH;
case 0x2:
return BlockFace.WEST; return BlockFace.WEST;
case 0x2:
return BlockFace.SOUTH;
case 0x3: case 0x3:
return BlockFace.EAST; return BlockFace.NORTH;
} }
} }
@ -60,20 +60,20 @@ public class Stairs extends MaterialData implements Directional {
byte data; byte data;
switch (face) { switch (face) {
case NORTH: case WEST:
default: default:
data = 0x0; data = 0x0;
break; break;
case SOUTH: case EAST:
data = 0x1; data = 0x1;
break; break;
case EAST: case NORTH:
data = 0x2; data = 0x2;
break; break;
case WEST: case SOUTH:
data = 0x3; data = 0x3;
break; break;
} }

Datei anzeigen

@ -37,16 +37,16 @@ public class Torch extends SimpleAttachableMaterialData {
switch (data) { switch (data) {
case 0x1: case 0x1:
return BlockFace.NORTH; return BlockFace.WEST;
case 0x2: case 0x2:
return BlockFace.SOUTH;
case 0x3:
return BlockFace.EAST; return BlockFace.EAST;
case 0x3:
return BlockFace.NORTH;
case 0x4: case 0x4:
return BlockFace.WEST; return BlockFace.SOUTH;
case 0x5: case 0x5:
return BlockFace.DOWN; return BlockFace.DOWN;
@ -59,19 +59,19 @@ public class Torch extends SimpleAttachableMaterialData {
byte data; byte data;
switch (face) { switch (face) {
case SOUTH: case EAST:
data = 0x1; data = 0x1;
break; break;
case NORTH: case WEST:
data = 0x2; data = 0x2;
break; break;
case WEST: case SOUTH:
data = 0x3; data = 0x3;
break; break;
case EAST: case NORTH:
data = 0x4; data = 0x4;
break; break;

Datei anzeigen

@ -48,16 +48,16 @@ public class TrapDoor extends SimpleAttachableMaterialData implements Openable {
switch (data) { switch (data) {
case 0x0: case 0x0:
return BlockFace.WEST;
case 0x1:
return BlockFace.EAST;
case 0x2:
return BlockFace.SOUTH; return BlockFace.SOUTH;
case 0x3: case 0x1:
return BlockFace.NORTH; return BlockFace.NORTH;
case 0x2:
return BlockFace.EAST;
case 0x3:
return BlockFace.WEST;
} }
return null; return null;
@ -68,13 +68,13 @@ public class TrapDoor extends SimpleAttachableMaterialData implements Openable {
byte data = (byte) (getData() & 0x4); byte data = (byte) (getData() & 0x4);
switch (face) { switch (face) {
case WEST: case SOUTH:
data |= 0x1; data |= 0x1;
break; break;
case NORTH: case WEST:
data |= 0x2; data |= 0x2;
break; break;
case SOUTH: case EAST:
data |= 0x3; data |= 0x3;
break; break;
} }

Datei anzeigen

@ -60,7 +60,7 @@ public class Tree extends MaterialData {
/** /**
* Get direction of the log * 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() { public BlockFace getDirection() {
switch ((getData() >> 2) & 0x3) { switch ((getData() >> 2) & 0x3) {
@ -68,9 +68,9 @@ public class Tree extends MaterialData {
default: default:
return BlockFace.UP; return BlockFace.UP;
case 1: // North-south case 1: // North-south
return BlockFace.NORTH; return BlockFace.WEST;
case 2: // East-west case 2: // East-west
return BlockFace.EAST; return BlockFace.NORTH;
case 3: // Directionless (bark on all sides) case 3: // Directionless (bark on all sides)
return BlockFace.SELF; return BlockFace.SELF;
} }
@ -87,12 +87,12 @@ public class Tree extends MaterialData {
default: default:
dat = 0; dat = 0;
break; break;
case NORTH: case WEST:
case SOUTH: case EAST:
dat = 1; dat = 1;
break; break;
case EAST: case NORTH:
case WEST: case SOUTH:
dat = 2; dat = 2;
break; break;
case SELF: case SELF:

Datei anzeigen

@ -68,16 +68,16 @@ public class TripwireHook extends SimpleAttachableMaterialData implements Redsto
public void setFacingDirection(BlockFace face) { public void setFacingDirection(BlockFace face) {
int dat = getData() & 0xC; int dat = getData() & 0xC;
switch (face) { switch (face) {
case NORTH: case WEST:
dat |= 0x1; dat |= 0x1;
break; break;
case EAST: case NORTH:
dat |= 0x2; dat |= 0x2;
break; break;
case SOUTH: case EAST:
dat |= 0x3; dat |= 0x3;
break; break;
case WEST: case SOUTH:
default: default:
break; break;
} }
@ -87,13 +87,13 @@ public class TripwireHook extends SimpleAttachableMaterialData implements Redsto
public BlockFace getAttachedFace() { public BlockFace getAttachedFace() {
switch (getData() & 0x3) { switch (getData() & 0x3) {
case 0: case 0:
return BlockFace.EAST;
case 1:
return BlockFace.SOUTH;
case 2:
return BlockFace.WEST;
case 3:
return BlockFace.NORTH; return BlockFace.NORTH;
case 1:
return BlockFace.EAST;
case 2:
return BlockFace.SOUTH;
case 3:
return BlockFace.WEST;
} }
return null; return null;
} }

Datei anzeigen

@ -14,7 +14,7 @@ public class Vine extends MaterialData {
private static final int VINE_EAST = 0x8; private static final int VINE_EAST = 0x8;
private static final int VINE_WEST = 0x2; private static final int VINE_WEST = 0x2;
private static final int VINE_SOUTH = 0x1; private static final int VINE_SOUTH = 0x1;
EnumSet<BlockFace> possibleFaces = EnumSet.of(BlockFace.NORTH, BlockFace.EAST, BlockFace.WEST, BlockFace.SOUTH); EnumSet<BlockFace> possibleFaces = EnumSet.of(BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST);
public Vine() { public Vine() {
super(Material.VINE); super(Material.VINE);
@ -38,19 +38,19 @@ public class Vine extends MaterialData {
byte data = 0; byte data = 0;
if (faces.contains(BlockFace.NORTH)) { if (faces.contains(BlockFace.WEST)) {
data |= VINE_NORTH; data |= VINE_NORTH;
} }
if (faces.contains(BlockFace.EAST)) { if (faces.contains(BlockFace.NORTH)) {
data |= VINE_EAST; data |= VINE_EAST;
} }
if (faces.contains(BlockFace.WEST)) { if (faces.contains(BlockFace.SOUTH)) {
data |= VINE_WEST; data |= VINE_WEST;
} }
if (faces.contains(BlockFace.SOUTH)) { if (faces.contains(BlockFace.EAST)) {
data |= VINE_SOUTH; data |= VINE_SOUTH;
} }
@ -66,22 +66,22 @@ public class Vine extends MaterialData {
*/ */
public boolean isOnFace(BlockFace face) { public boolean isOnFace(BlockFace face) {
switch (face) { switch (face) {
case NORTH:
return (getData() & VINE_NORTH) > 0;
case EAST:
return (getData() & VINE_EAST) > 0;
case WEST: case WEST:
return (getData() & VINE_WEST) > 0; return (getData() & VINE_NORTH) > 0;
case NORTH:
return (getData() & VINE_EAST) > 0;
case SOUTH: case SOUTH:
return (getData() & VINE_WEST) > 0;
case EAST:
return (getData() & VINE_SOUTH) > 0; return (getData() & VINE_SOUTH) > 0;
case NORTH_EAST: case NORTH_EAST:
return isOnFace(BlockFace.NORTH) && isOnFace(BlockFace.EAST); return isOnFace(BlockFace.WEST) && isOnFace(BlockFace.NORTH);
case NORTH_WEST: case NORTH_WEST:
return isOnFace(BlockFace.NORTH) && isOnFace(BlockFace.WEST); return isOnFace(BlockFace.WEST) && isOnFace(BlockFace.SOUTH);
case SOUTH_EAST: case SOUTH_EAST:
return isOnFace(BlockFace.SOUTH) && isOnFace(BlockFace.EAST); return isOnFace(BlockFace.EAST) && isOnFace(BlockFace.NORTH);
case SOUTH_WEST: 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 case UP: // It's impossible to be accurate with this since it's contextual
return true; return true;
default: default:
@ -96,33 +96,33 @@ public class Vine extends MaterialData {
*/ */
public void putOnFace(BlockFace face) { public void putOnFace(BlockFace face) {
switch(face) { switch(face) {
case NORTH: case WEST:
setData((byte) (getData() | VINE_NORTH)); setData((byte) (getData() | VINE_NORTH));
break; break;
case EAST: case NORTH:
setData((byte) (getData() | VINE_EAST)); setData((byte) (getData() | VINE_EAST));
break; break;
case WEST: case SOUTH:
setData((byte) (getData() | VINE_WEST)); setData((byte) (getData() | VINE_WEST));
break; break;
case SOUTH: case EAST:
setData((byte) (getData() | VINE_SOUTH)); setData((byte) (getData() | VINE_SOUTH));
break; break;
case NORTH_EAST: case NORTH_EAST:
putOnFace(BlockFace.WEST);
putOnFace(BlockFace.NORTH); putOnFace(BlockFace.NORTH);
putOnFace(BlockFace.EAST);
break; break;
case NORTH_WEST: case NORTH_WEST:
putOnFace(BlockFace.NORTH);
putOnFace(BlockFace.WEST); putOnFace(BlockFace.WEST);
putOnFace(BlockFace.SOUTH);
break; break;
case SOUTH_EAST: case SOUTH_EAST:
putOnFace(BlockFace.SOUTH);
putOnFace(BlockFace.EAST); putOnFace(BlockFace.EAST);
putOnFace(BlockFace.NORTH);
break; break;
case SOUTH_WEST: case SOUTH_WEST:
putOnFace(BlockFace.EAST);
putOnFace(BlockFace.SOUTH); putOnFace(BlockFace.SOUTH);
putOnFace(BlockFace.WEST);
break; break;
case UP: case UP:
break; break;
@ -138,33 +138,33 @@ public class Vine extends MaterialData {
*/ */
public void removeFromFace(BlockFace face) { public void removeFromFace(BlockFace face) {
switch(face) { switch(face) {
case NORTH: case WEST:
setData((byte) (getData() &~ VINE_NORTH)); setData((byte) (getData() &~ VINE_NORTH));
break; break;
case EAST: case NORTH:
setData((byte) (getData() &~ VINE_EAST)); setData((byte) (getData() &~ VINE_EAST));
break; break;
case WEST: case SOUTH:
setData((byte) (getData() &~ VINE_WEST)); setData((byte) (getData() &~ VINE_WEST));
break; break;
case SOUTH: case EAST:
setData((byte) (getData() &~ VINE_SOUTH)); setData((byte) (getData() &~ VINE_SOUTH));
break; break;
case NORTH_EAST: case NORTH_EAST:
removeFromFace(BlockFace.WEST);
removeFromFace(BlockFace.NORTH); removeFromFace(BlockFace.NORTH);
removeFromFace(BlockFace.EAST);
break; break;
case NORTH_WEST: case NORTH_WEST:
removeFromFace(BlockFace.NORTH);
removeFromFace(BlockFace.WEST); removeFromFace(BlockFace.WEST);
removeFromFace(BlockFace.SOUTH);
break; break;
case SOUTH_EAST: case SOUTH_EAST:
removeFromFace(BlockFace.SOUTH);
removeFromFace(BlockFace.EAST); removeFromFace(BlockFace.EAST);
removeFromFace(BlockFace.NORTH);
break; break;
case SOUTH_WEST: case SOUTH_WEST:
removeFromFace(BlockFace.EAST);
removeFromFace(BlockFace.SOUTH); removeFromFace(BlockFace.SOUTH);
removeFromFace(BlockFace.WEST);
break; break;
case UP: case UP:
break; break;

Datei anzeigen

@ -179,7 +179,7 @@ public class BlockIterator implements Iterator<Block> {
} }
private BlockFace getXFace(Vector direction) { 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) { private BlockFace getYFace(Vector direction) {
@ -187,7 +187,7 @@ public class BlockIterator implements Iterator<Block> {
} }
private BlockFace getZFace(Vector direction) { 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) { private double getXLength(Vector direction) {