package net.minecraft.world.item;

import javax.annotation.Nullable;
import net.minecraft.world.level.Level;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.level.block.entity.BannerPattern;
import net.minecraft.network.chat.Component;
import java.util.List;
import org.apache.commons.lang3.Validate;
import net.minecraft.world.level.block.AbstractBannerBlock;
import net.minecraft.world.level.block.Block;

public class BannerItem extends StandingAndWallBlockItem {
    public BannerItem(final Block bvr1, final Block bvr2, final Properties a) {
        super(bvr1, bvr2, a);
        Validate.isInstanceOf((Class)AbstractBannerBlock.class, bvr1);
        Validate.isInstanceOf((Class)AbstractBannerBlock.class, bvr2);
    }
    
    public static void appendHoverTextFromBannerBlockEntityTag(final ItemStack bki, final List<Component> list) {
        final CompoundTag le3 = bki.getTagElement("BlockEntityTag");
        if (le3 == null || !le3.contains("Patterns")) {
            return;
        }
        final ListTag lk4 = le3.getList("Patterns", 10);
        for (int integer5 = 0; integer5 < lk4.size() && integer5 < 6; ++integer5) {
            final CompoundTag le4 = lk4.getCompound(integer5);
            final DyeColor bje7 = DyeColor.byId(le4.getInt("Color"));
            final BannerPattern cdd8 = BannerPattern.byHash(le4.getString("Pattern"));
            if (cdd8 != null) {
                list.add(new TranslatableComponent("block.minecraft.banner." + cdd8.getFilename() + '.' + bje7.getName()).withStyle(ChatFormatting.GRAY));
            }
        }
    }
    
    public DyeColor getColor() {
        return ((AbstractBannerBlock)this.getBlock()).getColor();
    }
    
    @Override
    public void appendHoverText(final ItemStack bki, @Nullable final Level bqb, final List<Component> list, final TooltipFlag bls) {
        appendHoverTextFromBannerBlockEntityTag(bki, list);
    }
}
