Made Tree Feller a little more aggressive

This commit is contained in:
bm01 2013-01-24 00:52:32 +01:00
parent 9689c50603
commit 7e91776cfb
2 changed files with 24 additions and 35 deletions

View File

@ -7,13 +7,11 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.mods.CustomBlock; import com.gmail.nossr50.datatypes.mods.CustomBlock;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.Combat; import com.gmail.nossr50.skills.Combat;
@ -70,36 +68,24 @@ public abstract class TreeFeller {
* @param treeFellerBlocks List of blocks to be removed * @param treeFellerBlocks List of blocks to be removed
*/ */
private static void processRecursively(Block block, List<Block> treeFellerBlocks) { private static void processRecursively(Block block, List<Block> treeFellerBlocks) {
List<Block> futureCenterBlocks = new ArrayList<Block>(); if (!BlockChecks.isLog(block)) {
boolean centerIsLog = BlockChecks.isLog(block);
Block nextBlock = block.getRelative(BlockFace.UP);
// Handle the block above 'block'
if (addBlock(nextBlock, treeFellerBlocks)) {
if (treeFellerReachedThreshold) {
return; return;
} }
if (centerIsLog) { List<Block> futureCenterBlocks = new ArrayList<Block>();
futureCenterBlocks.add(nextBlock);
}
}
World world = block.getWorld(); World world = block.getWorld();
// Handle the blocks around 'block' // Handle the blocks around 'block'
for (int y = 0 ; y <= 1 ; y++) {
for (int x = -1 ; x <= 1 ; x++) { for (int x = -1 ; x <= 1 ; x++) {
for (int z = -1 ; z <= 1 ; z++) { for (int z = -1 ; z <= 1 ; z++) {
nextBlock = world.getBlockAt(block.getLocation().add(x, 0, z)); Block nextBlock = world.getBlockAt(block.getLocation().add(x, y, z));
handleBlock(nextBlock, futureCenterBlocks, treeFellerBlocks);
if (addBlock(nextBlock, treeFellerBlocks)) {
if (treeFellerReachedThreshold) { if (treeFellerReachedThreshold) {
return; return;
} }
if (centerIsLog) {
futureCenterBlocks.add(nextBlock);
}
} }
} }
} }
@ -115,24 +101,26 @@ public abstract class TreeFeller {
} }
/** /**
* Adds a block to the list of blocks to be removed * Handle a block addition to the list of blocks to be removed
* and to the list of blocks used for future recursive calls of 'processRecursively()'
* *
* @param block Block to be added * @param block Block to be added
* @param futureCenterBlocks List of blocks that will be used to call 'processRecursively()'
* @param treeFellerBlocks List of blocks to be removed * @param treeFellerBlocks List of blocks to be removed
* @return True if 'block' was added
*/ */
private static boolean addBlock(Block block, List<Block> treeFellerBlocks) { private static void handleBlock(Block block, List<Block> futureCenterBlocks, List<Block> treeFellerBlocks) {
if (BlockChecks.treeFellerCompatible(block) && !treeFellerBlocks.contains(block) && !mcMMO.placeStore.isTrue(block)) { if (!BlockChecks.treeFellerCompatible(block) || mcMMO.placeStore.isTrue(block) || treeFellerBlocks.contains(block)) {
return;
}
treeFellerBlocks.add(block); treeFellerBlocks.add(block);
if (treeFellerBlocks.size() >= Config.getInstance().getTreeFellerThreshold()) { if (treeFellerBlocks.size() > Woodcutting.TREE_FELLER_THRESHOLD) {
treeFellerReachedThreshold = true; treeFellerReachedThreshold = true;
return;
} }
return true; futureCenterBlocks.add(block);
}
return false;
} }
/** /**

View File

@ -27,6 +27,7 @@ public abstract class Woodcutting {
public static final double DOUBLE_DROP_CHANCE = AdvancedConfig.getInstance().getMiningDoubleDropChance(); public static final double DOUBLE_DROP_CHANCE = AdvancedConfig.getInstance().getMiningDoubleDropChance();
public static final int LEAF_BLOWER_UNLOCK_LEVEL = AdvancedConfig.getInstance().getLeafBlowUnlockLevel(); public static final int LEAF_BLOWER_UNLOCK_LEVEL = AdvancedConfig.getInstance().getLeafBlowUnlockLevel();
public static final boolean DOUBLE_DROP_DISABLED = Config.getInstance().woodcuttingDoubleDropsDisabled(); public static final boolean DOUBLE_DROP_DISABLED = Config.getInstance().woodcuttingDoubleDropsDisabled();
public static final int TREE_FELLER_THRESHOLD = Config.getInstance().getTreeFellerThreshold();
/** /**
* Begins the Tree Feller ability * Begins the Tree Feller ability