Use existing function to get opposite block face

By: Acrobot <andrzejp@dysleksja.pl>
This commit is contained in:
Bukkit/Spigot 2012-05-20 11:14:43 +02:00
parent 7769f579c6
commit 1d034350f7

View file

@ -134,16 +134,16 @@ public class BlockIterator implements Iterator<Block> {
Block lastBlock; Block lastBlock;
lastBlock = startBlock.getRelative(reverseFace(mainFace)); lastBlock = startBlock.getRelative(mainFace.getOppositeFace());
if (secondError < 0) { if (secondError < 0) {
secondError += gridSize; secondError += gridSize;
lastBlock = lastBlock.getRelative(reverseFace(secondFace)); lastBlock = lastBlock.getRelative(secondFace.getOppositeFace());
} }
if (thirdError < 0) { if (thirdError < 0) {
thirdError += gridSize; thirdError += gridSize;
lastBlock = lastBlock.getRelative(reverseFace(thirdFace)); lastBlock = lastBlock.getRelative(thirdFace.getOppositeFace());
} }
// This means that when the variables are positive, it means that the coord=1 boundary has been crossed // This means that when the variables are positive, it means that the coord=1 boundary has been crossed
@ -178,31 +178,6 @@ public class BlockIterator implements Iterator<Block> {
return a.getX() == b.getX() && a.getY() == b.getY() && a.getZ() == b.getZ(); return a.getX() == b.getX() && a.getY() == b.getY() && a.getZ() == b.getZ();
} }
private BlockFace reverseFace(BlockFace face) {
switch (face) {
case UP:
return BlockFace.DOWN;
case DOWN:
return BlockFace.UP;
case NORTH:
return BlockFace.SOUTH;
case SOUTH:
return BlockFace.NORTH;
case EAST:
return BlockFace.WEST;
case WEST:
return BlockFace.EAST;
default:
return null;
}
}
private BlockFace getXFace(Vector direction) { private BlockFace getXFace(Vector direction) {
return ((direction.getX() > 0) ? BlockFace.SOUTH : BlockFace.NORTH); return ((direction.getX() > 0) ? BlockFace.SOUTH : BlockFace.NORTH);
} }