package de.ellpeck.naturesaura.items.tools; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.data.ItemModelGenerator; import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.reg.ICustomItemModel; import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.ModRegistry; import net.minecraft.block.BlockState; import net.minecraft.block.material.Material; import net.minecraft.item.AxeItem; import net.minecraft.item.IItemTier; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraftforge.common.capabilities.ICapabilityProvider; import javax.annotation.Nullable; public class ItemAxe extends AxeItem implements IModItem, ICustomItemModel { private final String baseName; public ItemAxe(String baseName, IItemTier material, float damage, float speed) { super(material, damage, speed, new Properties().group(NaturesAura.CREATIVE_TAB)); this.baseName = baseName; ModRegistry.add(this); } @Override public String getBaseName() { return this.baseName; } @Override public float getDestroySpeed(ItemStack stack, BlockState state) { if (this == ModItems.INFUSED_IRON_AXE && state.getMaterial() == Material.LEAVES) { return this.efficiency; } else { return super.getDestroySpeed(stack, state); } } @Nullable @Override public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundNBT nbt) { return Helper.makeRechargeProvider(stack, true); } @Override public void generateCustomItemModel(ItemModelGenerator generator) { generator.withExistingParent(this.getBaseName(), "item/handheld").texture("layer0", "item/" + this.getBaseName()); } }