forked from GeyserMC/Geyser
Check if firework item explosions tag is null (#626)
This commit is contained in:
parent
a49f6fe0e3
commit
fe6257bb38
1 changed files with 34 additions and 32 deletions
|
@ -39,49 +39,51 @@ public class FireworkTranslator extends NbtItemStackTranslator {
|
||||||
CompoundTag fireworks = itemTag.get("Fireworks");
|
CompoundTag fireworks = itemTag.get("Fireworks");
|
||||||
|
|
||||||
ListTag explosions = fireworks.get("Explosions");
|
ListTag explosions = fireworks.get("Explosions");
|
||||||
for (Tag effect : explosions.getValue()) {
|
if (explosions != null) {
|
||||||
CompoundTag effectData = (CompoundTag) effect;
|
for (Tag effect : explosions.getValue()) {
|
||||||
|
CompoundTag effectData = (CompoundTag) effect;
|
||||||
|
|
||||||
CompoundTag newEffectData = new CompoundTag("");
|
CompoundTag newEffectData = new CompoundTag("");
|
||||||
|
|
||||||
if (effectData.get("Type") != null) {
|
if (effectData.get("Type") != null) {
|
||||||
newEffectData.put(new ByteTag("FireworkType", (Byte) effectData.get("Type").getValue()));
|
newEffectData.put(new ByteTag("FireworkType", (Byte) effectData.get("Type").getValue()));
|
||||||
}
|
|
||||||
|
|
||||||
if (effectData.get("Colors") != null) {
|
|
||||||
int[] oldColors = (int[]) effectData.get("Colors").getValue();
|
|
||||||
byte[] colors = new byte[oldColors.length];
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
for (int color : oldColors) {
|
|
||||||
colors[i++] = FireworkColor.fromJavaID(color).getBedrockID();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
newEffectData.put(new ByteArrayTag("FireworkColor", colors));
|
if (effectData.get("Colors") != null) {
|
||||||
}
|
int[] oldColors = (int[]) effectData.get("Colors").getValue();
|
||||||
|
byte[] colors = new byte[oldColors.length];
|
||||||
|
|
||||||
if (effectData.get("FadeColors") != null) {
|
int i = 0;
|
||||||
int[] oldColors = (int[]) effectData.get("FadeColors").getValue();
|
for (int color : oldColors) {
|
||||||
byte[] colors = new byte[oldColors.length];
|
colors[i++] = FireworkColor.fromJavaID(color).getBedrockID();
|
||||||
|
}
|
||||||
|
|
||||||
int i = 0;
|
newEffectData.put(new ByteArrayTag("FireworkColor", colors));
|
||||||
for (int color : oldColors) {
|
|
||||||
colors[i++] = FireworkColor.fromJavaID(color).getBedrockID();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
newEffectData.put(new ByteArrayTag("FireworkFade", colors));
|
if (effectData.get("FadeColors") != null) {
|
||||||
}
|
int[] oldColors = (int[]) effectData.get("FadeColors").getValue();
|
||||||
|
byte[] colors = new byte[oldColors.length];
|
||||||
|
|
||||||
if (effectData.get("Trail") != null) {
|
int i = 0;
|
||||||
newEffectData.put(new ByteTag("FireworkTrail", (Byte) effectData.get("Trail").getValue()));
|
for (int color : oldColors) {
|
||||||
}
|
colors[i++] = FireworkColor.fromJavaID(color).getBedrockID();
|
||||||
|
}
|
||||||
|
|
||||||
if (effectData.get("Flicker") != null) {
|
newEffectData.put(new ByteArrayTag("FireworkFade", colors));
|
||||||
newEffectData.put(new ByteTag("FireworkFlicker", (Byte) effectData.get("Flicker").getValue()));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
explosions.remove(effect);
|
if (effectData.get("Trail") != null) {
|
||||||
explosions.add(newEffectData);
|
newEffectData.put(new ByteTag("FireworkTrail", (Byte) effectData.get("Trail").getValue()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (effectData.get("Flicker") != null) {
|
||||||
|
newEffectData.put(new ByteTag("FireworkFlicker", (Byte) effectData.get("Flicker").getValue()));
|
||||||
|
}
|
||||||
|
|
||||||
|
explosions.remove(effect);
|
||||||
|
explosions.add(newEffectData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue