From 365040f59db0a42c51b8a81c9581f425c80fa0aa Mon Sep 17 00:00:00 2001 From: EnZaXD Date: Sun, 7 Jul 2024 17:39:30 +0200 Subject: [PATCH] Handle rarity changes in trident/banner pattern item in 1.20.5->1.21 (#4001) --- .../rewriter/BlockItemPacketRewriter1_21.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/BlockItemPacketRewriter1_21.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/BlockItemPacketRewriter1_21.java index 673928d2a..eb96cc491 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/BlockItemPacketRewriter1_21.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_5to1_21/rewriter/BlockItemPacketRewriter1_21.java @@ -17,7 +17,10 @@ */ package com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter; +import com.viaversion.nbt.tag.ByteTag; +import com.viaversion.nbt.tag.CompoundTag; import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.minecraft.data.StructuredData; import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer; import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey; import com.viaversion.viaversion.api.minecraft.item.Item; @@ -114,6 +117,17 @@ public final class BlockItemPacketRewriter1_21 extends StructuredItemRewriter customData = dataContainer.getNonEmpty(StructuredDataKey.CUSTOM_DATA); + if (customData == null) { + return; + } + if (customData.value().remove(tagName) != null) { + dataContainer.remove(StructuredDataKey.RARITY); + if (customData.value().isEmpty()) { + dataContainer.remove(StructuredDataKey.CUSTOM_DATA); + } + } + } + private int itemToJubeboxSong(final int id) { String identifier = Protocol1_20_5To1_21.MAPPINGS.getFullItemMappings().identifier(id); if (!identifier.contains("music_disc_")) {