From 5287d4fb4f69a1bedbad7d76e34dc49d163c35bb Mon Sep 17 00:00:00 2001 From: EnZaXD Date: Mon, 23 Sep 2024 19:24:46 +0200 Subject: [PATCH] Fix enchantment glint behaviour in 1.10->1.11 (#4156) --- .../rewriter/ItemPacketRewriter1_11.java | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_10to1_11/rewriter/ItemPacketRewriter1_11.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_10to1_11/rewriter/ItemPacketRewriter1_11.java index f7dcd7075..587f7f448 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_10to1_11/rewriter/ItemPacketRewriter1_11.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_10to1_11/rewriter/ItemPacketRewriter1_11.java @@ -19,6 +19,7 @@ package com.viaversion.viaversion.protocols.v1_10to1_11.rewriter; import com.viaversion.nbt.tag.ByteTag; import com.viaversion.nbt.tag.CompoundTag; +import com.viaversion.nbt.tag.ListTag; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.type.Types; @@ -55,6 +56,22 @@ public class ItemPacketRewriter1_11 extends ItemRewriterremoveUnchecked(nbtTagName()).asByte()); - if (item.tag().isEmpty()) { - item.setTag(null); + CompoundTag tag = item.tag(); + if (tag != null) { + if (tag.contains(nbtTagName())) { + item.setAmount(tag.removeUnchecked(nbtTagName()).asByte()); + if (tag.isEmpty()) { + item.setTag(null); + } + } + if (tag.remove(nbtTagName("clearEnch")) != null) { + tag.put("ench", new ListTag()); } } EntityMappings1_11.toServerItem(item); @@ -78,4 +101,4 @@ public class ItemPacketRewriter1_11 extends ItemRewriter