From bca25d4744d495771b9b5bc5e0536a866eec2bfe Mon Sep 17 00:00:00 2001 From: EnZaXD Date: Wed, 26 Jun 2024 10:58:50 +0200 Subject: [PATCH] Rewrite filtered_pages in 1.20.2->1.20.3 (#3983) --- .../BlockItemPacketRewriter1_20_3.java | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_2to1_20_3/rewriter/BlockItemPacketRewriter1_20_3.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_2to1_20_3/rewriter/BlockItemPacketRewriter1_20_3.java index f2d0e78f9..066ce66fe 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_2to1_20_3/rewriter/BlockItemPacketRewriter1_20_3.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_20_2to1_20_3/rewriter/BlockItemPacketRewriter1_20_3.java @@ -146,25 +146,28 @@ public final class BlockItemPacketRewriter1_20_3 extends ItemRewriter pages = tag.getListTag("pages", StringTag.class); + if (pages != null) { + for (final StringTag pageTag : pages) { + updatePageTag(pageTag); + } + } + final CompoundTag filteredPages = tag.getCompoundTag("filtered_pages"); + if (filteredPages != null) { + for (final String string : filteredPages.keySet()) { + updatePageTag(filteredPages.getStringTag(string)); + } + } } return super.handleItemToClient(connection, item); } - private void updatePages(final CompoundTag tag, final String key) { - final ListTag pages = tag.getListTag(key, StringTag.class); - if (pages == null) { - return; - } - - for (final StringTag pageTag : pages) { - try { - final JsonElement updatedComponent = ComponentUtil.convertJson(pageTag.getValue(), SerializerVersion.V1_19_4, SerializerVersion.V1_20_3); - pageTag.setValue(updatedComponent.toString()); - } catch (final Exception e) { - Via.getManager().debugHandler().error("Error during book conversion", e); - } + private void updatePageTag(final StringTag pageTag) { + try { + final JsonElement updatedComponent = ComponentUtil.convertJson(pageTag.getValue(), SerializerVersion.V1_19_4, SerializerVersion.V1_20_3); + pageTag.setValue(updatedComponent.toString()); + } catch (final Exception e) { + Via.getManager().debugHandler().error("Error during book conversion", e); } } } \ No newline at end of file