Unicopia/src/main/java/com/minelittlepony/unicopia/toxin/ToxicBlockItem.java

49 lines
1.5 KiB
Java
Raw Normal View History

package com.minelittlepony.unicopia.toxin;
2020-01-27 11:05:22 +01:00
import java.util.List;
import javax.annotation.Nullable;
2020-01-27 13:47:14 +01:00
import net.minecraft.block.Block;
2020-01-27 11:05:22 +01:00
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
2020-01-27 13:47:14 +01:00
import net.minecraft.item.BlockItem;
2020-01-27 11:05:22 +01:00
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.UseAction;
import net.minecraft.world.World;
2020-04-25 16:07:09 +02:00
public class ToxicBlockItem extends BlockItem {
2020-01-27 11:05:22 +01:00
private final Toxic toxic;
2020-01-27 11:05:22 +01:00
public ToxicBlockItem(Block block, Settings settings, UseAction action, Toxicity toxicity, Toxin toxin) {
super(block, settings);
toxic = new Toxic(this, action, toxin, stack -> toxicity);
2020-01-27 11:05:22 +01:00
}
@Override
public UseAction getUseAction(ItemStack stack) {
return toxic.getUseAction(stack);
2020-01-27 11:05:22 +01:00
}
@Override
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context) {
tooltip.add(toxic.getTooltip(stack));
2020-01-27 11:05:22 +01:00
}
@Override
public ItemStack finishUsing(ItemStack stack, World world, LivingEntity entity) {
super.finishUsing(stack, world, entity);
return toxic.finishUsing(stack, world, entity);
2020-01-27 11:05:22 +01:00
}
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
return toxic.use(world, player, hand, () -> super.use(world, player, hand));
2020-01-27 11:05:22 +01:00
}
}