Deprecated Block.getFace(Face) and Block.getFace(Face,int); use getRelative()

This commit is contained in:
Erik Broes 2011-07-17 15:01:15 +02:00
parent 36d901c6b1
commit 9b0dbed88e
2 changed files with 35 additions and 42 deletions

View File

@ -21,32 +21,14 @@ public interface Block {
byte getData(); byte getData();
/** /**
* Gets the block at the given face<br /> * @deprecated use {@link #getRelative(BlockFace face)}
* <br />
* This method is equal to getFace(face, 1)
*
* @param face Face of this block to return
* @return Block at the given face
* @see Block.getFace(BlockFace face, int distance);
*/ */
Block getFace(BlockFace face); @Deprecated Block getFace(BlockFace face);
/** /**
* Gets the block at the given distance of the given face<br /> * @deprecated use {@link #getRelative(BlockFace face, int distance)}
* <br />
* For example, the following method places water at 100,102,100; two blocks
* above 100,100,100.
* <pre>
* Block block = world.getBlockAt(100,100,100);
* Block shower = block.getFace(BlockFace.Up, 2);
* shower.setType(Material.WATER);
* </pre>
*
* @param face Face of this block to return
* @param distance Distance to get the block at
* @return Block at the given face
*/ */
Block getFace(BlockFace face, int distance); @Deprecated Block getFace(BlockFace face, int distance);
/** /**
* Gets the block at the given offsets * Gets the block at the given offsets
@ -59,19 +41,30 @@ public interface Block {
Block getRelative(int modX, int modY, int modZ); Block getRelative(int modX, int modY, int modZ);
/** /**
* Gets the block at the given offsets * Gets the block at the given face<br />
* <br />
* This method is equal to getRelative(face, 1)
* *
* @param face face * @param face Face of this block to return
* @return Block at the given offsets * @return Block at the given face
* @see Block.getRelative(BlockFace face, int distance);
*/ */
Block getRelative(BlockFace face); Block getRelative(BlockFace face);
/** /**
* Gets the block at the given offsets * Gets the block at the given distance of the given face<br />
* <br />
* For example, the following method places water at 100,102,100; two blocks
* above 100,100,100.
* <pre>
* Block block = world.getBlockAt(100,100,100);
* Block shower = block.getFace(BlockFace.UP, 2);
* shower.setType(Material.WATER);
* </pre>
* *
* @param face face * @param face Face of this block to return
* @param distance distance * @param distance Distance to get the block at
* @return Block at the given offset and distance * @return Block at the given face
*/ */
Block getRelative(BlockFace face, int distance); Block getRelative(BlockFace face, int distance);

View File

@ -135,16 +135,16 @@ public class BlockIterator implements Iterator<Block> {
Block lastBlock; Block lastBlock;
lastBlock = startBlock.getFace(reverseFace(mainFace)); lastBlock = startBlock.getRelative(reverseFace(mainFace));
if (secondError < 0) { if (secondError < 0) {
secondError += gridSize; secondError += gridSize;
lastBlock = lastBlock.getFace(reverseFace(secondFace)); lastBlock = lastBlock.getRelative(reverseFace(secondFace));
} }
if (thirdError < 0) { if (thirdError < 0) {
thirdError += gridSize; thirdError += gridSize;
lastBlock = lastBlock.getFace(reverseFace(thirdFace)); lastBlock = lastBlock.getRelative(reverseFace(thirdFace));
} }
// 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
@ -350,32 +350,32 @@ public class BlockIterator implements Iterator<Block> {
thirdError += thirdStep; thirdError += thirdStep;
if (secondError > 0 && thirdError > 0) { if (secondError > 0 && thirdError > 0) {
blockQueue[2] = blockQueue[0].getFace(mainFace); blockQueue[2] = blockQueue[0].getRelative(mainFace);
if (((long) secondStep) * ((long) thirdError) < ((long) thirdStep) * ((long) secondError)) { if (((long) secondStep) * ((long) thirdError) < ((long) thirdStep) * ((long) secondError)) {
blockQueue[1] = blockQueue[2].getFace(secondFace); blockQueue[1] = blockQueue[2].getRelative(secondFace);
blockQueue[0] = blockQueue[1].getFace(thirdFace); blockQueue[0] = blockQueue[1].getRelative(thirdFace);
} else { } else {
blockQueue[1] = blockQueue[2].getFace(thirdFace); blockQueue[1] = blockQueue[2].getRelative(thirdFace);
blockQueue[0] = blockQueue[1].getFace(secondFace); blockQueue[0] = blockQueue[1].getRelative(secondFace);
} }
thirdError -= gridSize; thirdError -= gridSize;
secondError -= gridSize; secondError -= gridSize;
currentBlock = 2; currentBlock = 2;
return; return;
} else if (secondError > 0) { } else if (secondError > 0) {
blockQueue[1] = blockQueue[0].getFace(mainFace); blockQueue[1] = blockQueue[0].getRelative(mainFace);
blockQueue[0] = blockQueue[1].getFace(secondFace); blockQueue[0] = blockQueue[1].getRelative(secondFace);
secondError -= gridSize; secondError -= gridSize;
currentBlock = 1; currentBlock = 1;
return; return;
} else if (thirdError > 0) { } else if (thirdError > 0) {
blockQueue[1] = blockQueue[0].getFace(mainFace); blockQueue[1] = blockQueue[0].getRelative(mainFace);
blockQueue[0] = blockQueue[1].getFace(thirdFace); blockQueue[0] = blockQueue[1].getRelative(thirdFace);
thirdError -= gridSize; thirdError -= gridSize;
currentBlock = 1; currentBlock = 1;
return; return;
} else { } else {
blockQueue[0] = blockQueue[0].getFace(mainFace); blockQueue[0] = blockQueue[0].getRelative(mainFace);
currentBlock = 0; currentBlock = 0;
return; return;
} }