From 1aa80ed1c6bedbed90b02595e24f6b52feacd6c7 Mon Sep 17 00:00:00 2001 From: CovertJaguar Date: Wed, 11 Apr 2012 21:16:56 -0700 Subject: [PATCH] Added a function for checking block harvest levels without having to resort to reflection. --- .../minecraft/src/forge/MinecraftForge.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/forge/forge_common/net/minecraft/src/forge/MinecraftForge.java b/forge/forge_common/net/minecraft/src/forge/MinecraftForge.java index a55e05f2d..8cb67298e 100755 --- a/forge/forge_common/net/minecraft/src/forge/MinecraftForge.java +++ b/forge/forge_common/net/minecraft/src/forge/MinecraftForge.java @@ -421,6 +421,26 @@ public class MinecraftForge ForgeHooks.toolEffectiveness.add(key); } } + + /** Returns the block harvest level for a particular tool class. + * + * @param block The block to check. + * @param metadata The metadata for the block subtype. + * @param toolClass The tool class to check as able to remove this block. + * @see setToolClass for details on tool classes. + * @return The harvest level or -1 if no mapping exists. + */ + public static int getBlockHarvestLevel(Block block, int metadata, String toolClass) + { + ForgeHooks.initTools(); + List key = Arrays.asList(block.blockID, metadata, toolClass); + Integer harvestLevel = (Integer)ForgeHooks.toolHarvestLevels.get(key); + if(harvestLevel == null) + { + return -1; + } + return harvestLevel; + } /** Remove a block effectiveness mapping. Since setBlockHarvestLevel * makes the tool class effective against the block by default, this can be