package net.minecraft.world.item;

import net.minecraft.stats.Stat;
import net.minecraft.stats.Stats;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.entity.ItemSteerable;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.entity.EntityType;

public class FoodOnAStickItem<T extends Entity> extends Item {
    private final EntityType<T> canInteractWith;
    private final int consumeItemDamage;
    
    public FoodOnAStickItem(final Properties a, final EntityType<T> aoq, final int integer) {
        super(a);
        this.canInteractWith = aoq;
        this.consumeItemDamage = integer;
    }
    
    @Override
    public InteractionResultHolder<ItemStack> use(final Level bqb, final Player bec, final InteractionHand anf) {
        final ItemStack bki5 = bec.getItemInHand(anf);
        if (bqb.isClientSide) {
            return InteractionResultHolder.<ItemStack>pass(bki5);
        }
        final Entity aom6 = bec.getVehicle();
        if (bec.isPassenger() && aom6 instanceof ItemSteerable && aom6.getType() == this.canInteractWith) {
            final ItemSteerable aow7 = (ItemSteerable)aom6;
            if (aow7.boost()) {
                bki5.<Player>hurtAndBreak(this.consumeItemDamage, bec, bec -> bec.broadcastBreakEvent(anf));
                if (bki5.isEmpty()) {
                    final ItemStack bki6 = new ItemStack(Items.FISHING_ROD);
                    bki6.setTag(bki5.getTag());
                    return InteractionResultHolder.<ItemStack>success(bki6);
                }
                return InteractionResultHolder.<ItemStack>success(bki5);
            }
        }
        bec.awardStat(Stats.ITEM_USED.get(this));
        return InteractionResultHolder.<ItemStack>pass(bki5);
    }
}
