From b43adaf08d2aed9909c10f57a6087156ba1e14cf Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Wed, 16 Jul 2014 10:58:27 +0200 Subject: [PATCH] Update tcon so we can remove the reflection hax for tool strength :) --- build.properties | 2 +- .../leveling/LevelingActiveToolMod.java | 34 +++---------------- 2 files changed, 6 insertions(+), 30 deletions(-) diff --git a/build.properties b/build.properties index 8b00581..659c65a 100644 --- a/build.properties +++ b/build.properties @@ -1,4 +1,4 @@ minecraft_version=1.7.10 forge_version=10.13.0.1180 mantle_version=161.45beb09 -tconstruct_version=1.6.0.jenkins534 \ No newline at end of file +tconstruct_version=1.6.0.jenkins536 \ No newline at end of file diff --git a/src/main/java/iguanaman/iguanatweakstconstruct/leveling/LevelingActiveToolMod.java b/src/main/java/iguanaman/iguanatweakstconstruct/leveling/LevelingActiveToolMod.java index 9ab851b..e6aa489 100644 --- a/src/main/java/iguanaman/iguanatweakstconstruct/leveling/LevelingActiveToolMod.java +++ b/src/main/java/iguanaman/iguanatweakstconstruct/leveling/LevelingActiveToolMod.java @@ -17,20 +17,6 @@ import java.util.Arrays; import java.util.List; public class LevelingActiveToolMod extends ActiveToolMod { - private static Method ToolStrength; - private static Method EffectiveMaterials; - static { - try { - ToolStrength = HarvestTool.class.getDeclaredMethod("calculateStrength", NBTTagCompound.class, Block.class, int.class); - ToolStrength.setAccessible(true); - EffectiveMaterials = HarvestTool.class.getDeclaredMethod("getEffectiveMaterials"); - EffectiveMaterials.setAccessible(true); - } catch (NoSuchMethodException e) { - IguanaLog.error(e); - e.printStackTrace(); - } - } - // TODO: make this customizable? static List materialBlacklist = Arrays.asList( Material.leaves, Material.vine, Material.circuits, @@ -54,22 +40,12 @@ public class LevelingActiveToolMod extends ActiveToolMod { boolean harvestable = false, effective = false, strong = false; - try { - harvestable = harvestTool.canHarvestBlock(block, stack); - Float strength = (Float)ToolStrength.invoke(harvestTool, tags, block, meta); - strong = strength >= 1.0f; - Material[] materials = (Material[])EffectiveMaterials.invoke(harvestTool); - for(Material m : materials) - if(m == block.getMaterial()) - effective = true; - } catch (IllegalAccessException e) { - IguanaLog.error(e); - e.printStackTrace(); - } catch (InvocationTargetException e) { - IguanaLog.error(e); - e.printStackTrace(); - } + harvestable = harvestTool.canHarvestBlock(block, stack); + + Float strength = harvestTool.calculateStrength(tags, block, meta); + strong = strength >= 1.0f; + effective = harvestTool.isEffective(block.getMaterial()); IguanaLog.trace("Tool is [harvestable: '" + harvestable + "', effective: '" + effective + "', strong: '" + strong + "']");