From f274d47c81b8eb91f2d1cdcf0761ab9c00690575 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Wed, 22 Feb 2012 20:53:20 -0800 Subject: [PATCH] Made Tree Feller much less aggressive. --- .../com/gmail/nossr50/skills/WoodCutting.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/WoodCutting.java b/src/main/java/com/gmail/nossr50/skills/WoodCutting.java index c39655ff6..ccf2051b6 100644 --- a/src/main/java/com/gmail/nossr50/skills/WoodCutting.java +++ b/src/main/java/com/gmail/nossr50/skills/WoodCutting.java @@ -121,29 +121,29 @@ public class WoodCutting } private static boolean treeFellerCompatible(Block block) { - return block.getType() == Material.LOG || block.getType() == Material.LEAVES; + return block.getType() == Material.LOG || block.getType() == Material.LEAVES || block.getType() == Material.AIR; } private static void processTreeFelling(Block currentBlock, World world, ArrayList toBeFelled) { int x = currentBlock.getX(), y = currentBlock.getY(), z = currentBlock.getZ(); + toBeFelled.add(currentBlock); + //These 2 are to make sure that Tree Feller isn't so aggressive + boolean isAirOrLeaves = currentBlock.getType() == Material.LEAVES || currentBlock.getType() == Material.AIR; - toBeFelled.add(currentBlock); - - //ORDER = X+, Z+, Z-, X- Block xPositive = world.getBlockAt(x+1, y, z); Block xNegative = world.getBlockAt(x-1, y, z); Block zPositive = world.getBlockAt(x, y, z+1); Block zNegative = world.getBlockAt(x, y, z-1); - if(treeFellerCompatible(xPositive) && !toBeFelled.contains(xPositive)) + if(!isTooAgressive(isAirOrLeaves, xPositive) && treeFellerCompatible(xPositive) && !toBeFelled.contains(xPositive)) processTreeFelling(xPositive, world, toBeFelled); - if(treeFellerCompatible(xNegative) && !toBeFelled.contains(xNegative)) + if(!isTooAgressive(isAirOrLeaves, xNegative) && treeFellerCompatible(xNegative) && !toBeFelled.contains(xNegative)) processTreeFelling(xNegative, world, toBeFelled); - if(treeFellerCompatible(zPositive) && !toBeFelled.contains(zPositive)) + if(!isTooAgressive(isAirOrLeaves, zPositive) && treeFellerCompatible(zPositive) && !toBeFelled.contains(zPositive)) processTreeFelling(zPositive, world, toBeFelled); - if(treeFellerCompatible(zNegative) && !toBeFelled.contains(zNegative)) + if(!isTooAgressive(isAirOrLeaves, zNegative) && treeFellerCompatible(zNegative) && !toBeFelled.contains(zNegative)) processTreeFelling(zNegative, world, toBeFelled); //Finally go Y+ @@ -158,6 +158,11 @@ public class WoodCutting } } + private static boolean isTooAgressive(boolean bool, Block block) + { + return bool && (block.getType() == Material.AIR || block.getType() == Material.LEAVES); + } + public static void woodCuttingProcCheck(Player player, Block block) { PlayerProfile PP = Users.getProfile(player);