48 lines
2.0 KiB
Java
48 lines
2.0 KiB
Java
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 bpe1, final Block bpe2, final Properties a) {
|
|
super(bpe1, bpe2, a);
|
|
Validate.isInstanceOf((Class)AbstractBannerBlock.class, bpe1);
|
|
Validate.isInstanceOf((Class)AbstractBannerBlock.class, bpe2);
|
|
}
|
|
|
|
public static void appendHoverTextFromBannerBlockEntityTag(final ItemStack bek, final List<Component> list) {
|
|
final CompoundTag jt3 = bek.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 bdg7 = DyeColor.byId(jt4.getInt("Color"));
|
|
final BannerPattern bwa8 = BannerPattern.byHash(jt4.getString("Pattern"));
|
|
if (bwa8 != null) {
|
|
list.add(new TranslatableComponent("block.minecraft.banner." + bwa8.getFilename() + '.' + bdg7.getName(), new Object[0]).withStyle(ChatFormatting.GRAY));
|
|
}
|
|
}
|
|
}
|
|
|
|
public DyeColor getColor() {
|
|
return ((AbstractBannerBlock)this.getBlock()).getColor();
|
|
}
|
|
|
|
@Override
|
|
public void appendHoverText(final ItemStack bek, @Nullable final Level bjt, final List<Component> list, final TooltipFlag bft) {
|
|
appendHoverTextFromBannerBlockEntityTag(bek, list);
|
|
}
|
|
}
|