diff --git a/build.gradle b/build.gradle index 50b48a4..b334201 100644 --- a/build.gradle +++ b/build.gradle @@ -48,7 +48,7 @@ archivesBaseName = "[${config.minecraft_version}]${config.mod_id}" minecraft { version = config.minecraft_version + "-" + config.forge_version // grab latest forge mappings = config.mappings_version - assetDir = "run/assets" + runDir = "run" replace '@MOD_VERSION@', version replace '@BSCORE_VERSION@', config.bscore_version } diff --git a/build.properties b/build.properties index ef83b1b..c5f376e 100644 --- a/build.properties +++ b/build.properties @@ -1,8 +1,8 @@ -minecraft_version=1.7.10 -forge_version=10.13.2.1232 -mappings_version=stable_12 -mod_version=2.0.4 -bscore_version=6.15 +minecraft_version=1.8 +forge_version=11.14.1.1334 +mappings_version=stable_16 +mod_version=2.0.5 +bscore_version=7.01 mod_id=Treecapitator group_name=treecapitator appendix=universal \ No newline at end of file diff --git a/src/main/java/bspkrs/treecapitator/ClientProxy.java b/src/main/java/bspkrs/treecapitator/ClientProxy.java index 8f6f99e..973cf34 100644 --- a/src/main/java/bspkrs/treecapitator/ClientProxy.java +++ b/src/main/java/bspkrs/treecapitator/ClientProxy.java @@ -3,9 +3,9 @@ import net.minecraftforge.common.config.Configuration; import bspkrs.treecapitator.config.TCSettings; import bspkrs.treecapitator.fml.gui.GuiConfigCustomCategoryListEntry; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ClientProxy extends CommonProxy diff --git a/src/main/java/bspkrs/treecapitator/CommonProxy.java b/src/main/java/bspkrs/treecapitator/CommonProxy.java index b9035fa..cad1b4e 100644 --- a/src/main/java/bspkrs/treecapitator/CommonProxy.java +++ b/src/main/java/bspkrs/treecapitator/CommonProxy.java @@ -10,14 +10,14 @@ import bspkrs.treecapitator.network.TCPacketConfig; import bspkrs.treecapitator.network.TCPacketLogin; import bspkrs.treecapitator.util.TCLog; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent; -import cpw.mods.fml.common.network.FMLEmbeddedChannel; -import cpw.mods.fml.common.network.FMLOutboundHandler; -import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.relauncher.Side; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent; +import net.minecraftforge.fml.common.network.FMLEmbeddedChannel; +import net.minecraftforge.fml.common.network.FMLOutboundHandler; +import net.minecraftforge.fml.common.network.NetworkRegistry; +import net.minecraftforge.fml.relauncher.Side; public class CommonProxy { diff --git a/src/main/java/bspkrs/treecapitator/EnchantmentTreecapitating.java b/src/main/java/bspkrs/treecapitator/EnchantmentTreecapitating.java index 6965c08..566e142 100644 --- a/src/main/java/bspkrs/treecapitator/EnchantmentTreecapitating.java +++ b/src/main/java/bspkrs/treecapitator/EnchantmentTreecapitating.java @@ -3,6 +3,7 @@ import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnumEnchantmentType; import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; import bspkrs.treecapitator.config.TCSettings; import bspkrs.treecapitator.registry.ToolRegistry; @@ -10,7 +11,7 @@ public class EnchantmentTreecapitating extends Enchantment { public EnchantmentTreecapitating(int par1, int par2) { - super(par1, par2, EnumEnchantmentType.digger); + super(par1, new ResourceLocation("treecapitating"), par2, EnumEnchantmentType.DIGGER); } @Override @@ -48,7 +49,7 @@ public int getMaxLevel() @Override public boolean canApplyTogether(Enchantment enchantment) { - return TCSettings.enableEnchantmentMode && super.canApplyTogether(enchantment) && enchantment.effectId != fortune.effectId; + return TCSettings.enableEnchantmentMode && super.canApplyTogether(enchantment) && (enchantment.effectId != fortune.effectId); } } diff --git a/src/main/java/bspkrs/treecapitator/TCClientTicker.java b/src/main/java/bspkrs/treecapitator/TCClientTicker.java index 6ed8464..f1942c6 100644 --- a/src/main/java/bspkrs/treecapitator/TCClientTicker.java +++ b/src/main/java/bspkrs/treecapitator/TCClientTicker.java @@ -3,13 +3,13 @@ import net.minecraft.client.Minecraft; import net.minecraft.util.ChatComponentText; import bspkrs.bspkrscore.fml.bspkrsCoreMod; -import cpw.mods.fml.client.FMLClientHandler; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent; -import cpw.mods.fml.common.gameevent.TickEvent.Phase; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; +import net.minecraftforge.fml.client.FMLClientHandler; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class TCClientTicker diff --git a/src/main/java/bspkrs/treecapitator/Treecapitator.java b/src/main/java/bspkrs/treecapitator/Treecapitator.java index ab1d135..00e27a0 100644 --- a/src/main/java/bspkrs/treecapitator/Treecapitator.java +++ b/src/main/java/bspkrs/treecapitator/Treecapitator.java @@ -6,6 +6,7 @@ import java.util.List; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.item.EntityItem; @@ -15,31 +16,29 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.stats.StatList; +import net.minecraft.util.BlockPos; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraftforge.common.IShearable; import bspkrs.treecapitator.config.TCSettings; import bspkrs.treecapitator.registry.ToolRegistry; import bspkrs.treecapitator.registry.TreeDefinition; -import bspkrs.treecapitator.registry.TreeRegistry; import bspkrs.treecapitator.util.Reference; import bspkrs.treecapitator.util.TCLog; import bspkrs.util.BlockID; import bspkrs.util.CommonUtils; -import bspkrs.util.Coord; import bspkrs.util.ModulusBlockID; public class Treecapitator { // The player chopping private World world; - private EntityPlayer player; - private Coord startPos; + private final EntityPlayer player; + private BlockPos startPos; // The axe of the player currently chopping private ItemStack axe; private ItemStack shears; private final TreeDefinition treeDef; - private final List masterLogList; private final BlockID vineID; private float currentAxeDamage, currentShearsDamage = 0.0F; private int numLogsToBreak; @@ -48,14 +47,13 @@ public class Treecapitator private float logDamageMultiplier; private float leafDamageMultiplier; private List drops; - private Coord dropPos; + private BlockPos dropPos; private boolean maxAllowed = false; public Treecapitator(EntityPlayer entityPlayer, TreeDefinition treeDef) { player = entityPlayer; this.treeDef = treeDef; - masterLogList = TreeRegistry.instance().masterLogList(); vineID = new BlockID(Blocks.vine); logDamageMultiplier = TCSettings.damageMultiplier; leafDamageMultiplier = TCSettings.damageMultiplier; @@ -64,13 +62,13 @@ public Treecapitator(EntityPlayer entityPlayer, TreeDefinition treeDef) numLeavesSheared = 1; } - public static boolean isBreakingPossible(EntityPlayer entityPlayer, Block block, int blockMetadata, boolean shouldLog) + public static boolean isBreakingPossible(EntityPlayer entityPlayer, BlockPos pos, boolean shouldLog) { ItemStack axe = entityPlayer.getCurrentEquippedItem(); - if ((isAxeItemEquipped(entityPlayer, block, blockMetadata) || !TCSettings.needItem)) + if ((isAxeItemEquipped(entityPlayer, pos) || !TCSettings.needItem)) { - if (!entityPlayer.capabilities.isCreativeMode && TCSettings.allowItemDamage && axe != null - && (axe.isItemStackDamageable() && (axe.getMaxDurability() - axe.getMetadata() <= TCSettings.damageMultiplier)) + if (!entityPlayer.capabilities.isCreativeMode && TCSettings.allowItemDamage && (axe != null) + && (axe.isItemStackDamageable() && ((axe.getMaxDamage() - axe.getMetadata()) <= TCSettings.damageMultiplier)) && !TCSettings.allowMoreBlocksThanDamage) { if (shouldLog) @@ -91,8 +89,8 @@ private boolean isBreakingPossible() axe = player.getCurrentEquippedItem(); if ((isAxeItemEquipped() || !TCSettings.needItem)) { - if (!player.capabilities.isCreativeMode && TCSettings.allowItemDamage && axe != null - && (axe.isItemStackDamageable() && (axe.getMaxDurability() - axe.getMetadata() <= TCSettings.damageMultiplier)) + if (!player.capabilities.isCreativeMode && TCSettings.allowItemDamage && (axe != null) + && (axe.isItemStackDamageable() && ((axe.getMaxDamage() - axe.getMetadata()) <= TCSettings.damageMultiplier)) && !TCSettings.allowMoreBlocksThanDamage) { TCLog.debug("Chopping disabled due to axe durability."); @@ -115,7 +113,7 @@ private boolean isAxeItemEquipped() if (TCSettings.enableEnchantmentMode) { - if (item != null && item.isItemEnchanted()) + if ((item != null) && item.isItemEnchanted()) for (int i = 0; i < item.getEnchantmentTagList().tagCount(); i++) { NBTTagCompound tag = item.getEnchantmentTagList().getCompoundTagAt(i); @@ -144,13 +142,13 @@ else if (ToolRegistry.instance().isAxe(item)) /** * Defines whether or not a player can break the block with current tool */ - public static boolean isAxeItemEquipped(EntityPlayer entityPlayer, Block block, int blockMetadata) + public static boolean isAxeItemEquipped(EntityPlayer entityPlayer, BlockPos pos) { ItemStack item = entityPlayer.getCurrentEquippedItem(); if (TCSettings.enableEnchantmentMode) { - if (item != null && item.isItemEnchanted()) + if ((item != null) && item.isItemEnchanted()) for (int i = 0; i < item.getEnchantmentTagList().tagCount(); i++) { NBTTagCompound tag = item.getEnchantmentTagList().getCompoundTagAt(i); @@ -162,8 +160,8 @@ public static boolean isAxeItemEquipped(EntityPlayer entityPlayer, Block block, } else { - if (item != null && !ToolRegistry.instance().isAxe(item) && TCSettings.allowAutoAxeDetection) - ToolRegistry.autoDetectAxe(item, block, blockMetadata); + if ((item != null) && !ToolRegistry.instance().isAxe(item) && TCSettings.allowAutoAxeDetection) + ToolRegistry.autoDetectAxe(entityPlayer.worldObj, pos, item); return ToolRegistry.instance().isAxe(item); } @@ -177,9 +175,9 @@ public static boolean isBreakingEnabled(EntityPlayer player) && !(player.capabilities.isCreativeMode && TCSettings.disableInCreative); } - public static int getTreeHeight(TreeDefinition tree, World world, int x, int y, int z, int md, EntityPlayer entityPlayer) + public static int getTreeHeight(TreeDefinition tree, World world, BlockPos pos, EntityPlayer entityPlayer) { - Coord startPos = new Coord(x, y, z); + BlockPos startPos = pos; if (!tree.onlyDestroyUpwards()) if (tree.useAdvancedTopLogLogic()) @@ -187,102 +185,38 @@ public static int getTreeHeight(TreeDefinition tree, World world, int x, int y, else startPos = getBottomLogAtPos(tree.getLogList(), world, startPos, false); - Coord topLog = tree.useAdvancedTopLogLogic() ? getTopLog(tree.getLogList(), world, new Coord(x, y, z), false) - : getTopLogAtPos(tree.getLogList(), world, new Coord(x, y, z), false); + BlockPos topLog = tree.useAdvancedTopLogLogic() ? getTopLog(tree.getLogList(), world, pos, false) + : getTopLogAtPos(tree.getLogList(), world, pos, false); - if (!tree.allowSmartTreeDetection() || tree.getLeafList().size() == 0 + if (!tree.allowSmartTreeDetection() || (tree.getLeafList().size() == 0) || hasXLeavesInDist(tree.getLeafList(), world, topLog, tree.maxLeafIDDist(), tree.minLeavesToID(), false)) - return topLog.y - startPos.y + 1; + return (topLog.getY() - startPos.getY()) + 1; return 1; } - public void onBlockHarvested(World world, int x, int y, int z, int md) + public void onBlockHarvested(World world, BlockPos pos) { if (!world.isRemote) { - TCLog.debug("In TreeCapitator.onBlockHarvested() " + x + ", " + y + ", " + z); + TCLog.debug("In TreeCapitator.onBlockHarvested() " + pos.toString()); this.world = world; - startPos = new Coord(x, y, z); - dropPos = startPos.clone(); + startPos = pos; + dropPos = startPos; drops = new ArrayList(); if (isBreakingEnabled(player)) { - Coord topLog = getTopLog(world, new Coord(x, y, z)); - if (!treeDef.allowSmartTreeDetection() || treeDef.getLeafList().size() == 0 + BlockPos topLog = getTopLog(world, pos); + if (!treeDef.allowSmartTreeDetection() || (treeDef.getLeafList().size() == 0) || hasXLeavesInDist(world, topLog, treeDef.maxLeafIDDist(), treeDef.minLeavesToID())) { if (isBreakingPossible()) { - long beginning = System.currentTimeMillis(); - TCLog.debug("Proceeding to chop tree..."); - LinkedList listFinal = new LinkedList(); - TCLog.debug("Finding log blocks..."); - long startTime = System.currentTimeMillis(); - LinkedList logs = addLogs(world, new Coord(x, y, z)); - TCLog.debug("Log Discovery: %dms", System.currentTimeMillis() - startTime); - if (logs.isEmpty() && maxAllowed) - return; - startTime = System.currentTimeMillis(); - addLogsAbove(world, new Coord(x, y, z), listFinal); - TCLog.debug("Final Logs: %dms", System.currentTimeMillis() - startTime); - - TCLog.debug("Destroying %d log blocks...", logs.size()); - startTime = System.currentTimeMillis(); - destroyBlocks(world, logs); - TCLog.debug("Log Destruction: %dms", System.currentTimeMillis() - startTime); - if (numLogsBroken > 1) - TCLog.debug("Number of logs broken: %d", numLogsBroken); - - if (TCSettings.destroyLeaves && treeDef.getLeafList().size() != 0) - { - TCLog.debug("Finding leaf blocks..."); - List leaves = new ArrayList(); - startTime = System.currentTimeMillis(); - for (Coord pos : listFinal) - { - addLeaves(world, pos, leaves); - } - TCLog.debug("Leaf Discovery: %dms", System.currentTimeMillis() - startTime); - TCLog.debug("Destroying %d leaf blocks...", leaves.size()); - startTime = System.currentTimeMillis(); - destroyBlocksWithChance(world, leaves, 0.5F, hasShearsInHotbar(player)); - TCLog.debug("Leaf Destruction: %dms", System.currentTimeMillis() - startTime); - - if (numLeavesSheared > 1) - TCLog.debug("Number of leaves sheared: %d", numLeavesSheared); - } - - /* - * Apply remaining damage if it rounds to a non-zero value - */ - if (currentAxeDamage > 0.0F && axe != null) - { - currentAxeDamage = Math.round(currentAxeDamage); - - for (int i = 0; i < MathHelper.floor_double(currentAxeDamage); i++) - axe.getItem().onBlockDestroyed(axe, world, treeDef.getLogList().get(0).getBlock(), x, y, z, player); - } - - if (currentShearsDamage > 0.0F && shears != null) - { - currentShearsDamage = Math.round(currentShearsDamage); - - for (int i = 0; i < Math.floor(currentShearsDamage); i++) - if (shears.getItem().equals(Items.shears)) - shears.damageItem(1, player); - else - shears.getItem().onBlockDestroyed(shears, world, treeDef.getLeafList().get(0).getBlock(), x, y, z, player); - } - - startTime = System.currentTimeMillis(); - if (TCSettings.stackDrops) - while (drops.size() > 0) - world.spawnEntityInWorld(new EntityItem(world, dropPos.x, dropPos.y, dropPos.z, drops.remove(0))); - TCLog.debug("Drops: %dms", System.currentTimeMillis() - startTime); - - TCLog.debug("Total: %dms", System.currentTimeMillis() - beginning); + // if (TCSettings.useTickBasedChopping) + // this.startTickingChop(pos); + // else + this.doProceduralChop(pos); } } else @@ -295,13 +229,97 @@ public void onBlockHarvested(World world, int x, int y, int z, int md) TCLog.debug("World is remote, skipping TreeCapitator.onBlockHarvested()."); } - public static List getLeavesForTree(World world, BlockID logID, Coord pos, boolean shouldLog) + // public void startTickingChop(BlockPos pos) + // { + // // TODO!!! + // } + // + // public class LogFinder + // { + // LinkedList listFinal; + // LinkedList logs; + // + // } + + public void doProceduralChop(BlockPos pos) + { + long beginning = System.currentTimeMillis(); + TCLog.debug("Proceeding to chop tree..."); + LinkedList listFinal = new LinkedList(); + TCLog.debug("Finding log blocks..."); + long startTime = System.currentTimeMillis(); + LinkedList logs = addLogs(world, pos); + TCLog.debug("Log Discovery: %dms", System.currentTimeMillis() - startTime); + if (logs.isEmpty() && maxAllowed) + return; + startTime = System.currentTimeMillis(); + addLogsAbove(world, pos, listFinal); + TCLog.debug("Final Logs: %dms", System.currentTimeMillis() - startTime); + + TCLog.debug("Destroying %d log blocks...", logs.size()); + startTime = System.currentTimeMillis(); + destroyBlocks(world, logs); + TCLog.debug("Log Destruction: %dms", System.currentTimeMillis() - startTime); + if (numLogsBroken > 1) + TCLog.debug("Number of logs broken: %d", numLogsBroken); + + if (TCSettings.destroyLeaves && (treeDef.getLeafList().size() != 0)) + { + TCLog.debug("Finding leaf blocks..."); + List leaves = new ArrayList(); + startTime = System.currentTimeMillis(); + for (BlockPos BlockPos : listFinal) + { + addLeaves(world, BlockPos, leaves); + } + TCLog.debug("Leaf Discovery: %dms", System.currentTimeMillis() - startTime); + TCLog.debug("Destroying %d leaf blocks...", leaves.size()); + startTime = System.currentTimeMillis(); + destroyBlocksWithChance(world, leaves, 0.5F, hasShearsInHotbar(player)); + TCLog.debug("Leaf Destruction: %dms", System.currentTimeMillis() - startTime); + + if (numLeavesSheared > 1) + TCLog.debug("Number of leaves sheared: %d", numLeavesSheared); + } + + /* + * Apply remaining damage if it rounds to a non-zero value + */ + if ((currentAxeDamage > 0.0F) && (axe != null)) + { + currentAxeDamage = Math.round(currentAxeDamage); + + for (int i = 0; i < MathHelper.floor_double(currentAxeDamage); i++) + axe.getItem().onBlockDestroyed(axe, world, treeDef.getLogList().get(0).getBlock(), pos, player); + } + + if ((currentShearsDamage > 0.0F) && (shears != null)) + { + currentShearsDamage = Math.round(currentShearsDamage); + + for (int i = 0; i < Math.floor(currentShearsDamage); i++) + if (shears.getItem().equals(Items.shears)) + shears.damageItem(1, player); + else + shears.getItem().onBlockDestroyed(shears, world, treeDef.getLeafList().get(0).getBlock(), pos, player); + } + + startTime = System.currentTimeMillis(); + if (TCSettings.stackDrops) + while (drops.size() > 0) + world.spawnEntityInWorld(new EntityItem(world, dropPos.getX(), dropPos.getY(), dropPos.getZ(), drops.remove(0))); + TCLog.debug("Drops: %dms", System.currentTimeMillis() - startTime); + + TCLog.debug("Total: %dms", System.currentTimeMillis() - beginning); + } + + public static List getLeavesForTree(World world, BlockID logID, BlockPos pos, boolean shouldLog) { List leaves = new ArrayList(); List logs = new ArrayList(); logs.add(logID); - Coord topLogPos; + BlockPos topLogPos; if (TCSettings.useAdvancedTopLogLogic) topLogPos = getTopLog(logs, world, pos, shouldLog); else @@ -312,7 +330,7 @@ public static List getLeavesForTree(World world, BlockID logID, Coord p return leaves; } - private static List getLeavesInDist(World world, Coord pos, int range, boolean shouldLog) + private static List getLeavesInDist(World world, BlockPos pos, int range, boolean shouldLog) { if (shouldLog) TCLog.debug("Attempting to identify tree..."); @@ -323,13 +341,14 @@ private static List getLeavesInDist(World world, Coord pos, int range, // lower bound kept at -1 for (int y = -1; y <= range; y++) for (int z = -range; z <= range; z++) - if (x != 0 || y != 0 || z != 0) + if ((x != 0) || (y != 0) || (z != 0)) { - if (!world.isAirBlock(pos.x + x, pos.y + y, pos.z + z)) + BlockPos pos2 = pos.add(new BlockPos(x, y, z)); + if (!world.isAirBlock(pos2)) { - Block block = world.getBlock(pos.x + x, pos.y + y, pos.z + z); - ModulusBlockID blockID = new ModulusBlockID(world, pos.x + x, pos.y + y, pos.z + z, 8); - if (block.isLeaves(world, pos.x + x, pos.y + y, pos.z + z)) + Block block = world.getBlockState(pos2).getBlock(); + ModulusBlockID blockID = new ModulusBlockID(world, pos2, 8); + if (block.isLeaves(world, pos2)) { if (shouldLog) TCLog.debug("Found leaf block: %s", blockID); @@ -347,7 +366,7 @@ else if (shouldLog) return leaves; } - private Coord getTopLog(World world, Coord pos) + private BlockPos getTopLog(World world, BlockPos pos) { if (treeDef.useAdvancedTopLogLogic()) return getTopLog(treeDef.getLogList(), world, pos, true); @@ -355,129 +374,129 @@ private Coord getTopLog(World world, Coord pos) return getTopLogAtPos(treeDef.getLogList(), world, pos, true); } - private static Coord getTopLog(List logBlocks, World world, Coord pos, boolean shouldLog) + private static BlockPos getTopLog(List logBlocks, World world, BlockPos pos, boolean shouldLog) { - LinkedList topLogs = new LinkedList(); - HashSet processed = new HashSet(); - Coord topLog = pos.clone(); + LinkedList topLogs = new LinkedList(); + HashSet processed = new HashSet(); + BlockPos topLog = pos; topLogs.add(getTopLogAtPos(logBlocks, world, topLog, false)); while (topLogs.size() > 0) { - Coord nextLog = topLogs.pollFirst(); + BlockPos nextLog = topLogs.pollFirst(); processed.add(nextLog); // if the new pos is higher than what we've seen so far, save it as the new top log - if (nextLog.y > topLog.y) + if (nextLog.getY() > topLog.getY()) topLog = nextLog; int currentSize = topLogs.size(); - Coord newPos; + BlockPos newPos; for (int x = -1; x <= 1; x++) for (int z = -1; z <= 1; z++) - if ((x != 0 || z != 0) && logBlocks.contains(new BlockID(world, nextLog.x + x, nextLog.y + 1, nextLog.z + z))) - { - newPos = nextLog.add(new Coord(x, 1, z)); - if (!topLogs.contains(newPos) && !processed.contains(newPos)) - topLogs.add(getTopLogAtPos(logBlocks, world, newPos, false)); - } + { + newPos = new BlockPos(x, 1, z).add(nextLog); + if (((x != 0) || (z != 0)) && logBlocks.contains(new BlockID(world, newPos)) + && !topLogs.contains(newPos) && !processed.contains(newPos)) + topLogs.add(getTopLogAtPos(logBlocks, world, newPos, false)); + } // check if we found anything if (topLogs.size() == currentSize) { for (int x = -1; x <= 1; x++) for (int z = -1; z <= 1; z++) - if ((x != 0 || z != 0) && logBlocks.contains(new BlockID(world, nextLog.x + x, nextLog.y, nextLog.z + z))) - { - newPos = nextLog.add(new Coord(x, 0, z)); - if (!topLogs.contains(newPos) && !processed.contains(newPos)) - topLogs.add(getTopLogAtPos(logBlocks, world, newPos, false)); - } + { + newPos = new BlockPos(x, 0, z).add(nextLog); + if (((x != 0) || (z != 0)) && logBlocks.contains(new BlockID(world, newPos)) + && !topLogs.contains(newPos) && !processed.contains(newPos)) + topLogs.add(getTopLogAtPos(logBlocks, world, newPos, false)); + } } } if (shouldLog) - TCLog.debug("Top Log: " + pos.x + ", " + pos.y + ", " + pos.z); + TCLog.debug("Top Log: " + pos.toString()); return topLog; } - private static Coord getTopLogAtPos(List logBlocks, World world, Coord pos, boolean shouldLog) + private static BlockPos getTopLogAtPos(List logBlocks, World world, BlockPos pos, boolean shouldLog) { - while (logBlocks.contains(new BlockID(world, pos.x, pos.y + 1, pos.z))) - pos.y++; + while (logBlocks.contains(new BlockID(world, pos.up()))) + pos = pos.up(); if (shouldLog) - TCLog.debug("Top Log: " + pos.x + ", " + pos.y + ", " + pos.z); + TCLog.debug("Top Log: " + pos.toString()); - return pos.clone(); + return pos; } - private static Coord getBottomLog(List logBlocks, World world, Coord pos, boolean shouldLog) + private static BlockPos getBottomLog(List logBlocks, World world, BlockPos pos, boolean shouldLog) { - LinkedList bottomLogs = new LinkedList(); - HashSet processed = new HashSet(); - Coord bottomLog = pos.clone(); + LinkedList bottomLogs = new LinkedList(); + HashSet processed = new HashSet(); + BlockPos bottomLog = pos; bottomLogs.add(getBottomLogAtPos(logBlocks, world, bottomLog, false)); while (bottomLogs.size() > 0) { - Coord nextLog = bottomLogs.pollFirst(); + BlockPos nextLog = bottomLogs.pollFirst(); processed.add(nextLog); // if the new pos is lower than what we've seen so far, save it as the new bottom log - if (nextLog.y < bottomLog.y) + if (nextLog.getY() < bottomLog.getY()) bottomLog = nextLog; int currentSize = bottomLogs.size(); - Coord newPos; + BlockPos newPos; for (int x = -1; x <= 1; x++) for (int z = -1; z <= 1; z++) - if ((x != 0 || z != 0) && logBlocks.contains(new BlockID(world, nextLog.x + x, nextLog.y - 1, nextLog.z + z))) - { - newPos = new Coord(nextLog.x + x, nextLog.y - 1, nextLog.z + z); - if (!bottomLogs.contains(newPos) && !processed.contains(newPos)) - bottomLogs.add(getBottomLogAtPos(logBlocks, world, newPos, false)); - } + { + newPos = new BlockPos(x, -1, z).add(nextLog); + if (((x != 0) || (z != 0)) && logBlocks.contains(new BlockID(world, newPos)) + && !bottomLogs.contains(newPos) && !processed.contains(newPos)) + bottomLogs.add(getBottomLogAtPos(logBlocks, world, newPos, false)); + } - // check if we found anything before adding adjacent coords + // check if we found anything before adding adjacent BlockPoss if (bottomLogs.size() == currentSize) { for (int x = -1; x <= 1; x++) for (int z = -1; z <= 1; z++) - if ((x != 0 || z != 0) && logBlocks.contains(new BlockID(world, nextLog.x + x, nextLog.y, nextLog.z + z))) - { - newPos = new Coord(nextLog.x + x, nextLog.y, nextLog.z + z); - if (!bottomLogs.contains(newPos) && !processed.contains(newPos)) - bottomLogs.add(getBottomLogAtPos(logBlocks, world, newPos, false)); - } + { + newPos = new BlockPos(x, 0, z).add(nextLog); + if (((x != 0) || (z != 0)) && logBlocks.contains(new BlockID(world, newPos)) + && !bottomLogs.contains(newPos) && !processed.contains(newPos)) + bottomLogs.add(getBottomLogAtPos(logBlocks, world, newPos, false)); + } } } if (shouldLog) - TCLog.debug("Bottom Log: " + pos.x + ", " + pos.y + ", " + pos.z); + TCLog.debug("Bottom Log: " + pos.toString()); return bottomLog; } - private static Coord getBottomLogAtPos(List logBlocks, World world, Coord pos, boolean shouldLog) + private static BlockPos getBottomLogAtPos(List logBlocks, World world, BlockPos pos, boolean shouldLog) { - while (logBlocks.contains(new BlockID(world, pos.x, pos.y - 1, pos.z))) - pos.y--; + while (logBlocks.contains(new BlockID(world, pos.down()))) + pos = pos.down(); if (shouldLog) - TCLog.debug("Bottom Log: " + pos.x + ", " + pos.y + ", " + pos.z); + TCLog.debug("Bottom Log: " + pos.toString()); return pos; } - private static boolean hasXLeavesInDist(List leafBlocks, World world, Coord pos, int range, int limit, boolean shouldLog) + private static boolean hasXLeavesInDist(List leafBlocks, World world, BlockPos pos, int range, int limit, boolean shouldLog) { if (shouldLog) TCLog.debug("Attempting to identify tree..."); @@ -487,9 +506,10 @@ private static boolean hasXLeavesInDist(List leafBlocks, World world, C // lower bound kept at -1 for (int y = -1; y <= range; y++) for (int z = -range; z <= range; z++) - if (x != 0 || y != 0 || z != 0) + if ((x != 0) || (y != 0) || (z != 0)) { - BlockID blockID = new BlockID(world, pos.x + x, pos.y + y, pos.z + z); + BlockPos otherPos = new BlockPos(x, y, z).add(pos); + BlockID blockID = new BlockID(world, otherPos); if (blockID.isValid()) if (isLeafBlock(leafBlocks, blockID)) { @@ -510,7 +530,7 @@ else if (shouldLog) return false; } - private boolean hasXLeavesInDist(World world, Coord pos, int range, int limit) + private boolean hasXLeavesInDist(World world, BlockPos pos, int range, int limit) { return hasXLeavesInDist(treeDef.getLeafList(), world, pos, range, limit, true); } @@ -532,7 +552,7 @@ private int shearsHotbarIndex(EntityPlayer entityPlayer) { ItemStack item = entityPlayer.inventory.mainInventory[i]; - if (item != null && item.stackSize > 0 && ToolRegistry.instance().isShears(item)) + if ((item != null) && (item.stackSize > 0) && ToolRegistry.instance().isShears(item)) { shears = item; return i; @@ -552,20 +572,21 @@ public boolean isLeafBlock(BlockID blockID) return isLeafBlock(treeDef.getLeafList(), blockID); } - private void destroyBlocks(World world, LinkedList list) + private void destroyBlocks(World world, LinkedList list) { destroyBlocksWithChance(world, list, 1.0F, false); } - private void destroyBlocksWithChance(World world, List list, float f, boolean canShear) + private void destroyBlocksWithChance(World world, List list, float f, boolean canShear) { while (list.size() > 0) { - Coord pos = list.remove(0); - Block block = world.getBlock(pos.x, pos.y, pos.z); - if (!block.isAir(world, pos.x, pos.y, pos.z)) + BlockPos pos = list.remove(0); + IBlockState state = world.getBlockState(pos); + Block block = state.getBlock(); + if (!block.isAir(world, pos)) { - int metadata = world.getBlockMetadata(pos.x, pos.y, pos.z); + int metadata = block.getMetaFromState(state); BlockID blockID = new BlockID(block, metadata); if ((block instanceof IShearable) && (((vineID.equals(blockID) && TCSettings.shearVines) @@ -573,9 +594,9 @@ private void destroyBlocksWithChance(World world, List list, float f, boo && !(player.capabilities.isCreativeMode && TCSettings.disableCreativeDrops)) { IShearable target = (IShearable) block; - if (target.isShearable(shears, world, pos.x, pos.y, pos.z)) + if (target.isShearable(shears, world, pos)) { - ArrayList drops = target.onSheared(shears, player.worldObj, pos.x, pos.y, pos.z, + List drops = target.onSheared(shears, player.worldObj, pos, EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, shears)); if (drops != null) @@ -584,18 +605,18 @@ private void destroyBlocksWithChance(World world, List list, float f, boo addDrops(drops); else if (TCSettings.itemsDropInPlace) for (ItemStack itemStack : drops) - world.spawnEntityInWorld(new EntityItem(world, pos.x, pos.y, pos.z, itemStack)); + world.spawnEntityInWorld(new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), itemStack)); else for (ItemStack itemStack : drops) - world.spawnEntityInWorld(new EntityItem(world, startPos.x, startPos.y, startPos.z, itemStack)); + world.spawnEntityInWorld(new EntityItem(world, startPos.getX(), startPos.getY(), startPos.getZ(), itemStack)); } - if (TCSettings.allowItemDamage && !player.capabilities.isCreativeMode && shears != null && shears.stackSize > 0) + if (TCSettings.allowItemDamage && !player.capabilities.isCreativeMode && (shears != null) && (shears.stackSize > 0)) { - canShear = damageShearsAndContinue(world, block, pos.x, pos.y, pos.z); + canShear = damageShearsAndContinue(world, block, pos); numLeavesSheared++; - if (canShear && TCSettings.useIncreasingItemDamage && numLeavesSheared % TCSettings.increaseDamageEveryXBlocks == 0) + if (canShear && TCSettings.useIncreasingItemDamage && ((numLeavesSheared % TCSettings.increaseDamageEveryXBlocks) == 0)) leafDamageMultiplier += TCSettings.damageIncreaseAmount; } } @@ -605,27 +626,27 @@ else if (!(player.capabilities.isCreativeMode && TCSettings.disableCreativeDrops if (TCSettings.stackDrops) addDrop(block, metadata, pos); else if (TCSettings.itemsDropInPlace) - block.dropBlockAsItem(world, pos.x, pos.y, pos.z, metadata, EnchantmentHelper.getFortuneModifier(player)); + block.dropBlockAsItem(world, pos, world.getBlockState(pos), EnchantmentHelper.getFortuneModifier(player)); else - block.dropBlockAsItem(world, startPos.x, startPos.y, startPos.z, metadata, EnchantmentHelper.getFortuneModifier(player)); + block.dropBlockAsItem(world, startPos, world.getBlockState(pos), EnchantmentHelper.getFortuneModifier(player)); - if (TCSettings.allowItemDamage && !player.capabilities.isCreativeMode && axe != null && axe.stackSize > 0 + if (TCSettings.allowItemDamage && !player.capabilities.isCreativeMode && (axe != null) && (axe.stackSize > 0) && !vineID.equals(new BlockID(block, metadata)) && !isLeafBlock(new BlockID(block, metadata)) && !pos.equals(startPos)) { - if (!damageAxeAndContinue(world, block, startPos.x, startPos.y, startPos.z)) + if (!damageAxeAndContinue(world, block, startPos)) list.clear(); numLogsBroken++; - if (TCSettings.useIncreasingItemDamage && numLogsBroken % TCSettings.increaseDamageEveryXBlocks == 0) + if (TCSettings.useIncreasingItemDamage && ((numLogsBroken % TCSettings.increaseDamageEveryXBlocks) == 0)) logDamageMultiplier += TCSettings.damageIncreaseAmount; } } - if (world.getTileEntity(pos.x, pos.y, pos.z) != null) - world.removeTileEntity(pos.x, pos.y, pos.z); + if (world.getTileEntity(pos) != null) + world.removeTileEntity(pos); - world.setBlockToAir(pos.x, pos.y, pos.z); + world.setBlockToAir(pos); // Can't believe it took this long to realize this wasn't being done... player.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(block)], 1); @@ -634,20 +655,21 @@ else if (TCSettings.itemsDropInPlace) } } - private void addDrop(Block block, int metadata, Coord pos) + private void addDrop(Block block, int metadata, BlockPos pos) { List stacks = null; - dropPos = TCSettings.itemsDropInPlace ? pos.clone() : startPos.clone(); + dropPos = TCSettings.itemsDropInPlace ? pos : startPos; + IBlockState state = world.getBlockState(pos); - if ((block.canSilkHarvest(world, player, pos.x, pos.y, pos.z, metadata) && EnchantmentHelper.getSilkTouchModifier(player))) + if ((block.canSilkHarvest(world, pos, state, player) && EnchantmentHelper.getSilkTouchModifier(player))) { stacks = new ArrayList(); stacks.add(new ItemStack(block, 1, metadata)); } else { - stacks = block.getDrops(world, pos.x, pos.y, pos.z, metadata, EnchantmentHelper.getFortuneModifier(player)); + stacks = block.getDrops(world, pos, state, EnchantmentHelper.getFortuneModifier(player)); } addDrops(stacks); @@ -688,7 +710,7 @@ private void addDrops(List stacks) { int i = drop.stackSize - drop.getMaxStackSize(); drop.stackSize = drop.getMaxStackSize(); - world.spawnEntityInWorld(new EntityItem(world, dropPos.x, dropPos.y, dropPos.z, drop)); + world.spawnEntityInWorld(new EntityItem(world, dropPos.getX(), dropPos.getY(), dropPos.getZ(), drop)); if (i > 0) drop.stackSize = i; else @@ -700,18 +722,18 @@ private void addDrops(List stacks) /** * Damages the axe-type item and returns true if we should continue destroying logs */ - private boolean damageAxeAndContinue(World world, Block block, int x, int y, int z) + private boolean damageAxeAndContinue(World world, Block block, BlockPos pos) { if (axe != null) { currentAxeDamage += logDamageMultiplier; for (int i = 0; i < (int) Math.floor(currentAxeDamage); i++) - axe.getItem().onBlockDestroyed(axe, world, block, x, y, z, player); + axe.getItem().onBlockDestroyed(axe, world, block, pos, player); currentAxeDamage -= Math.floor(currentAxeDamage); - if (axe != null && axe.stackSize < 1) + if ((axe != null) && (axe.stackSize < 1)) player.destroyCurrentEquippedItem(); } return !TCSettings.needItem || TCSettings.allowMoreBlocksThanDamage || isAxeItemEquipped(); @@ -720,7 +742,7 @@ private boolean damageAxeAndContinue(World world, Block block, int x, int y, int /** * Damages the shear-type item and returns true if we should continue shearing leaves/vines */ - private boolean damageShearsAndContinue(World world, Block block, int x, int y, int z) + private boolean damageShearsAndContinue(World world, Block block, BlockPos pos) { if (shears != null) { @@ -732,43 +754,43 @@ private boolean damageShearsAndContinue(World world, Block block, int x, int y, if (shears.getItem().equals(Items.shears)) shears.damageItem(1, player); else - shears.getItem().onBlockDestroyed(shears, world, block, x, y, z, player); + shears.getItem().onBlockDestroyed(shears, world, block, pos, player); currentShearsDamage -= Math.floor(currentShearsDamage); - if (shears != null && shears.stackSize < 1 && shearsIndex != -1) + if ((shears != null) && (shears.stackSize < 1) && (shearsIndex != -1)) player.inventory.setInventorySlotContents(shearsIndex, (ItemStack) null); } return TCSettings.allowMoreBlocksThanDamage || hasShearsInHotbar(player); } - private LinkedList addLogs(World world, Coord pos) + private LinkedList addLogs(World world, BlockPos pos) { - int index = 0, lowY = pos.y, x, y, z; - LinkedList list = new LinkedList(); - Coord newPos; + int index = 0, lowY = pos.getY(), x, y, z; + LinkedList list = new LinkedList(); + BlockPos newPos; list.add(pos); do { - Coord currentLog = list.get(index); + BlockPos currentLog = list.get(index); for (x = -1; x <= 1; x++) for (y = (treeDef.onlyDestroyUpwards() ? 0 : -1); y <= 1; y++) for (z = -1; z <= 1; z++) - if (!world.isAirBlock(currentLog.x + x, currentLog.y + y, currentLog.z + z)) - if (treeDef.getLogList().contains(new BlockID(world, currentLog.x + x, currentLog.y + y, currentLog.z + z))) + { + newPos = currentLog.add(x, y, z); + if (!world.isAirBlock(newPos)) + if (treeDef.getLogList().contains(new BlockID(world, newPos))) { - newPos = new Coord(currentLog.x + x, currentLog.y + y, currentLog.z + z); - - if (treeDef.maxHorLogBreakDist() == -1 || (Math.abs(newPos.x - startPos.x) <= treeDef.maxHorLogBreakDist() - && Math.abs(newPos.z - startPos.z) <= treeDef.maxHorLogBreakDist()) - && (treeDef.maxVerLogBreakDist() == -1 || (Math.abs(newPos.y - startPos.y) <= treeDef.maxVerLogBreakDist())) - && !list.contains(newPos) && (newPos.y >= lowY || !treeDef.onlyDestroyUpwards())) + if ((treeDef.maxHorLogBreakDist() == -1) || (((Math.abs(newPos.getX() - startPos.getX()) <= treeDef.maxHorLogBreakDist()) + && (Math.abs(newPos.getZ() - startPos.getZ()) <= treeDef.maxHorLogBreakDist())) + && ((treeDef.maxVerLogBreakDist() == -1) || (Math.abs(newPos.getY() - startPos.getY()) <= treeDef.maxVerLogBreakDist())) + && !list.contains(newPos) && ((newPos.getY() >= lowY) || !treeDef.onlyDestroyUpwards()))) { list.add(newPos); - if (TCSettings.maxNumberOfBlocksInTree != -1 && ++this.numLogsToBreak > TCSettings.maxNumberOfBlocksInTree) + if ((TCSettings.maxNumberOfBlocksInTree != -1) && (++numLogsToBreak > TCSettings.maxNumberOfBlocksInTree)) { list.clear(); TCLog.debug("Number of logs in tree is more than the maximum number allowed."); @@ -777,6 +799,7 @@ private LinkedList addLogs(World world, Coord pos) } } } + } } while (++index < list.size()); @@ -786,11 +809,11 @@ private LinkedList addLogs(World world, Coord pos) return list; } - private void addLogsAbove(World world, Coord position, List listFinal) + private void addLogsAbove(World world, BlockPos position, List listFinal) { - List listAbove = new ArrayList(); - List list; - Coord newPosition; + List listAbove = new ArrayList(); + List list; + BlockPos newPosition; int counter, index, x, z; listAbove.add(position); @@ -798,20 +821,23 @@ private void addLogsAbove(World world, Coord position, List listFinal) do { list = listAbove; - listAbove = new ArrayList(); + listAbove = new ArrayList(); - for (Coord pos : list) + for (BlockPos pos : list) { counter = 0; for (x = -1; x <= 1; x++) for (z = -1; z <= 1; z++) - if (treeDef.getLogList().contains(new BlockID(world, pos.x + x, pos.y + 1, pos.z + z))) + { + newPosition = pos.add(x, 1, z); + if (treeDef.getLogList().contains(new BlockID(world, newPosition))) { - if (!listAbove.contains(newPosition = new Coord(pos.x + x, pos.y + 1, pos.z + z))) + if (!listAbove.contains(newPosition)) listAbove.add(newPosition); counter++; } + } if (counter == 0) listFinal.add(pos); @@ -820,37 +846,39 @@ private void addLogsAbove(World world, Coord position, List listFinal) index = -1; while (++index < listAbove.size()) { - Coord pos = listAbove.get(index); + BlockPos pos = listAbove.get(index); for (x = -1; x <= 1; x++) for (z = -1; z <= 1; z++) - if (treeDef.getLogList().contains(new BlockID(world, pos.x + x, pos.y, pos.z + z))) - if (!listAbove.contains(newPosition = new Coord(pos.x + x, pos.y, pos.z + z))) - listAbove.add(newPosition); + { + newPosition = pos.add(x, 0, z); + if (treeDef.getLogList().contains(new BlockID(world, newPosition)) && !listAbove.contains(newPosition)) + listAbove.add(newPosition); + } } } while (listAbove.size() > 0); } - public List addLeaves(World world, Coord pos, List list) + public List addLeaves(World world, BlockPos pos, List list) { int index = -1; if (list == null) - list = new ArrayList(); + list = new ArrayList(); addLeavesInDistance(world, pos, treeDef.maxHorLeafBreakDist(), list); while (++index < list.size()) { - Coord pos2 = list.get(index); - if (treeDef.maxHorLeafBreakDist() == -1 || CommonUtils.getHorSquaredDistance(pos, pos2) <= treeDef.maxHorLeafBreakDist()) + BlockPos pos2 = list.get(index); + if ((treeDef.maxHorLeafBreakDist() == -1) || (CommonUtils.getHorSquaredDistance(pos, pos2) <= treeDef.maxHorLeafBreakDist())) addLeavesInDistance(world, pos2, 1, list); } return list; } - public void addLeavesInDistance(World world, Coord pos, int range, List list) + public void addLeavesInDistance(World world, BlockPos pos, int range, List list) { if (range == -1) range = 4; @@ -859,32 +887,31 @@ public void addLeavesInDistance(World world, Coord pos, int range, List l for (int y = -range; y <= range; y++) for (int z = -range; z <= range; z++) { - Block block = world.getBlock(x + pos.x, y + pos.y, z + pos.z); - int md = world.getBlockMetadata(x + pos.x, y + pos.y, z + pos.z); - if (isLeafBlock(new BlockID(block, md)) || vineID.equals(new BlockID(block))) - { - if (!treeDef.requireLeafDecayCheck() || ((md & 8) != 0 && (md & 4) == 0)) - { - Coord newPos = new Coord(x + pos.x, y + pos.y, z + pos.z); - if (!list.contains(newPos) && !hasLogClose(world, newPos, 1)) - list.add(newPos); - } - } + BlockPos newPos = pos.add(x, y, z); + if (world.isAirBlock(newPos)) + continue; + IBlockState state = world.getBlockState(newPos); + Block block = state.getBlock(); + int md = block.getMetaFromState(state); + if ((isLeafBlock(new BlockID(block, md)) || vineID.equals(new BlockID(block))) + && (!treeDef.requireLeafDecayCheck() || (((md & 8) != 0) && ((md & 4) == 0))) + && !list.contains(newPos) && !hasLogClose(world, newPos, 1)) + list.add(newPos); } } /** * Returns true if a log block is within i blocks of pos */ - public boolean hasLogClose(World world, Coord pos, int i) + public boolean hasLogClose(World world, BlockPos pos, int i) { for (int x = -i; x <= i; x++) for (int y = -i; y <= i; y++) for (int z = -i; z <= i; z++) { - Coord neighborPos = new Coord(x + pos.x, y + pos.y, z + pos.z); - if ((x != 0 || y != 0 || z != 0) && !neighborPos.isAirBlock(world) && - treeDef.getLogList().contains(new BlockID(world, neighborPos.x, neighborPos.y, neighborPos.z)) + BlockPos neighborPos = pos.add(x, y, z); + if (((x != 0) || (y != 0) || (z != 0)) && !world.isAirBlock(neighborPos) && + treeDef.getLogList().contains(new BlockID(world, neighborPos)) && !neighborPos.equals(startPos)) return true; } diff --git a/src/main/java/bspkrs/treecapitator/TreecapitatorMod.java b/src/main/java/bspkrs/treecapitator/TreecapitatorMod.java index a6be58b..41060d8 100644 --- a/src/main/java/bspkrs/treecapitator/TreecapitatorMod.java +++ b/src/main/java/bspkrs/treecapitator/TreecapitatorMod.java @@ -15,18 +15,18 @@ import bspkrs.util.CommonUtils; import bspkrs.util.Const; import bspkrs.util.ModVersionChecker; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.Mod.EventHandler; -import cpw.mods.fml.common.Mod.Instance; -import cpw.mods.fml.common.Mod.Metadata; -import cpw.mods.fml.common.ModMetadata; -import cpw.mods.fml.common.SidedProxy; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent; -import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.Mod.EventHandler; +import net.minecraftforge.fml.common.Mod.Instance; +import net.minecraftforge.fml.common.Mod.Metadata; +import net.minecraftforge.fml.common.ModMetadata; +import net.minecraftforge.fml.common.SidedProxy; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLInterModComms.IMCEvent; +import net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; @Mod(modid = Reference.MODID, name = Reference.NAME, version = "@MOD_VERSION@", dependencies = "required-after:bspkrsCore@[@BSCORE_VERSION@,)", useMetadata = true, guiFactory = Reference.GUI_FACTORY) diff --git a/src/main/java/bspkrs/treecapitator/config/TCConfigHandler.java b/src/main/java/bspkrs/treecapitator/config/TCConfigHandler.java index 3966f81..f985ec2 100644 --- a/src/main/java/bspkrs/treecapitator/config/TCConfigHandler.java +++ b/src/main/java/bspkrs/treecapitator/config/TCConfigHandler.java @@ -5,12 +5,12 @@ import java.util.Date; import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import bspkrs.treecapitator.TreecapitatorMod; import bspkrs.treecapitator.registry.ModConfigRegistry; import bspkrs.treecapitator.util.Reference; import bspkrs.treecapitator.util.TCLog; -import cpw.mods.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class TCConfigHandler { @@ -42,8 +42,7 @@ private TCConfigHandler() private TCConfigHandler(File file) { this(); - this.fileRef = file; - TCLog.info("Loading configuration file %s", file.getAbsolutePath()); + fileRef = file; try { config = new Configuration(fileRef, Reference.CONFIG_VERSION); @@ -79,7 +78,7 @@ public Configuration getConfig() public void setShouldRefreshRegistries(boolean bol) { - this.shouldRefreshRegistries = bol; + shouldRefreshRegistries = bol; } public void syncConfig() @@ -117,7 +116,7 @@ public void syncConfig(boolean init) oldConfig = null; } - if (this.shouldRefreshRegistries) + if (shouldRefreshRegistries) { ModConfigRegistry.instance().applyPrioritizedModConfigs(); TreecapitatorMod.instance.nbtManager().saveAllCurrentObjectsToLocalNBT(); diff --git a/src/main/java/bspkrs/treecapitator/config/TCSettings.java b/src/main/java/bspkrs/treecapitator/config/TCSettings.java index b672a0c..7665d7c 100644 --- a/src/main/java/bspkrs/treecapitator/config/TCSettings.java +++ b/src/main/java/bspkrs/treecapitator/config/TCSettings.java @@ -62,6 +62,10 @@ public final class TCSettings public static boolean useIncreasingItemDamage = useIncreasingItemDamageDefault; private final static boolean useStrictBlockPairingDefault = true; public static boolean useStrictBlockPairing = useStrictBlockPairingDefault; + // private final static boolean useTickBasedChoppingDefault = true; + // public static boolean useTickBasedChopping = useTickBasedChoppingDefault; + // private final static int blocksPerTickDefault = 640; + // public static int blocksPerTick = blocksPerTickDefault; // Per-tree private final static boolean allowSmartTreeDetectionDefault = true; @@ -127,10 +131,8 @@ private TCSettings() public void handleEnchantmentID(int id) { - if (id >= 0 && id < 256 && enableEnchantmentMode) + if ((id >= 0) && (id < 256) && enableEnchantmentMode) { - if (Enchantment.enchantmentsList[enchantmentID] != null) - Enchantment.enchantmentsList[enchantmentID] = null; enchantmentID = id; treecapitating = new EnchantmentTreecapitating(enchantmentID, enchantmentWeight); treecapitating.setName("treecapitating"); @@ -179,6 +181,8 @@ public void readFromNBT(NBTTagCompound ntc) useAdvancedTopLogLogic = ntc.getBoolean(Reference.USE_ADV_TOP_LOG_LOGIC); useIncreasingItemDamage = ntc.getBoolean(Reference.USE_INCREASING_ITEM_DAMAGE); useStrictBlockPairing = ntc.getBoolean(Reference.USE_STRICT_BLOCK_PAIRING); + // useTickBasedChopping = ntc.getBoolean(Reference.USE_TICK_BASED_CHOPPING); + // blocksPerTick = ntc.getInteger(Reference.BLOCKS_PER_TICK); } public void writeToNBT(NBTTagCompound ntc) @@ -221,6 +225,8 @@ public void writeToNBT(NBTTagCompound ntc) ntc.setBoolean(Reference.USE_ADV_TOP_LOG_LOGIC, useAdvancedTopLogLogic); ntc.setBoolean(Reference.USE_INCREASING_ITEM_DAMAGE, useIncreasingItemDamage); ntc.setBoolean(Reference.USE_STRICT_BLOCK_PAIRING, useStrictBlockPairing); + // ntc.setBoolean(Reference.USE_TICK_BASED_CHOPPING, useTickBasedChopping); + // ntc.setInteger(Reference.BLOCKS_PER_TICK, blocksPerTick); } /** @@ -308,6 +314,12 @@ public void syncConfiguration(Configuration config) orderedKeys = new ArrayList(); // Tree Chop Behavior settings + // useTickBasedChopping = config.getBoolean(Reference.USE_TICK_BASED_CHOPPING, Reference.CTGY_TREE_CHOP_BEHAVIOR, + // useTickBasedChoppingDefault, Reference.useTickBasedChoppingDesc, Reference.LANG_KEY_BASE + Reference.USE_TICK_BASED_CHOPPING); + // orderedKeys.add(Reference.USE_TICK_BASED_CHOPPING); + // blocksPerTick = config.getInt(Reference.BLOCKS_PER_TICK, Reference.CTGY_TREE_CHOP_BEHAVIOR, + // blocksPerTickDefault, 1, 64000, Reference.blocksPerTickDesc, Reference.LANG_KEY_BASE + Reference.BLOCKS_PER_TICK); + // orderedKeys.add(Reference.BLOCKS_PER_TICK); allowAutoTreeDetection = config.getBoolean(Reference.ALLOW_AUTO_TREE_DETECT, Reference.CTGY_TREE_CHOP_BEHAVIOR, allowAutoTreeDetectionDefault, Reference.allowAutoTreeDetectionDesc, Reference.LANG_KEY_BASE + Reference.ALLOW_AUTO_TREE_DETECT); orderedKeys.add(Reference.ALLOW_AUTO_TREE_DETECT); @@ -371,7 +383,8 @@ public void syncConfiguration(Configuration config) enableEnchantmentModeDefault, Reference.enableEnchantmentModeDesc, Reference.LANG_KEY_BASE + Reference.ENABLE_ENCHANT_MODE); orderedKeys.add(Reference.ENABLE_ENCHANT_MODE); handleEnchantmentID(config.getInt(Reference.ENCHANT_ID, Reference.CTGY_ENCHANTMENT_MODE, - enchantmentIDDefault, 0, Enchantment.enchantmentsList.length - 1, Reference.enchantmentIDDesc, Reference.LANG_KEY_BASE + Reference.ENCHANT_ID)); + enchantmentIDDefault, 0, 255, Reference.enchantmentIDDesc, Reference.LANG_KEY_BASE + Reference.ENCHANT_ID)); + config.getCategory(Reference.CTGY_ENCHANTMENT_MODE).get(Reference.ENCHANT_ID).setRequiresMcRestart(true); orderedKeys.add(Reference.ENCHANT_ID); requireItemInAxeListForEnchant = config.getBoolean(Reference.REQ_ITEM_IN_AXE_LIST_ENCHANT, Reference.CTGY_ENCHANTMENT_MODE, requireItemInAxeListForEnchantDefault, Reference.requireItemInAxeListForEnchantDesc, Reference.LANG_KEY_BASE + Reference.REQ_ITEM_IN_AXE_LIST_ENCHANT); diff --git a/src/main/java/bspkrs/treecapitator/fml/gui/GuiConfigCustomCategoryListEntry.java b/src/main/java/bspkrs/treecapitator/fml/gui/GuiConfigCustomCategoryListEntry.java index 731a7ab..c54f48d 100644 --- a/src/main/java/bspkrs/treecapitator/fml/gui/GuiConfigCustomCategoryListEntry.java +++ b/src/main/java/bspkrs/treecapitator/fml/gui/GuiConfigCustomCategoryListEntry.java @@ -2,28 +2,27 @@ import java.util.List; -import cpw.mods.fml.client.config.GuiConfig; -import cpw.mods.fml.client.config.GuiConfigEntries; -import cpw.mods.fml.client.config.GuiConfigEntries.CategoryEntry; -import cpw.mods.fml.client.config.IConfigElement; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; +import net.minecraftforge.fml.client.config.GuiConfig; +import net.minecraftforge.fml.client.config.GuiConfigEntries; +import net.minecraftforge.fml.client.config.GuiConfigEntries.CategoryEntry; +import net.minecraftforge.fml.client.config.IConfigElement; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class GuiConfigCustomCategoryListEntry extends CategoryEntry { - @SuppressWarnings("rawtypes") public GuiConfigCustomCategoryListEntry(GuiConfig parentGuiConfig, GuiConfigEntries parentPropertyList, IConfigElement prop) { super(parentGuiConfig, parentPropertyList, prop); - List props = this.configElement.getChildElements(); + List props = configElement.getChildElements(); // TODO: create a custom IGuiConfigListEntry class for adding a new mod config // TODO: create a custom IGuiConfigListEntry class that extends this class and provides a button for removing the mod config // TODO: create a custom IGuiConfigListEntry class that adds a new tree to a mod config - childScreen = new GuiConfig(this.owningScreen, props, this.owningScreen.title, this.owningScreen.modID, - this.configElement.requiresWorldRestart(), this.configElement.requiresMcRestart(), - ((this.owningScreen.titleLine2 == null ? "" : this.owningScreen.titleLine2) + " > " + this.name)); + childScreen = new GuiConfig(owningScreen, props, owningScreen.title, owningScreen.modID, + configElement.requiresWorldRestart(), configElement.requiresMcRestart(), + ((owningScreen.titleLine2 == null ? "" : owningScreen.titleLine2 + " > ") + name)); } } \ No newline at end of file diff --git a/src/main/java/bspkrs/treecapitator/fml/gui/GuiTCConfig.java b/src/main/java/bspkrs/treecapitator/fml/gui/GuiTCConfig.java index c14d622..4448b4e 100644 --- a/src/main/java/bspkrs/treecapitator/fml/gui/GuiTCConfig.java +++ b/src/main/java/bspkrs/treecapitator/fml/gui/GuiTCConfig.java @@ -2,16 +2,15 @@ import java.util.ArrayList; import java.util.List; -import java.util.Set; -import java.util.TreeSet; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.common.config.ConfigElement; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.fml.client.config.GuiConfig; +import net.minecraftforge.fml.client.config.IConfigElement; import bspkrs.treecapitator.TreecapitatorMod; import bspkrs.treecapitator.config.TCConfigHandler; import bspkrs.treecapitator.util.Reference; -import cpw.mods.fml.client.config.GuiConfig; -import cpw.mods.fml.client.config.IConfigElement; public class GuiTCConfig extends GuiConfig { @@ -20,28 +19,197 @@ public GuiTCConfig(GuiScreen parent) super(parent, getProps(), Reference.MODID, false, false, GuiConfig.getAbridgedConfigPath(TCConfigHandler.instance().getConfig().toString())); } - @SuppressWarnings("rawtypes") private static List getProps() { // Make sure the local objects contain our local settings TreecapitatorMod.instance.nbtManager().registerLocalInstances(); - Set processed = new TreeSet(); List props = new ArrayList(); for (String catName : TCConfigHandler.instance().getConfig().getCategoryNames()) - { - boolean shouldAdd = true; - for (String prevCat : processed) - if (catName.startsWith(prevCat)) - { - shouldAdd = false; - break; - } - processed.add(catName); - if (shouldAdd) + if (!catName.contains(Configuration.CATEGORY_SPLITTER)) props.add(new ConfigElement(TCConfigHandler.instance().getConfig().getCategory(catName))); - } return props; } + + // /** + // * This custom list entry provides the Tree and Mod Configs entry on the Treecapitator config screen. It extends the base Category entry + // * class and defines the IConfigElement objects that will be used to build the child screen. In this case it adds the custom entry for + // * adding a new mod config and lists the existing mod configs. + // */ + // public static class ModConfigsEntry extends CategoryEntry + // { + // public ModConfigsEntry(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop) + // { + // super(owningScreen, owningEntryList, prop); + // } + // + // /** + // * This method is called in the constructor and is used to set the childScreen field. + // */ + // @Override + // protected GuiScreen buildChildScreen() + // { + // List list = new ArrayList(); + // + // list.add(new DummyCategoryElement(Reference.CTGY_TREE_MOD_CFG, Reference.LANG_KEY_BASE + Reference.CTGY_TREE_MOD_CFG, + // AddModConfigEntry.class)); + // for (ConfigCategory cc : ForgeChunkManager.getModCategories()) + // list.add(new ConfigElement(cc)); + // + // return new GuiConfig(owningScreen, list, owningScreen.modID, + // configElement.requiresWorldRestart() || owningScreen.allRequireWorldRestart, + // configElement.requiresMcRestart() || owningScreen.allRequireMcRestart, owningScreen.title, + // I18n.format("forge.configgui.ctgy.forgeChunkLoadingModConfig")); + // } + // + // /** + // * By overriding the enabled() method and checking the value of the "enabled" entry this entry is enabled/disabled based on the + // * value of the other entry. + // */ + // @Override + // public boolean enabled() + // { + // for (IConfigEntry entry : owningEntryList.listEntries) + // { + // if (entry.getName().equals("enabled") && (entry instanceof BooleanEntry)) + // { + // return Boolean.valueOf(entry.getCurrentValue().toString()); + // } + // } + // + // return true; + // } + // + // /** + // * Check to see if the child screen's entry list has changed. + // */ + // @Override + // public boolean isChanged() + // { + // if (childScreen instanceof GuiConfig) + // { + // GuiConfig child = (GuiConfig) childScreen; + // return (child.entryList.listEntries.size() != child.initEntries.size()) || child.entryList.hasChangedEntry(true); + // } + // return false; + // } + // + // /** + // * Since adding a new entry to the child screen is what constitutes a change here, reset the child screen listEntries to the saved + // * list. + // */ + // @Override + // public void undoChanges() + // { + // if (childScreen instanceof GuiConfig) + // { + // GuiConfig child = (GuiConfig) childScreen; + // for (IConfigEntry ice : child.entryList.listEntries) + // if (!child.initEntries.contains(ice) && ForgeChunkManager.getConfig().hasCategory(ice.getName())) + // ForgeChunkManager.getConfig().removeCategory(ForgeChunkManager.getConfig().getCategory(ice.getName())); + // + // child.entryList.listEntries = new ArrayList(child.initEntries); + // } + // } + // } + // + // /** + // * This custom list entry provides a button that will open to a screen that will allow a user to define a new mod override. + // */ + // public static class AddModConfigEntry extends CategoryEntry + // { + // public AddModConfigEntry(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop) + // { + // super(owningScreen, owningEntryList, prop); + // } + // + // @Override + // protected GuiScreen buildChildScreen() + // { + // List list = new ArrayList(); + // + // list.add(new DummyConfigElement(Reference.MOD_ID, "", ConfigGuiType.STRING, Reference.LANG_KEY_BASE + Reference.MOD_ID) + // .setCustomListEntryClass(ModIDEntry.class)); + // list.add(new ConfigElement(new Property(Reference.OVERRIDE_IMC, "true", Property.Type.BOOLEAN, Reference.LANG_KEY_BASE + Reference.OVERRIDE_IMC))); + // list.add(new ConfigElement(new Property("maximumChunksPerTicket", "25", Property.Type.INTEGER, "forge.configgui.maximumChunksPerTicket"))); + // + // return new GuiConfig(owningScreen, list, owningScreen.modID, + // configElement.requiresWorldRestart() || owningScreen.allRequireWorldRestart, + // configElement.requiresMcRestart() || owningScreen.allRequireMcRestart, owningScreen.title, + // I18n.format("forge.configgui.ctgy.forgeChunkLoadingAddModConfig")); + // } + // + // @Override + // public boolean isChanged() + // { + // return false; + // } + // } + // + // /** + // * This custom list entry provides a Mod ID selector. The control is a button that opens a list of values to select from. This entry + // * also overrides onGuiClosed() to run code to save the data to a new ConfigCategory when the user is done. + // */ + // public static class ModIDEntry extends SelectValueEntry + // { + // public ModIDEntry(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop) + // { + // super(owningScreen, owningEntryList, prop, getSelectableValues()); + // if (selectableValues.size() == 0) + // btnValue.enabled = false; + // } + // + // private static Map getSelectableValues() + // { + // Map selectableValues = new TreeMap(); + // + // for (ModContainer mod : Loader.instance().getActiveModList()) + // // only add mods to the list that have a non-immutable ModContainer + // if (!mod.isImmutable() && (mod.getMod() != null)) + // selectableValues.put(mod.getModId(), mod.getName()); + // + // return selectableValues; + // } + // + // /** + // * By overriding onGuiClosed() for this entry we can perform additional actions when the user is done such as saving a new + // * ConfigCategory object to the Configuration object. + // */ + // @Override + // public void onGuiClosed() + // { + // Object modObject = Loader.instance().getModObjectList().get(Loader.instance().getIndexedModList().get(currentValue)); + // if (modObject != null) + // { + // owningEntryList.saveConfigElements(); + // for (IConfigElement ice : owningScreen.configElements) + // if ("maximumTicketCount".equals(ice.getName())) + // maxTickets = Integer.valueOf(ice.get().toString()); + // else if ("maximumChunksPerTicket".equals(ice.getName())) + // maxChunks = Integer.valueOf(ice.get().toString()); + // + // // TODO: create a new ConfigCategory + // + // if (owningScreen.parentScreen instanceof GuiConfig) + // { + // GuiConfig superParent = (GuiConfig) owningScreen.parentScreen; + // ConfigCategory modCtgy = ForgeChunkManager.getConfigFor(modObject); + // modCtgy.setPropertyOrder(ForgeChunkManager.MOD_PROP_ORDER); + // ConfigElement modConfig = new ConfigElement(modCtgy); + // + // boolean found = false; + // for (IConfigElement ice : superParent.configElements) + // if (ice.getName().equals(currentValue)) + // found = true; + // + // if (!found) + // superParent.configElements.add(modConfig); + // + // superParent.needsRefresh = true; + // superParent.initGui(); + // } + // } + // } + // } } diff --git a/src/main/java/bspkrs/treecapitator/fml/gui/ModGuiFactoryHandler.java b/src/main/java/bspkrs/treecapitator/fml/gui/ModGuiFactoryHandler.java index 6e91b10..5b4cf5f 100644 --- a/src/main/java/bspkrs/treecapitator/fml/gui/ModGuiFactoryHandler.java +++ b/src/main/java/bspkrs/treecapitator/fml/gui/ModGuiFactoryHandler.java @@ -4,7 +4,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; -import cpw.mods.fml.client.IModGuiFactory; +import net.minecraftforge.fml.client.IModGuiFactory; public class ModGuiFactoryHandler implements IModGuiFactory { diff --git a/src/main/java/bspkrs/treecapitator/forge/ForgeEventHandler.java b/src/main/java/bspkrs/treecapitator/forge/ForgeEventHandler.java index e067541..a31bddf 100644 --- a/src/main/java/bspkrs/treecapitator/forge/ForgeEventHandler.java +++ b/src/main/java/bspkrs/treecapitator/forge/ForgeEventHandler.java @@ -7,9 +7,12 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.util.BlockPos; import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.world.BlockEvent.BreakEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.registry.GameData; import bspkrs.treecapitator.Treecapitator; import bspkrs.treecapitator.TreecapitatorMod; import bspkrs.treecapitator.config.TCConfigHandler; @@ -18,7 +21,6 @@ import bspkrs.treecapitator.registry.TreeDefinition; import bspkrs.treecapitator.registry.TreeRegistry; import bspkrs.treecapitator.util.TCLog; -import bspkrs.util.Coord; import bspkrs.util.ModulusBlockID; import com.google.common.base.Charsets; @@ -26,20 +28,17 @@ import com.google.common.hash.Hasher; import com.google.common.hash.Hashing; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.registry.GameData; - public class ForgeEventHandler { - private Map playerSneakingMap = new ConcurrentHashMap(64); - private Map breakSpeedCache = new ConcurrentHashMap(64); + private final Map playerSneakingMap = new ConcurrentHashMap(64); + private final Map breakSpeedCache = new ConcurrentHashMap(64); @SubscribeEvent public void onBlockClicked(PlayerInteractEvent event) { if (TreecapitatorMod.proxy.isEnabled() && !TCSettings.sneakAction.equalsIgnoreCase("none") && event.action.equals(PlayerInteractEvent.Action.LEFT_CLICK_BLOCK)) { - if (!event.entityPlayer.worldObj.isAirBlock(event.x, event.y, event.z)) + if (!event.entityPlayer.worldObj.isAirBlock(event.pos)) playerSneakingMap.put(event.entityPlayer.getGameProfile().getName(), event.entityPlayer.isSneaking()); } } @@ -47,25 +46,26 @@ public void onBlockClicked(PlayerInteractEvent event) @SubscribeEvent public void getPlayerBreakSpeed(BreakSpeed event) { - ModulusBlockID blockID = new ModulusBlockID(event.block, event.metadata, 4); + ModulusBlockID blockID = new ModulusBlockID(event.state, 4); + BlockPos pos = event.pos; if (TreecapitatorMod.proxy.isEnabled() && (TreeRegistry.instance().isRegistered(blockID) - || (TCSettings.allowAutoTreeDetection && TreeRegistry.canAutoDetect(event.entityPlayer.worldObj, event.block, event.x, event.y, event.z))) - && Treecapitator.isBreakingPossible(event.entityPlayer, event.block, event.metadata, false)) + || (TCSettings.allowAutoTreeDetection && TreeRegistry.canAutoDetect(event.entityPlayer.worldObj, event.state.getBlock(), pos))) + && Treecapitator.isBreakingPossible(event.entityPlayer, event.pos, false)) { TreeDefinition treeDef; if (TCSettings.allowAutoTreeDetection) - treeDef = TreeRegistry.autoDetectTree(event.entityPlayer.worldObj, blockID, new Coord(event.x, event.y, event.z), TCSettings.allowDebugLogging); + treeDef = TreeRegistry.autoDetectTree(event.entityPlayer.worldObj, blockID, pos, TCSettings.allowDebugLogging); else treeDef = TreeRegistry.instance().get(blockID); if (treeDef != null) { Boolean isSneaking = playerSneakingMap.get(event.entityPlayer.getGameProfile().getName()); - boolean swappedSneak = !((isSneaking != null && (isSneaking.booleanValue() == event.entityPlayer.isSneaking())) || isSneaking == null); + boolean swappedSneak = !(((isSneaking != null) && (isSneaking.booleanValue() == event.entityPlayer.isSneaking())) || (isSneaking == null)); CachedBreakSpeed cachedBreakSpeed = new CachedBreakSpeed(event, swappedSneak); - Float newBreakSpeed = this.breakSpeedCache.get(cachedBreakSpeed); + Float newBreakSpeed = breakSpeedCache.get(cachedBreakSpeed); if (newBreakSpeed == null) { @@ -75,7 +75,7 @@ public void getPlayerBreakSpeed(BreakSpeed event) { if (Treecapitator.isBreakingEnabled(event.entityPlayer)) { - int height = Treecapitator.getTreeHeight(treeDef, event.entityPlayer.worldObj, event.x, event.y, event.z, event.metadata, event.entityPlayer); + int height = Treecapitator.getTreeHeight(treeDef, event.entityPlayer.worldObj, pos, event.entityPlayer); if (height > 1) event.newSpeed = event.originalSpeed / (height * TCSettings.treeHeightModifier); } @@ -86,7 +86,7 @@ else if (Treecapitator.isBreakingEnabled(event.entityPlayer)) else event.newSpeed = 0.0f; - this.breakSpeedCache.put(cachedBreakSpeed, event.newSpeed); + breakSpeedCache.put(cachedBreakSpeed, event.newSpeed); } else event.newSpeed = newBreakSpeed; @@ -97,33 +97,34 @@ else if (Treecapitator.isBreakingEnabled(event.entityPlayer)) @SubscribeEvent public void onBlockHarvested(BreakEvent event) { - if (event.block != null && event.world != null && event.getPlayer() != null) + if ((event.state != null) && (event.world != null) && (event.getPlayer() != null)) { if (TreecapitatorMod.proxy.isEnabled() && !event.world.isRemote) { - ModulusBlockID blockID = new ModulusBlockID(event.block, event.blockMetadata, 4); + ModulusBlockID blockID = new ModulusBlockID(event.state, 4); - if ((TreeRegistry.instance().isRegistered(blockID) || (TCSettings.allowAutoTreeDetection && TreeRegistry.canAutoDetect(event.world, event.block, event.x, event.y, event.z))) - && Treecapitator.isBreakingPossible(event.getPlayer(), event.block, event.blockMetadata, TCSettings.allowDebugLogging)) + if ((TreeRegistry.instance().isRegistered(blockID) || (TCSettings.allowAutoTreeDetection + && TreeRegistry.canAutoDetect(event.world, event.state.getBlock(), event.pos))) + && Treecapitator.isBreakingPossible(event.getPlayer(), event.pos, TCSettings.allowDebugLogging)) { - Coord blockPos = new Coord(event.x, event.y, event.z); - if (TreeRegistry.instance().trackTreeChopEventAt(blockPos)) + BlockPos pos = event.pos; + if (TreeRegistry.instance().trackTreeChopEventAt(pos)) { TCLog.debug("BlockID " + blockID + " is a log."); TreeDefinition treeDef; if (TCSettings.allowAutoTreeDetection) - treeDef = TreeRegistry.autoDetectTree(event.world, blockID, blockPos, TCSettings.allowDebugLogging); + treeDef = TreeRegistry.autoDetectTree(event.world, blockID, pos, TCSettings.allowDebugLogging); else treeDef = TreeRegistry.instance().get(blockID); if (treeDef != null) - (new Treecapitator(event.getPlayer(), treeDef)).onBlockHarvested(event.world, event.x, event.y, event.z, event.blockMetadata); + (new Treecapitator(event.getPlayer(), treeDef)).onBlockHarvested(event.world, pos); - TreeRegistry.instance().endTreeChopEventAt(blockPos); + TreeRegistry.instance().endTreeChopEventAt(pos); } else - TCLog.debug("Previous chopping event detected for block @%s", blockPos.toString()); + TCLog.debug("Previous chopping event detected for block @%s", pos.toString()); } } @@ -137,12 +138,12 @@ public void onBlockHarvested(BreakEvent event) public void cleanUpCaches(EntityPlayer player) { List toRemove = new ArrayList(); - for (CachedBreakSpeed bs : this.breakSpeedCache.keySet()) + for (CachedBreakSpeed bs : breakSpeedCache.keySet()) if (bs.entityPlayer.getGameProfile().getName().equals(player.getGameProfile().getName())) toRemove.add(bs); for (CachedBreakSpeed bs : toRemove) - this.breakSpeedCache.remove(bs); + breakSpeedCache.remove(bs); if (playerSneakingMap.containsKey(player.getGameProfile().getName())) playerSneakingMap.remove(player.getGameProfile().getName()); @@ -150,13 +151,13 @@ public void cleanUpCaches(EntityPlayer player) private class CachedBreakSpeed extends BreakSpeed { - private boolean isSneaking; - private boolean swappedSneak; + private final boolean isSneaking; + private final boolean swappedSneak; public CachedBreakSpeed(BreakSpeed event, boolean swappedSneak) { - super(event.entityPlayer, event.block, event.metadata, event.originalSpeed, event.x, event.y, event.z); - this.isSneaking = event.entityPlayer.isSneaking(); + super(event.entityPlayer, event.state, event.originalSpeed, event.pos); + isSneaking = event.entityPlayer.isSneaking(); this.swappedSneak = swappedSneak; } @@ -172,33 +173,34 @@ public boolean equals(Object o) CachedBreakSpeed bs = (CachedBreakSpeed) o; ItemStack oItem = bs.entityPlayer.getCurrentEquippedItem(); - ItemStack thisItem = this.entityPlayer.getCurrentEquippedItem(); + ItemStack thisItem = entityPlayer.getCurrentEquippedItem(); - return bs.entityPlayer.getGameProfile().getName().equals(this.entityPlayer.getGameProfile().getName()) - && (oItem != null && oItem.getItem() != null ? (thisItem != null && thisItem.getItem() != null + return bs.entityPlayer.getGameProfile().getName().equals(entityPlayer.getGameProfile().getName()) + && ((oItem != null) && (oItem.getItem() != null) ? ((thisItem != null) && (thisItem.getItem() != null) ? GameData.getItemRegistry().getNameForObject(thisItem.getItem()).equals(GameData.getItemRegistry().getNameForObject(oItem.getItem())) : false) - : thisItem == null || thisItem.getItem() == null) - && GameData.getBlockRegistry().getNameForObject(bs.block).equals(GameData.getBlockRegistry().getNameForObject(this.block)) - && bs.isSneaking == this.isSneaking && bs.swappedSneak == this.swappedSneak - && bs.metadata == this.metadata && bs.originalSpeed == this.originalSpeed && bs.x == this.x && bs.y == this.y && bs.z == this.z; + : (thisItem == null) || (thisItem.getItem() == null)) + && GameData.getBlockRegistry().getNameForObject(bs.state.getBlock()).equals(GameData.getBlockRegistry().getNameForObject(state.getBlock())) + && (bs.isSneaking == isSneaking) && (bs.swappedSneak == swappedSneak) + && (bs.state.getBlock().getMetaFromState(bs.state) == state.getBlock().getMetaFromState(state)) + && (bs.originalSpeed == originalSpeed) && (bs.pos.equals(pos)); } @Override public int hashCode() { - ItemStack thisItem = this.entityPlayer.getCurrentEquippedItem(); + ItemStack thisItem = entityPlayer.getCurrentEquippedItem(); HashFunction hf = Hashing.md5(); Hasher h = hf.newHasher() - .putString(this.entityPlayer.getGameProfile().getName(), Charsets.UTF_8) - .putString(GameData.getBlockRegistry().getNameForObject(this.block), Charsets.UTF_8) - .putBoolean(this.isSneaking) - .putBoolean(this.swappedSneak) - .putInt(this.metadata) - .putFloat(this.originalSpeed) - .putInt(x + z << 8 + y << 16); - - if (thisItem != null && thisItem.getItem() != null) - h.putString(GameData.getItemRegistry().getNameForObject(thisItem.getItem()), Charsets.UTF_8) + .putString(entityPlayer.getGameProfile().getName(), Charsets.UTF_8) + .putString(GameData.getBlockRegistry().getNameForObject(state.getBlock()).toString(), Charsets.UTF_8) + .putBoolean(isSneaking) + .putBoolean(swappedSneak) + .putInt(state.getBlock().getMetaFromState(state)) + .putFloat(originalSpeed) + .putInt(pos.hashCode()); + + if ((thisItem != null) && (thisItem.getItem() != null)) + h.putString(GameData.getItemRegistry().getNameForObject(thisItem.getItem()).toString(), Charsets.UTF_8) .putInt(thisItem.getMetadata()); return h.hash().hashCode(); diff --git a/src/main/java/bspkrs/treecapitator/forge/OreDictionaryHandler.java b/src/main/java/bspkrs/treecapitator/forge/OreDictionaryHandler.java index aa162b8..5e83920 100644 --- a/src/main/java/bspkrs/treecapitator/forge/OreDictionaryHandler.java +++ b/src/main/java/bspkrs/treecapitator/forge/OreDictionaryHandler.java @@ -6,6 +6,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.registry.GameData; import net.minecraftforge.oredict.OreDictionary; import bspkrs.treecapitator.config.TCSettings; import bspkrs.treecapitator.registry.ModConfigRegistry; @@ -14,7 +15,6 @@ import bspkrs.treecapitator.util.Reference; import bspkrs.treecapitator.util.TCLog; import bspkrs.util.BlockID; -import cpw.mods.fml.common.registry.GameData; public class OreDictionaryHandler { @@ -46,7 +46,7 @@ public boolean generateAndRegisterOreDictionaryTreeDefinitions() Item item = itemStack.getItem(); if (item instanceof ItemBlock) { - BlockID blockID = new BlockID(GameData.getItemRegistry().getNameForObject(item)); + BlockID blockID = new BlockID(GameData.getItemRegistry().getNameForObject(item).toString()); if (!leafList.contains(blockID)) leafList.add(blockID); } @@ -67,7 +67,7 @@ public boolean generateAndRegisterOreDictionaryTreeDefinitions() Item item = itemStack.getItem(); if (item instanceof ItemBlock) { - BlockID blockID = new BlockID(GameData.getItemRegistry().getNameForObject(item)); + BlockID blockID = new BlockID(GameData.getItemRegistry().getNameForObject(item).toString()); if (!TreeRegistry.instance().isRegistered(blockID) && !TreeRegistry.instance().blacklist().contains(blockID)) genericTree.addLogID(blockID); } diff --git a/src/main/java/bspkrs/treecapitator/registry/ModConfigRegistry.java b/src/main/java/bspkrs/treecapitator/registry/ModConfigRegistry.java index 37b3948..78590df 100644 --- a/src/main/java/bspkrs/treecapitator/registry/ModConfigRegistry.java +++ b/src/main/java/bspkrs/treecapitator/registry/ModConfigRegistry.java @@ -17,7 +17,7 @@ import bspkrs.util.BlockID; import bspkrs.util.ItemID; import bspkrs.util.ModulusBlockID; -import cpw.mods.fml.common.Loader; +import net.minecraftforge.fml.common.Loader; public class ModConfigRegistry { diff --git a/src/main/java/bspkrs/treecapitator/registry/ThirdPartyModConfig.java b/src/main/java/bspkrs/treecapitator/registry/ThirdPartyModConfig.java index 57c5e33..779495a 100644 --- a/src/main/java/bspkrs/treecapitator/registry/ThirdPartyModConfig.java +++ b/src/main/java/bspkrs/treecapitator/registry/ThirdPartyModConfig.java @@ -62,18 +62,18 @@ protected ThirdPartyModConfig() protected ThirdPartyModConfig(String modID) { this.modID = modID; - this.overrideIMC = TCSettings.userConfigOverridesIMC; - this.axeList = new ArrayList(); - this.shearsList = new ArrayList(); - this.treesMap = new TreeMap(); + overrideIMC = TCSettings.userConfigOverridesIMC; + axeList = new ArrayList(); + shearsList = new ArrayList(); + treesMap = new TreeMap(); } public void merge(ThirdPartyModConfig toMerge) { - if (!this.modID.equals(toMerge.modID)) - throw new IllegalArgumentException(String.format("Cannot merge ThirdPartyModConfig objects with different modID values! this.modID: %s toMerge.modID: %s", this.modID, toMerge.modID)); + if (!modID.equals(toMerge.modID)) + throw new IllegalArgumentException(String.format("Cannot merge ThirdPartyModConfig objects with different modID values! this.modID: %s toMerge.modID: %s", modID, toMerge.modID)); - this.overrideIMC = this.overrideIMC || toMerge.overrideIMC; + overrideIMC = overrideIMC || toMerge.overrideIMC; for (ItemID itemID : toMerge.axeList) if (!axeList.contains(itemID)) @@ -85,25 +85,26 @@ public void merge(ThirdPartyModConfig toMerge) for (Entry newEntry : toMerge.treesMap.entrySet()) { - if (this.treesMap.containsKey(newEntry.getKey())) + if (treesMap.containsKey(newEntry.getKey())) { - this.treesMap.get(newEntry.getKey()).appendWithSettings(newEntry.getValue()); + treesMap.get(newEntry.getKey()).appendWithSettings(newEntry.getValue()); continue; } - for (Entry entry : this.treesMap.entrySet()) + for (Entry entry : treesMap.entrySet()) if (newEntry.getValue().hasCommonLog(entry.getValue())) { entry.getValue().appendWithSettings(newEntry.getValue()); continue; } - this.treesMap.put(newEntry.getKey(), newEntry.getValue()); + treesMap.put(newEntry.getKey(), newEntry.getValue()); } isChanged = true; } + @SuppressWarnings("unchecked") public static boolean isValidNBT(NBTTagCompound tpModCfg) { for (String s : (Set) tpModCfg.getKeySet()) @@ -214,7 +215,7 @@ public void writeToConfiguration(Configuration config, String category) TreecapitatorMod.proxy.setCategoryConfigEntryClass(config, category); config.setCategoryPropertyOrder(category, orderedKeys); - this.isChanged = false; + isChanged = false; } public ThirdPartyModConfig addTreeDef(String key, TreeDefinition tree) @@ -224,25 +225,25 @@ public ThirdPartyModConfig addTreeDef(String key, TreeDefinition tree) else treesMap.get(key).appendWithSettings(tree); - this.isChanged = true; + isChanged = true; return this; } public ThirdPartyModConfig addAxe(ItemID axe) { - if (!this.axeList.contains(axe)) - this.axeList.add(axe); + if (!axeList.contains(axe)) + axeList.add(axe); - this.isChanged = true; + isChanged = true; return this; } public ThirdPartyModConfig addShears(ItemID shears) { - if (!this.shearsList.contains(shears)) - this.shearsList.add(shears); + if (!shearsList.contains(shears)) + shearsList.add(shears); - this.isChanged = true; + isChanged = true; return this; } @@ -299,5 +300,6 @@ public boolean isChanged() validKeys.add(Reference.AXE_ID_LIST); validKeys.add(Reference.SHEARS_ID_LIST); validKeys.add(Reference.OVERRIDE_IMC); + validKeys.add(Reference.TREES); } } diff --git a/src/main/java/bspkrs/treecapitator/registry/ToolRegistry.java b/src/main/java/bspkrs/treecapitator/registry/ToolRegistry.java index a4b35e3..c69ddef 100644 --- a/src/main/java/bspkrs/treecapitator/registry/ToolRegistry.java +++ b/src/main/java/bspkrs/treecapitator/registry/ToolRegistry.java @@ -3,10 +3,11 @@ import java.util.ArrayList; import java.util.List; -import net.minecraft.block.Block; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; import net.minecraftforge.common.ForgeHooks; import bspkrs.treecapitator.config.TCSettings; import bspkrs.treecapitator.util.Reference; @@ -69,9 +70,9 @@ protected void initVanillaItemLists() vanShearsList.add(new ItemID(Items.shears)); } - public static synchronized void autoDetectAxe(ItemStack item, Block block, int blockMetadata) + public static synchronized void autoDetectAxe(World world, BlockPos pos, ItemStack item) { - if (item != null && item.getItem() != null && ForgeHooks.isToolEffective(item, block, blockMetadata)) + if ((item != null) && (item.getItem() != null) && ForgeHooks.isToolEffective(world, pos, item)) { ItemID axe = new ItemID(item); if (!instance.isAxe(item)) @@ -112,7 +113,7 @@ public void writeToNBT(NBTTagCompound ntc) public synchronized boolean registerAxe(ItemID axe) { - if (axe != null && !blacklist.contains(axe) && !axeList.contains(axe)) + if ((axe != null) && !blacklist.contains(axe) && !axeList.contains(axe)) { axeList.add(axe); TCLog.debug("ToolRegistry: Successfully registered axe item %s", axe); @@ -126,7 +127,7 @@ else if (blacklist.contains(axe)) public synchronized boolean registerShears(ItemID shears) { - if (shears != null && !blacklist.contains(shears) && !shearsList.contains(shears)) + if ((shears != null) && !blacklist.contains(shears) && !shearsList.contains(shears)) { shearsList.add(shears); TCLog.debug("ToolRegistry: Successfully registered shears item %s", shears); @@ -160,7 +161,7 @@ public List vanillaShearsList() public boolean isAxe(ItemStack itemStack) { - if (itemStack != null && itemStack.getItem() != null) + if ((itemStack != null) && (itemStack.getItem() != null)) { ItemID itemID = new ItemID(itemStack); return !blacklist.contains(itemID) && axeList.contains(itemID); @@ -171,7 +172,7 @@ public boolean isAxe(ItemStack itemStack) public boolean isShears(ItemStack itemStack) { - if (itemStack != null && itemStack.getItem() != null) + if ((itemStack != null) && (itemStack.getItem() != null)) { ItemID itemID = new ItemID(itemStack); return !blacklist.contains(itemID) && shearsList.contains(itemID); diff --git a/src/main/java/bspkrs/treecapitator/registry/TreeDefinition.java b/src/main/java/bspkrs/treecapitator/registry/TreeDefinition.java index e53bbd0..a3f1f80 100644 --- a/src/main/java/bspkrs/treecapitator/registry/TreeDefinition.java +++ b/src/main/java/bspkrs/treecapitator/registry/TreeDefinition.java @@ -197,6 +197,7 @@ public TreeDefinition appendWithSettings(TreeDefinition toAdd) return this; } + @SuppressWarnings("unchecked") public static boolean isValidNBT(NBTTagCompound treeDefNBT) { for (String s : (Set) treeDefNBT.getKeySet()) @@ -241,12 +242,12 @@ public TreeDefinition readFromNBT(NBTTagCompound treeDefNBT) if (treeDefNBT.hasKey(Reference.USE_ADV_TOP_LOG_LOGIC)) useAdvancedTopLogLogic = treeDefNBT.getBoolean(Reference.USE_ADV_TOP_LOG_LOGIC); - if (treeDefNBT.hasKey(Reference.LOGS) && treeDefNBT.getString(Reference.LOGS).length() > 0) + if (treeDefNBT.hasKey(Reference.LOGS) && (treeDefNBT.getString(Reference.LOGS).length() > 0)) logBlocks = ListUtils.getDelimitedStringAsBlockIDList(treeDefNBT.getString(Reference.LOGS), ";"); else logBlocks = new ArrayList(); - if (treeDefNBT.hasKey(Reference.LEAVES) && treeDefNBT.getString(Reference.LEAVES).length() > 0) + if (treeDefNBT.hasKey(Reference.LEAVES) && (treeDefNBT.getString(Reference.LEAVES).length() > 0)) leafBlocks = ListUtils.getDelimitedStringAsBlockIDList(treeDefNBT.getString(Reference.LEAVES), ";"); else leafBlocks = new ArrayList(); diff --git a/src/main/java/bspkrs/treecapitator/registry/TreeRegistry.java b/src/main/java/bspkrs/treecapitator/registry/TreeRegistry.java index 791420a..1108a87 100644 --- a/src/main/java/bspkrs/treecapitator/registry/TreeRegistry.java +++ b/src/main/java/bspkrs/treecapitator/registry/TreeRegistry.java @@ -15,13 +15,13 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; +import net.minecraft.util.BlockPos; import net.minecraft.world.World; import bspkrs.treecapitator.Treecapitator; import bspkrs.treecapitator.config.TCSettings; import bspkrs.treecapitator.util.Reference; import bspkrs.treecapitator.util.TCLog; import bspkrs.util.BlockID; -import bspkrs.util.Coord; import bspkrs.util.ListUtils; import bspkrs.util.ModulusBlockID; @@ -32,7 +32,7 @@ public class TreeRegistry private TreeDefinition masterDefinition; private Map vanTrees; private List blacklist; - private Set blocksBeingChopped; + private Set blocksBeingChopped; private static TreeRegistry instance; @@ -57,7 +57,7 @@ protected void initMapsAndLists() treeDefs = new HashMap(); logToStringMap = new HashMap(); masterDefinition = new TreeDefinition(); - blocksBeingChopped = new HashSet(); + blocksBeingChopped = new HashSet(); readBlacklistFromDelimitedString(TCSettings.blockIDBlacklist); } @@ -123,7 +123,7 @@ else if (logToStringMap.containsKey(blockID) && !sharedLogTrees.contains(logToSt // Whoa! this BlockID isn't new, we need to do some merging sharedLogTrees.add(logToStringMap.get(blockID)); - if (!newKey.trim().isEmpty() && !isRegistered(newKey) && sharedLogTrees.size() == 0) + if (!newKey.trim().isEmpty() && !isRegistered(newKey) && (sharedLogTrees.size() == 0)) { // New definition all around. Easy. TCLog.debug("Tree Definition \"%s\" is new. Proceeding to insert new key.", newKey); @@ -197,7 +197,7 @@ else if (!newKey.trim().isEmpty()) TCLog.warning("TreeDefinition cannot be null when registering a tree!"); } - public boolean trackTreeChopEventAt(Coord c) + public boolean trackTreeChopEventAt(BlockPos c) { if (!blocksBeingChopped.contains(c)) { @@ -207,7 +207,7 @@ public boolean trackTreeChopEventAt(Coord c) return false; } - public void endTreeChopEventAt(Coord c) + public void endTreeChopEventAt(BlockPos c) { if (blocksBeingChopped.contains(c)) blocksBeingChopped.remove(c); @@ -276,17 +276,17 @@ public TreeDefinition get(BlockID blockID) return null; } - public static boolean canAutoDetect(World world, Block block, int x, int y, int z) + public static boolean canAutoDetect(World world, Block block, BlockPos pos) { - return block.isWood(world, x, y, z) || block.canSustainLeaves(world, x, y, z); + return block.isWood(world, pos) || block.canSustainLeaves(world, pos); } - public static synchronized TreeDefinition autoDetectTree(World world, BlockID blockID, Coord blockPos, boolean shouldLog) + public static synchronized TreeDefinition autoDetectTree(World world, BlockID blockID, BlockPos blockPos, boolean shouldLog) { TreeDefinition treeDef = instance.get(blockID); List leaves = Treecapitator.getLeavesForTree(world, blockID, blockPos, treeDef == null); - if (treeDef == null && leaves.size() >= TCSettings.minLeavesToID) + if ((treeDef == null) && (leaves.size() >= TCSettings.minLeavesToID)) { treeDef = new TreeDefinition().addLogID(blockID).addAllLeafIDs(leaves); int index = blockID.id.indexOf(":"); @@ -299,7 +299,7 @@ public static synchronized TreeDefinition autoDetectTree(World world, BlockID bl if (shouldLog) TCLog.debug("Auto Tree Detection: New tree added: %s (%s)", treeName, treeDef); } - else if (treeDef != null && leaves.size() >= TCSettings.minLeavesToID) + else if ((treeDef != null) && (leaves.size() >= TCSettings.minLeavesToID)) { if (!ListUtils.doesListAContainAllUniqueListBValues(treeDef.leafBlocks, leaves)) { @@ -310,9 +310,9 @@ else if (treeDef != null && leaves.size() >= TCSettings.minLeavesToID) } else { - if (shouldLog) - TCLog.debug("Auto Tree Detection: Block ID %s is a log, but not enough leaves were " + - "found to identify this structure as a tree. Found %d leaves.", blockID, leaves.size()); + // if (shouldLog) + // TCLog.debug("Auto Tree Detection: Block ID %s is a log, but not enough leaves were " + + // "found to identify this structure as a tree. Found %d leaves.", blockID, leaves.size()); treeDef = null; } diff --git a/src/main/java/bspkrs/treecapitator/util/Reference.java b/src/main/java/bspkrs/treecapitator/util/Reference.java index 6303e75..f31ac47 100644 --- a/src/main/java/bspkrs/treecapitator/util/Reference.java +++ b/src/main/java/bspkrs/treecapitator/util/Reference.java @@ -99,6 +99,8 @@ public class Reference public static final String USE_ADV_TOP_LOG_LOGIC = "useAdvancedTopLogLogic"; public static final String USE_INCREASING_ITEM_DAMAGE = "useIncreasingItemDamage"; public static final String USE_STRICT_BLOCK_PAIRING = "useStrictBlockPairing"; + // public static final String USE_TICK_BASED_CHOPPING = "useTickBasedChopping"; + // public static final String BLOCKS_PER_TICK = "blocksPerTick"; // IMC Message Key public static final String THIRD_PARTY_MOD_CONFIG = "ThirdPartyModConfig"; @@ -199,6 +201,8 @@ public class Reference "enough leaf blocks are found the structure is considered a tree and is added to the TreeRegistry. Trees will\n" + "also be added to your local config file to allow for tweaking of settings if desired.\n" + "Set to true to enable this feature, false to disable."; + // public static final String useTickBasedChoppingDesc = "[Global] Set to true to use tick-based chopping (less lag inducing) or false to use the older chopping logic."; + // public static final String blocksPerTickDesc = "[Global] The number of blocks per tick to process when useTickBasedChopping == true."; public static final String maxLeafIDDistDesc = "[Global, PerTree] If a tree's top log is not close enough to leaf blocks, the tree will not be chopped.\n" + "Increasing this value will search further. I would try to keep it at or below 3."; public static final String maxLeafBreakDistDesc = "[Global, PerTree] The maximum distance to instantly decay leaves from any log block that is removed by Treecapitator."; diff --git a/src/main/resources/dependencies.info b/src/main/resources/dependencies.info deleted file mode 100644 index 4090230..0000000 --- a/src/main/resources/dependencies.info +++ /dev/null @@ -1,7 +0,0 @@ -{ - "repo": "http://bspk.rs/MC/bspkrsCore", - "file": "${bscore_jar}", - "pattern": "${pattern}", - "class": "bspkrs.bspkrscore.fml.bspkrsCoreMod", - "version": "${bscore_version}" -} \ No newline at end of file