From 9b0dbed88ea31ef3e32f9ab9fa430896f0095930 Mon Sep 17 00:00:00 2001 From: Erik Broes Date: Sun, 17 Jul 2011 15:01:15 +0200 Subject: [PATCH] Deprecated Block.getFace(Face) and Block.getFace(Face,int); use getRelative() --- src/main/java/org/bukkit/block/Block.java | 51 ++++++++----------- .../java/org/bukkit/util/BlockIterator.java | 26 +++++----- 2 files changed, 35 insertions(+), 42 deletions(-) diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java index 05fb9ca8..a5c3bb0c 100644 --- a/src/main/java/org/bukkit/block/Block.java +++ b/src/main/java/org/bukkit/block/Block.java @@ -21,32 +21,14 @@ public interface Block { byte getData(); /** - * Gets the block at the given face
- *
- * 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); + * @deprecated use {@link #getRelative(BlockFace face)} */ - Block getFace(BlockFace face); + @Deprecated Block getFace(BlockFace face); /** - * Gets the block at the given distance of the given face
- *
- * For example, the following method places water at 100,102,100; two blocks - * above 100,100,100. - *
-     * Block block = world.getBlockAt(100,100,100);
-     * Block shower = block.getFace(BlockFace.Up, 2);
-     * shower.setType(Material.WATER);
-     * 
- * - * @param face Face of this block to return - * @param distance Distance to get the block at - * @return Block at the given face + * @deprecated use {@link #getRelative(BlockFace face, int distance)} */ - Block getFace(BlockFace face, int distance); + @Deprecated Block getFace(BlockFace face, int distance); /** * Gets the block at the given offsets @@ -59,19 +41,30 @@ public interface Block { Block getRelative(int modX, int modY, int modZ); /** - * Gets the block at the given offsets + * Gets the block at the given face
+ *
+ * This method is equal to getRelative(face, 1) * - * @param face face - * @return Block at the given offsets + * @param face Face of this block to return + * @return Block at the given face + * @see Block.getRelative(BlockFace face, int distance); */ Block getRelative(BlockFace face); /** - * Gets the block at the given offsets + * Gets the block at the given distance of the given face
+ *
+ * For example, the following method places water at 100,102,100; two blocks + * above 100,100,100. + *
+     * Block block = world.getBlockAt(100,100,100);
+     * Block shower = block.getFace(BlockFace.UP, 2);
+     * shower.setType(Material.WATER);
+     * 
* - * @param face face - * @param distance distance - * @return Block at the given offset and distance + * @param face Face of this block to return + * @param distance Distance to get the block at + * @return Block at the given face */ Block getRelative(BlockFace face, int distance); diff --git a/src/main/java/org/bukkit/util/BlockIterator.java b/src/main/java/org/bukkit/util/BlockIterator.java index 0a2fa5be..0427d889 100644 --- a/src/main/java/org/bukkit/util/BlockIterator.java +++ b/src/main/java/org/bukkit/util/BlockIterator.java @@ -135,16 +135,16 @@ public class BlockIterator implements Iterator { Block lastBlock; - lastBlock = startBlock.getFace(reverseFace(mainFace)); + lastBlock = startBlock.getRelative(reverseFace(mainFace)); if (secondError < 0) { secondError += gridSize; - lastBlock = lastBlock.getFace(reverseFace(secondFace)); + lastBlock = lastBlock.getRelative(reverseFace(secondFace)); } if (thirdError < 0) { 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 @@ -350,32 +350,32 @@ public class BlockIterator implements Iterator { thirdError += thirdStep; 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)) { - blockQueue[1] = blockQueue[2].getFace(secondFace); - blockQueue[0] = blockQueue[1].getFace(thirdFace); + blockQueue[1] = blockQueue[2].getRelative(secondFace); + blockQueue[0] = blockQueue[1].getRelative(thirdFace); } else { - blockQueue[1] = blockQueue[2].getFace(thirdFace); - blockQueue[0] = blockQueue[1].getFace(secondFace); + blockQueue[1] = blockQueue[2].getRelative(thirdFace); + blockQueue[0] = blockQueue[1].getRelative(secondFace); } thirdError -= gridSize; secondError -= gridSize; currentBlock = 2; return; } else if (secondError > 0) { - blockQueue[1] = blockQueue[0].getFace(mainFace); - blockQueue[0] = blockQueue[1].getFace(secondFace); + blockQueue[1] = blockQueue[0].getRelative(mainFace); + blockQueue[0] = blockQueue[1].getRelative(secondFace); secondError -= gridSize; currentBlock = 1; return; } else if (thirdError > 0) { - blockQueue[1] = blockQueue[0].getFace(mainFace); - blockQueue[0] = blockQueue[1].getFace(thirdFace); + blockQueue[1] = blockQueue[0].getRelative(mainFace); + blockQueue[0] = blockQueue[1].getRelative(thirdFace); thirdError -= gridSize; currentBlock = 1; return; } else { - blockQueue[0] = blockQueue[0].getFace(mainFace); + blockQueue[0] = blockQueue[0].getRelative(mainFace); currentBlock = 0; return; }