mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-06-28 13:19:09 +02:00
70 lines
2.4 KiB
Java
70 lines
2.4 KiB
Java
package de.ellpeck.naturesaura.items.tools;
|
|
|
|
import de.ellpeck.naturesaura.Helper;
|
|
import de.ellpeck.naturesaura.NaturesAura;
|
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityWoodStand;
|
|
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.LogBlock;
|
|
import net.minecraft.block.material.Material;
|
|
import net.minecraft.entity.player.PlayerEntity;
|
|
import net.minecraft.item.AxeItem;
|
|
import net.minecraft.item.IItemTier;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.nbt.CompoundNBT;
|
|
import net.minecraft.util.math.BlockPos;
|
|
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 (state.getMaterial() == Material.LEAVES) {
|
|
return this.efficiency;
|
|
} else {
|
|
return super.getDestroySpeed(stack, state);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, PlayerEntity player) {
|
|
if (itemstack.getItem() == ModItems.SKY_AXE) {
|
|
if (player.world.getBlockState(pos).getBlock() instanceof LogBlock) {
|
|
TileEntityWoodStand.recurseTreeDestruction(player.world, pos, pos, false, true);
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@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());
|
|
}
|
|
|
|
}
|