Skip to content

Commit e5db448

Browse files
committed
Fix 1.16->1.15 hover components in books
Fixes #3411
1 parent 082b61a commit e5db448

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/packets/BlockItemPackets1_16.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@
3333
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
3434
import com.viaversion.viaversion.api.type.Type;
3535
import com.viaversion.viaversion.api.type.types.UUIDIntArrayType;
36+
import com.viaversion.viaversion.libs.gson.JsonElement;
3637
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
3738
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntArrayTag;
39+
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
3840
import com.viaversion.viaversion.libs.opennbt.tag.builtin.LongArrayTag;
3941
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
4042
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
@@ -302,6 +304,22 @@ public Item handleItemToClient(Item item) {
302304
}
303305
}
304306

307+
// Handle hover event changes in book pages
308+
if ((item.identifier() == 758 || item.identifier() == 759) && tag != null) {
309+
Tag pagesTag = tag.get("pages");
310+
if (pagesTag instanceof ListTag) {
311+
for (Tag page : ((ListTag) pagesTag)) {
312+
if (!(page instanceof StringTag)) {
313+
continue;
314+
}
315+
316+
StringTag pageTag = (StringTag) page;
317+
JsonElement jsonElement = protocol.getTranslatableRewriter().processText(pageTag.getValue());
318+
pageTag.setValue(jsonElement.toString());
319+
}
320+
}
321+
}
322+
305323
InventoryPackets.newToOldAttributes(item);
306324
enchantmentRewriter.handleToClient(item);
307325
return item;

0 commit comments

Comments
 (0)