Cleanup Tools Module code (#5578)

* Make most mekanism tools extend the vanilla tool class

* Move things around slightly

* ATs and work on making the paxel's behaviour be identical to the axe, pickaxe, or shovel it represents

* Keep track of normal tools via the Paxel

* Set the Material's Repair Stack

* Cleanup material repair stack registry

* Small spacing changes

* Replace ToolsItems with ToolsItem

* Cleanup adding smelting recipes

* Move the various materials into an enum

* Ensure the Materials doesn't read the config values before the config is loaded if somewhere it is referenced ends up being called

* Minor cleanup/add some comments

* Show repair recipes in JEI, and fix it so that you can smelt any damage into a nugget like vanilla

* Minor code cleanup to entity equipment spawning

* Make sure the paxel canHarvestBlock uses the correct mining level

* Switch back to if statements for setting entity equipment

* Remove unneeded code that gets handled by ForgeHooks anyways

* Make sure to refresh the Item references
This commit is contained in:
Richard Freimer authored and GitHub committed 2019-08-04 20:01:42 -04:00
1 parent 0f5ef4e11e
commit 034340eed1
17 files changed
+479 -887

No files matched your search

@@ -1,36 +1,31 @@
package mekanism.tools.item;
import com.google.common.collect.Sets;
import java.util.Set;
import javax.annotation.Nonnull;
import mekanism.tools.common.ToolUtils;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import java.util.List;
import mekanism.common.util.LangUtils;
import mekanism.tools.common.IHasRepairType;
import mekanism.tools.common.Materials;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemPickaxe;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemMekanismPickaxe extends ItemMekanismTool {
public class ItemMekanismPickaxe extends ItemPickaxe implements IHasRepairType {
private static final Set<Block> EFFECTIVE_ON = Sets.newHashSet(Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK,
Blocks.DIAMOND_ORE, Blocks.DOUBLE_STONE_SLAB, Blocks.GOLDEN_RAIL, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE,
Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.LIT_REDSTONE_ORE, Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE,
Blocks.SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.STONE_SLAB, Blocks.STONE_BUTTON, Blocks.STONE_PRESSURE_PLATE);
public ItemMekanismPickaxe(ToolMaterial toolMaterial) {
super(1, -2.8F, toolMaterial, EFFECTIVE_ON);
public ItemMekanismPickaxe(Materials material) {
super(material.getMaterial());
setHarvestLevel("pickaxe", material.getMaterial().getHarvestLevel());
}
@Override
public boolean canHarvestBlock(@Nonnull IBlockState state, ItemStack stack) {
return ToolUtils.canPickaxeHarvest(state, toolMaterial);
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemstack, World world, List<String> list, ITooltipFlag flag) {
list.add(LangUtils.localize("tooltip.hp") + ": " + (itemstack.getMaxDamage() - itemstack.getItemDamage()));
}
@Override
public float getDestroySpeed(@Nonnull ItemStack itemstack, IBlockState blockState) {
if (blockState != null && (blockState.getMaterial() == Material.IRON || blockState.getMaterial() == Material.ANVIL || blockState.getMaterial() == Material.ROCK)) {
return efficiency;
}
return super.getDestroySpeed(itemstack, blockState);
public ItemStack getRepairStack() {
return toolMaterial.getRepairItemStack();
}
}