public static boolean canHarvestBlock(Block block, EntityPlayer player, int metadata) { if (block.blockMaterial.isToolNotRequired()) { return true; } ItemStack stack = player.inventory.getCurrentItem(); if (stack == null) { return player.canHarvestBlock(block); } List info = toolClasses.get(stack.getItem()); if (info == null) { return player.canHarvestBlock(block); } Object[] tmp = info.toArray(); String toolClass = (String) tmp[0]; int harvestLevel = (Integer) tmp[1]; Integer blockHarvestLevel = toolHarvestLevels.get(Arrays.asList(block, metadata, toolClass)); if (blockHarvestLevel == null) { return player.canHarvestBlock(block); } if (blockHarvestLevel > harvestLevel) { return false; } return true; }
public static boolean canToolHarvestBlock(Block block, int metadata, ItemStack stack) { if (stack == null) return false; List info = toolClasses.get(stack.getItem()); if (info == null) return false; Object[] tmp = info.toArray(); String toolClass = (String) tmp[0]; int harvestLevel = (Integer) tmp[1]; Integer blockHarvestLevel = toolHarvestLevels.get(Arrays.asList(block, metadata, toolClass)); return !(blockHarvestLevel == null || blockHarvestLevel > harvestLevel); }
public static boolean isToolEffective(ItemStack stack, Block block, int metadata) { List toolClass = toolClasses.get(stack.getItem()); return toolClass != null && toolEffectiveness.contains(Arrays.asList(block, metadata, toolClass.get(0))); }