fix editBook sending invalid packet in 1.13+#3677
Open
autowert66 wants to merge 8 commits intoPrismarineJS:masterfrom
Open
fix editBook sending invalid packet in 1.13+#3677autowert66 wants to merge 8 commits intoPrismarineJS:masterfrom
autowert66 wants to merge 8 commits intoPrismarineJS:masterfrom
Conversation
Contributor
Author
|
Should fix #3495 |
Verifies that the edit_book packet sends the correct fields for both NBT-based versions (1.13-1.16.5) and non-NBT versions (1.17.1+), ensuring the fix for swapped packet fields is covered by tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Exercises both writeBook and signBook from a non-hotbar inventory slot, verifying that the edit_book packet field assignments work correctly across NBT and non-NBT code paths. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The editBook test was added but immediately excluded, meaning it never actually ran in CI. Remove it from the excludedTests array so the test exercises the writeBook/signBook code path it was written to validate. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
In MC 1.20.5+ the server returns book items using structured components (writable_book_content / written_book_content) instead of NBT, so book.nbt is null and accessing book.nbt.value.pages throws. Additionally, for some versions the server may not echo back page data in the set_slot response for writable_book at all. This commit adds helper functions that extract pages, title, and author from either the legacy NBT format or the new componentMap, and makes content assertions conditional on the data actually being present. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After Minecraft 1.17, the packet for editing a book changed.
To support writing newer books, a feature
editBookPacketUsesNbtwas added, and #3373 updated the code for writing books to use that feature and send the correct package.However, after checking for the feature, the wrong code gets executed (uses nbt -> non-nbt packet is sent, and vice versa). This effectively breaks all book functionality since the introduction of the book edit packet.
This PR fixes this by updating the packet sent in each case.
Test Results
See source.
✖ Error
✖ Error
✖ Error
✖ Error
✖ Error
✖ Error
✖ Error
✖ Error
✖ Error
✖ Error
The error in version 1.17.1 is related to a previously incorrect version range for the
editBookPacketUsesNbtfeature, which was fixed in PrismarineJS/minecraft-data#1013 and will be resolved once PrismarineJS/node-minecraft-data updates minecraft-data.