@Override public boolean canHarvestBlock(Block block, ItemStack itemStack) { ToolMaterial toolMaterial = ToolMaterial.values()[itemStack.stackTagCompound.getInteger("material")]; try { if (block.getBlockHardness(null, 0, 0, 0) == -1) { return false; } } catch (NullPointerException e) { return false; } if (block.getMaterial().isToolNotRequired()) { return true; } if (toolMaterial == ToolMaterial.WOOD) { return Items.wooden_pickaxe.func_150897_b /*canHarvestBlock*/(block) || Items.wooden_shovel.func_150897_b(block); } else if (toolMaterial == ToolMaterial.STONE) { return Items.stone_pickaxe.func_150897_b(block) || Items.stone_shovel.func_150897_b(block); } else if (toolMaterial == ToolMaterial.EMERALD) { return Items.diamond_pickaxe.func_150897_b(block) || Items.diamond_shovel.func_150897_b(block); } else if (toolMaterial == ToolMaterial.IRON) { return Items.iron_pickaxe.func_150897_b(block) || Items.iron_shovel.func_150897_b(block); } else if (toolMaterial == ToolMaterial.GOLD) { return Items.golden_pickaxe.func_150897_b(block) || Items.golden_shovel.func_150897_b(block); } return toolMaterial.getHarvestLevel() >= block.getHarvestLevel(0); }
@Override public int getHarvestLevel(ItemStack stack, String toolClass) { ToolMaterial toolMaterial = ToolMaterial.values()[stack.stackTagCompound.getInteger("material")]; if (toolClass.equals("pickaxe") || toolClass.equals("shovel")) { return toolMaterial.getHarvestLevel(); } else { return -1; } }
private static void setPaxelHarvest(Item item, ToolMaterial material) { item.setHarvestLevel("pickaxe", material.getHarvestLevel()); item.setHarvestLevel("axe", material.getHarvestLevel()); item.setHarvestLevel("shovel", material.getHarvestLevel()); }
/** * Adds a tool material to TConstruct * * @param name Name of the material * @param stack The stack used to create the material * @param ID The unique ID of the material * @param mat The base tool material used to generate values * @param tooltipColor The colour in the item tooltip * @param hexColor The actual colour of the Item * @param handleMod The handle modifier of the material * @param reinforced The reinforced trait of the material * @param stonebound The stonebound modifier of the material, negative is jagged * @param maxDamage The base speed of the bow * @param bowMaxSpeed The max speed of the bow * @param arrowWeight The weight of the arrow * @param arrowBreakChance The chance that the arrow will survive on impact * @param inGame The in game name of the material * @param casting Whether or not this needs casting (true) or part building (false) */ public static void createToolSet( String name, ItemStack stack, int ID, ToolMaterial mat, EnumChatFormatting tooltipColor, int hexColor, float handleMod, int reinforced, float stonebound, int maxDamage, float bowMaxSpeed, float arrowWeight, float arrowBreakChance, String inGame, boolean casting, boolean instant) { pb.registerMaterialSet( name, new ItemStack(TinkerTools.toolShard, 1, ID), new ItemStack(TinkerTools.toolRod, 1, ID), 32); TConstructClientRegistry.addMaterialRenderMapping(ID, "tinker", name, true); if (Loader.isModLoaded("IguanaTweaksTConstruct")) // ID, MaterialName, HarvestLevel, BaseDurability, MiningSpeed, Attack, // handleModifier, ReinforcedLevel, stonebound TConstructRegistry.addToolMaterial( ID, name, mat.getHarvestLevel() + 2, mat.getMaxUses(), instant ? Integer.MAX_VALUE : (int) mat.getEfficiencyOnProperMaterial() * 100, (int) mat.getDamageVsEntity(), handleMod, reinforced, stonebound, tooltipColor.toString(), hexColor); else TConstructRegistry.addToolMaterial( ID, name, mat.getHarvestLevel(), mat.getMaxUses(), instant ? Integer.MAX_VALUE : (int) mat.getEfficiencyOnProperMaterial() * 100, (int) mat.getDamageVsEntity(), handleMod, reinforced, stonebound, tooltipColor.toString(), hexColor); // MatID, DrawSpeed, maxSpeed TConstructRegistry.addBowMaterial(ID, maxDamage, bowMaxSpeed); // MatID, Weight, BreakChance TConstructRegistry.addArrowMaterial(ID, arrowWeight, arrowBreakChance); // TinkerTools.registerPatternMaterial(name, 2, name); TConstructRegistry.addDefaultToolPartMaterial(ID); pb.registerFullMaterial( stack, 2, name, new ItemStack(TinkerTools.toolShard, 1, ID), new ItemStack(TinkerTools.toolRod, 1, ID), ID); LanguageRegistry.instance() .addStringLocalization("material." + name.toLowerCase(), "en_US", inGame); // LogHelper.info("Looking for %s to localise to %s", "material."+name, inGame); registerWithStations(stack, name, ID); if (!casting) addPartBuilding(ID); // else addCasting(null, ID); }