2018-10-19 18:32:20 +02:00
|
|
|
package de.ellpeck.naturesaura.items.tools;
|
|
|
|
|
2018-10-20 21:19:08 +02:00
|
|
|
import de.ellpeck.naturesaura.Helper;
|
2019-11-04 19:08:49 +01:00
|
|
|
import de.ellpeck.naturesaura.NaturesAura;
|
2020-01-29 00:40:28 +01:00
|
|
|
import de.ellpeck.naturesaura.data.ItemModelGenerator;
|
2018-10-20 00:54:33 +02:00
|
|
|
import de.ellpeck.naturesaura.items.ModItems;
|
2020-01-29 00:40:28 +01:00
|
|
|
import de.ellpeck.naturesaura.reg.ICustomItemModel;
|
2018-10-19 18:32:20 +02:00
|
|
|
import de.ellpeck.naturesaura.reg.IModItem;
|
2020-01-22 01:32:26 +01:00
|
|
|
import de.ellpeck.naturesaura.reg.ModRegistry;
|
2019-10-20 22:30:49 +02:00
|
|
|
import net.minecraft.block.BlockState;
|
2019-11-04 19:08:49 +01:00
|
|
|
import net.minecraft.block.material.Material;
|
2019-10-20 22:30:49 +02:00
|
|
|
import net.minecraft.item.AxeItem;
|
2019-11-04 19:08:49 +01:00
|
|
|
import net.minecraft.item.IItemTier;
|
2018-10-20 00:54:33 +02:00
|
|
|
import net.minecraft.item.ItemStack;
|
2019-10-20 22:30:49 +02:00
|
|
|
import net.minecraft.nbt.CompoundNBT;
|
2018-10-20 21:19:08 +02:00
|
|
|
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
2018-10-19 18:32:20 +02:00
|
|
|
|
2018-10-20 21:19:08 +02:00
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
2020-01-29 00:40:28 +01:00
|
|
|
public class ItemAxe extends AxeItem implements IModItem, ICustomItemModel {
|
2018-10-19 18:32:20 +02:00
|
|
|
private final String baseName;
|
|
|
|
|
2020-01-26 01:41:49 +01:00
|
|
|
public ItemAxe(String baseName, IItemTier material, float damage, float speed) {
|
2019-11-04 19:08:49 +01:00
|
|
|
super(material, damage, speed, new Properties().group(NaturesAura.CREATIVE_TAB));
|
2018-10-19 18:32:20 +02:00
|
|
|
this.baseName = baseName;
|
2020-01-22 01:32:26 +01:00
|
|
|
ModRegistry.add(this);
|
2018-10-19 18:32:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getBaseName() {
|
|
|
|
return this.baseName;
|
|
|
|
}
|
|
|
|
|
2018-10-20 00:54:33 +02:00
|
|
|
@Override
|
2019-10-20 22:30:49 +02:00
|
|
|
public float getDestroySpeed(ItemStack stack, BlockState state) {
|
2020-01-23 19:20:47 +01:00
|
|
|
if (this == ModItems.INFUSED_IRON_AXE && state.getMaterial() == Material.LEAVES) {
|
2018-10-20 00:54:33 +02:00
|
|
|
return this.efficiency;
|
|
|
|
} else {
|
|
|
|
return super.getDestroySpeed(stack, state);
|
|
|
|
}
|
|
|
|
}
|
2018-10-20 21:19:08 +02:00
|
|
|
|
|
|
|
@Nullable
|
|
|
|
@Override
|
2019-10-20 22:30:49 +02:00
|
|
|
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundNBT nbt) {
|
2020-01-23 19:20:47 +01:00
|
|
|
if (this == ModItems.INFUSED_IRON_AXE)
|
2018-12-01 18:56:05 +01:00
|
|
|
return Helper.makeRechargeProvider(stack, true);
|
2018-10-20 21:19:08 +02:00
|
|
|
else return null;
|
|
|
|
}
|
2020-01-29 00:40:28 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void generateCustomItemModel(ItemModelGenerator generator) {
|
|
|
|
generator.withExistingParent(this.getBaseName(), "item/handheld").texture("layer0", "item/" + this.getBaseName());
|
|
|
|
}
|
|
|
|
|
2018-10-19 18:32:20 +02:00
|
|
|
}
|