62 lines
2.6 KiB
Java
62 lines
2.6 KiB
Java
package net.minecraft.world.item;
|
|
|
|
import net.minecraft.network.chat.TextComponent;
|
|
import net.minecraft.ChatFormatting;
|
|
import net.minecraft.network.chat.TranslatableComponent;
|
|
import net.minecraft.nbt.CompoundTag;
|
|
import net.minecraft.network.chat.Component;
|
|
import java.util.List;
|
|
import javax.annotation.Nullable;
|
|
import net.minecraft.world.level.Level;
|
|
|
|
public class FireworkStarItem extends Item {
|
|
public FireworkStarItem(final Properties a) {
|
|
super(a);
|
|
}
|
|
|
|
@Override
|
|
public void appendHoverText(final ItemStack bek, @Nullable final Level bjt, final List<Component> list, final TooltipFlag bft) {
|
|
final CompoundTag jt6 = bek.getTagElement("Explosion");
|
|
if (jt6 != null) {
|
|
appendHoverText(jt6, list);
|
|
}
|
|
}
|
|
|
|
public static void appendHoverText(final CompoundTag jt, final List<Component> list) {
|
|
final FireworkRocketItem.Shape a3 = FireworkRocketItem.Shape.byId(jt.getByte("Type"));
|
|
list.add(new TranslatableComponent("item.minecraft.firework_star.shape." + a3.getName(), new Object[0]).withStyle(ChatFormatting.GRAY));
|
|
final int[] arr4 = jt.getIntArray("Colors");
|
|
if (arr4.length > 0) {
|
|
list.add(appendColors(new TextComponent("").withStyle(ChatFormatting.GRAY), arr4));
|
|
}
|
|
final int[] arr5 = jt.getIntArray("FadeColors");
|
|
if (arr5.length > 0) {
|
|
list.add(appendColors(new TranslatableComponent("item.minecraft.firework_star.fade_to", new Object[0]).append(" ").withStyle(ChatFormatting.GRAY), arr5));
|
|
}
|
|
if (jt.getBoolean("Trail")) {
|
|
list.add(new TranslatableComponent("item.minecraft.firework_star.trail", new Object[0]).withStyle(ChatFormatting.GRAY));
|
|
}
|
|
if (jt.getBoolean("Flicker")) {
|
|
list.add(new TranslatableComponent("item.minecraft.firework_star.flicker", new Object[0]).withStyle(ChatFormatting.GRAY));
|
|
}
|
|
}
|
|
|
|
private static Component appendColors(final Component lf, final int[] arr) {
|
|
for (int integer3 = 0; integer3 < arr.length; ++integer3) {
|
|
if (integer3 > 0) {
|
|
lf.append(", ");
|
|
}
|
|
lf.append(getColorName(arr[integer3]));
|
|
}
|
|
return lf;
|
|
}
|
|
|
|
private static Component getColorName(final int integer) {
|
|
final DyeColor bdg2 = DyeColor.byFireworkColor(integer);
|
|
if (bdg2 == null) {
|
|
return new TranslatableComponent("item.minecraft.firework_star.custom_color", new Object[0]);
|
|
}
|
|
return new TranslatableComponent("item.minecraft.firework_star." + bdg2.getName(), new Object[0]);
|
|
}
|
|
}
|