From d3d6d4f1cd4c16a0b52a12341e00a972aa9db2a1 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Mon, 22 Apr 2024 16:05:44 +0200 Subject: [PATCH] Fixes to hover event handling, some cleanup --- .../BlockItemPacketRewriter1_20_5.java | 7 ++++-- .../rewriter/ComponentRewriter1_20_5.java | 25 +++++++++++-------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java index 0f6b9ff6a..4c9945ef3 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/BlockItemPacketRewriter1_20_5.java @@ -468,7 +468,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter attributeModifiersTag = tag.getListTag("AttributeModifiers", CompoundTag.class); if (attributeModifiersTag != null) { - updateAttributes(data, tag, attributeModifiersTag, (hideFlagsValue & StructuredDataConverter.HIDE_ATTRIBUTES) == 0); + updateAttributes(data, attributeModifiersTag, (hideFlagsValue & StructuredDataConverter.HIDE_ATTRIBUTES) == 0); } final CompoundTag fireworksTag = tag.getCompoundTag("Fireworks"); @@ -653,6 +653,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter possibleEffects = new ArrayList<>(); for (final CompoundTag effect : possibleEffectsTag) { final CompoundTag potionEffectTag = effect.getCompoundTag("effect"); @@ -675,6 +676,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter rules = new ArrayList<>(); for (final CompoundTag tag : rulesTag) { HolderSet blocks = null; @@ -709,6 +711,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter attributeModifiersTag, final boolean showInTooltip) { + private void updateAttributes(final StructuredDataContainer data, final ListTag attributeModifiersTag, final boolean showInTooltip) { final List modifiers = new ArrayList<>(); for (int i = 0; i < attributeModifiersTag.size(); i++) { final CompoundTag modifierTag = attributeModifiersTag.get(i); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/ComponentRewriter1_20_5.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/ComponentRewriter1_20_5.java index a651b6282..60438b2f6 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/ComponentRewriter1_20_5.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/ComponentRewriter1_20_5.java @@ -196,10 +196,10 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter, StructuredData> data = newItem.structuredData().data(); if (!data.isEmpty()) { - CompoundTag components; + final CompoundTag components; try { components = toTag(data, false); - } catch (Exception e) { + } catch (final Exception e) { if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) { Via.getPlatform().getLogger().log(Level.WARNING, "Error writing 1.20.5 components in show_item!", e); } @@ -783,7 +788,7 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter tag = new ListTag<>(CompoundTag.class); final ListTag items = convertItemArray(value); for (int i = 0; i < items.size(); i++) { - final CompoundTag itemTag = items.get(i); + final CompoundTag itemTag = new CompoundTag(); itemTag.putInt("slot", i); itemTag.put("item", items.get(i)); tag.add(itemTag); @@ -942,11 +947,11 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter