mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-12-23 08:57:39 +01:00
Fix firework rewriting in 1.20.3->.5 (#3860)
Makes the explosion tag optional like it is in 1.20.4 so the tooltip shows the correct duration when crafting a firework, also fixes the type used for Flight which is byte in 1.20.4
This commit is contained in:
parent
f92d241028
commit
7d9c6fea69
@ -499,9 +499,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
final CompoundTag fireworksTag = tag.getCompoundTag("Fireworks");
|
final CompoundTag fireworksTag = tag.getCompoundTag("Fireworks");
|
||||||
if (fireworksTag != null) {
|
if (fireworksTag != null) {
|
||||||
final ListTag<CompoundTag> explosionsTag = fireworksTag.getListTag("Explosions", CompoundTag.class);
|
final ListTag<CompoundTag> explosionsTag = fireworksTag.getListTag("Explosions", CompoundTag.class);
|
||||||
if (explosionsTag != null) {
|
updateFireworks(data, fireworksTag, explosionsTag);
|
||||||
updateFireworks(data, fireworksTag, explosionsTag);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (old.identifier() == 1085) {
|
if (old.identifier() == 1085) {
|
||||||
@ -1022,10 +1020,11 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateFireworks(final StructuredDataContainer data, final CompoundTag fireworksTag, final ListTag<CompoundTag> explosionsTag) {
|
private void updateFireworks(final StructuredDataContainer data, final CompoundTag fireworksTag, final ListTag<CompoundTag> explosionsTag) {
|
||||||
final int flightDuration = fireworksTag.getInt("Flight");
|
final int flightDuration = fireworksTag.getByte("Flight");
|
||||||
final Fireworks fireworks = new Fireworks(
|
final Fireworks fireworks = new Fireworks(
|
||||||
flightDuration,
|
flightDuration,
|
||||||
explosionsTag.stream().limit(256).map(this::readExplosion).toArray(FireworkExplosion[]::new)
|
explosionsTag != null ? explosionsTag.stream().limit(256).
|
||||||
|
map(this::readExplosion).toArray(FireworkExplosion[]::new) : new FireworkExplosion[0]
|
||||||
);
|
);
|
||||||
data.set(StructuredDataKey.FIREWORKS, fireworks);
|
data.set(StructuredDataKey.FIREWORKS, fireworks);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user