NaturesAura/src/main/java/de/ellpeck/naturesaura/items/GoldFiber.java

39 lines
1.3 KiB
Java
Raw Normal View History

2018-10-15 18:36:46 +02:00
package de.ellpeck.naturesaura.items;
2019-11-04 19:08:49 +01:00
import de.ellpeck.naturesaura.NaturesAura;
2018-10-15 18:36:46 +02:00
import de.ellpeck.naturesaura.blocks.BlockGoldenLeaves;
import de.ellpeck.naturesaura.reg.IColorProvidingItem;
import net.minecraft.client.renderer.color.IItemColor;
2019-10-20 22:30:49 +02:00
import net.minecraft.entity.player.PlayerEntity;
2018-10-15 18:36:46 +02:00
import net.minecraft.item.ItemStack;
2019-11-04 19:08:49 +01:00
import net.minecraft.item.ItemUseContext;
2019-10-20 22:30:49 +02:00
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
2018-10-15 18:36:46 +02:00
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
2019-11-04 19:08:49 +01:00
public class GoldFiber extends ItemImpl implements IColorProvidingItem {
2018-10-15 18:36:46 +02:00
2019-11-04 19:08:49 +01:00
public GoldFiber() {
super("gold_fiber", new Properties().group(NaturesAura.CREATIVE_TAB));
2018-10-15 18:36:46 +02:00
}
@Override
public IItemColor getItemColor() {
return (stack, tintIndex) -> 0xF2FF00;
}
@Override
2019-11-04 19:08:49 +01:00
public ActionResultType onItemUse(ItemUseContext context) {
ItemStack stack = context.getPlayer().getHeldItem(context.getHand());
if (BlockGoldenLeaves.convert(context.getWorld(), context.getPos())) {
if (!context.getWorld().isRemote) {
2018-10-15 18:36:46 +02:00
stack.shrink(1);
}
2019-10-20 22:30:49 +02:00
return ActionResultType.SUCCESS;
2018-10-15 18:36:46 +02:00
}
2019-10-20 22:30:49 +02:00
return ActionResultType.PASS;
2018-10-15 18:36:46 +02:00
}
}