NaturesAura/src/main/java/de/ellpeck/naturesaura/items/ItemGoldFiber.java
2021-01-14 23:15:02 +01:00

33 lines
1,010 B
Java

package de.ellpeck.naturesaura.items;
import de.ellpeck.naturesaura.blocks.BlockGoldenLeaves;
import de.ellpeck.naturesaura.reg.IColorProvidingItem;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.util.ActionResultType;
public class ItemGoldFiber extends ItemImpl implements IColorProvidingItem {
public ItemGoldFiber() {
super("gold_fiber");
}
@Override
public IItemColor getItemColor() {
return (stack, tintIndex) -> 0xF2FF00;
}
@Override
public ActionResultType onItemUse(ItemUseContext context) {
ItemStack stack = context.getPlayer().getHeldItem(context.getHand());
if (BlockGoldenLeaves.convert(context.getWorld(), context.getPos())) {
if (!context.getWorld().isRemote) {
stack.shrink(1);
}
return ActionResultType.SUCCESS;
}
return ActionResultType.PASS;
}
}