From 33703834814c2250d5f8f88a206ac09a2552f1be Mon Sep 17 00:00:00 2001 From: EnZaXD Date: Sun, 2 Jun 2024 09:04:17 +0200 Subject: [PATCH] Add firework flight length fix from VV (#769) --- .../rewriter/BlockItemPacketRewriter1_20_5.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java index 612d891c..78afc206 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java @@ -27,7 +27,11 @@ import com.viaversion.viabackwards.protocol.v1_20_5to1_20_3.Protocol1_20_5To1_20 import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.Particle; +import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer; +import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey; import com.viaversion.viaversion.api.minecraft.item.Item; +import com.viaversion.viaversion.api.minecraft.item.data.FireworkExplosion; +import com.viaversion.viaversion.api.minecraft.item.data.Fireworks; import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2; import com.viaversion.viaversion.api.type.types.version.Types1_20_3; @@ -320,6 +324,12 @@ public final class BlockItemPacketRewriter1_20_5 extends BackwardsStructuredItem super.handleItemToClient(connection, item); + // In 1.20.6, some items have default values which are not written into the components + final StructuredDataContainer data = item.structuredData(); + if (item.identifier() == 1105 && !data.contains(StructuredDataKey.FIREWORKS)) { + data.set(StructuredDataKey.FIREWORKS, new Fireworks(1, new FireworkExplosion[0])); + } + final Item oldItem = vvProtocol.getItemRewriter().toOldItem(connection, item, DATA_CONVERTER); if (oldItem.tag() != null && oldItem.tag().isEmpty()) { // Improve item equality checks by removing empty tags