package net.minecraft.world.item;

import net.minecraft.tags.ItemTags;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.network.chat.Component;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.block.DispenserBlock;

public class ShieldItem extends Item {
    public ShieldItem(final Properties a) {
        super(a);
        DispenserBlock.registerBehavior(this, ArmorItem.DISPENSE_ITEM_BEHAVIOR);
    }
    
    @Override
    public String getDescriptionId(final ItemStack bki) {
        if (bki.getTagElement("BlockEntityTag") != null) {
            return this.getDescriptionId() + '.' + getColor(bki).getName();
        }
        return super.getDescriptionId(bki);
    }
    
    @Override
    public void appendHoverText(final ItemStack bki, @Nullable final Level bqb, final List<Component> list, final TooltipFlag bls) {
        BannerItem.appendHoverTextFromBannerBlockEntityTag(bki, list);
    }
    
    @Override
    public UseAnim getUseAnimation(final ItemStack bki) {
        return UseAnim.BLOCK;
    }
    
    @Override
    public int getUseDuration(final ItemStack bki) {
        return 72000;
    }
    
    @Override
    public InteractionResultHolder<ItemStack> use(final Level bqb, final Player bec, final InteractionHand anf) {
        final ItemStack bki5 = bec.getItemInHand(anf);
        bec.startUsingItem(anf);
        return InteractionResultHolder.<ItemStack>consume(bki5);
    }
    
    @Override
    public boolean isValidRepairItem(final ItemStack bki1, final ItemStack bki2) {
        return ItemTags.PLANKS.contains(bki2.getItem()) || super.isValidRepairItem(bki1, bki2);
    }
    
    public static DyeColor getColor(final ItemStack bki) {
        return DyeColor.byId(bki.getOrCreateTagElement("BlockEntityTag").getInt("Base"));
    }
}
