mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-22 10:05:12 +01:00
Rewrite filtered_pages in 1.20.2->1.20.3 (#3983)
This commit is contained in:
parent
2417ffe483
commit
bca25d4744
@ -146,19 +146,23 @@ public final class BlockItemPacketRewriter1_20_3 extends ItemRewriter<Clientboun
|
||||
|
||||
final CompoundTag tag = item.tag();
|
||||
if (tag != null && item.identifier() == 1047) { // Written book
|
||||
updatePages(tag, "pages");
|
||||
updatePages(tag, "filtered_pages"); // TODO This isn't a list
|
||||
final ListTag<StringTag> 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<StringTag> pages = tag.getListTag(key, StringTag.class);
|
||||
if (pages == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (final StringTag pageTag : pages) {
|
||||
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());
|
||||
@ -167,4 +171,3 @@ public final class BlockItemPacketRewriter1_20_3 extends ItemRewriter<Clientboun
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user