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 bph1, final Block bph2, final Properties a) {
        super(bph1, bph2, a);
        Validate.isInstanceOf((Class)AbstractBannerBlock.class, bph1);
        Validate.isInstanceOf((Class)AbstractBannerBlock.class, bph2);
    }
    
    public static void appendHoverTextFromBannerBlockEntityTag(final ItemStack ben, final List<Component> list) {
        final CompoundTag jt3 = ben.getTagElement("BlockEntityTag");
        if (jt3 == null || !jt3.contains("Patterns")) {
            return;
        }
        final ListTag jz4 = jt3.getList("Patterns", 10);
        for (int integer5 = 0; integer5 < jz4.size() && integer5 < 6; ++integer5) {
            final CompoundTag jt4 = jz4.getCompound(integer5);
            final DyeColor bdj7 = DyeColor.byId(jt4.getInt("Color"));
            final BannerPattern bwd8 = BannerPattern.byHash(jt4.getString("Pattern"));
            if (bwd8 != null) {
                list.add(new TranslatableComponent("block.minecraft.banner." + bwd8.getFilename() + '.' + bdj7.getName(), new Object[0]).withStyle(ChatFormatting.GRAY));
            }
        }
    }
    
    public DyeColor getColor() {
        return ((AbstractBannerBlock)this.getBlock()).getColor();
    }
    
    @Override
    public void appendHoverText(final ItemStack ben, @Nullable final Level bjw, final List<Component> list, final TooltipFlag bfw) {
        appendHoverTextFromBannerBlockEntityTag(ben, list);
    }
}
