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
*/
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),

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -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;
}

Datei anzeigen

@ -74,15 +74,15 @@ public class CocoaPlant extends MaterialData implements Directional {
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,13 +94,13 @@ 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;
}

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -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
}

Datei anzeigen

@ -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!");
}

Datei anzeigen

@ -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() {

Datei anzeigen

@ -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;
}

Datei anzeigen

@ -56,16 +56,16 @@ 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:
@ -89,43 +89,43 @@ public class Lever extends SimpleAttachableMaterialData implements Redstone {
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;
}

Datei anzeigen

@ -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<BlockFace> getPaintedFaces() {
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)) {
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);
}

Datei anzeigen

@ -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;
}

Datei anzeigen

@ -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;
}

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -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;

Datei anzeigen

@ -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;

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -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;
}

Datei anzeigen

@ -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;

Datei anzeigen

@ -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;
}

Datei anzeigen

@ -60,7 +60,7 @@ 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:

Datei anzeigen

@ -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;
}

Datei anzeigen

@ -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<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() {
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;

Datei anzeigen

@ -179,7 +179,7 @@ public class BlockIterator implements Iterator<Block> {
}
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<Block> {
}
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) {