Collection of misc improvements and fixes#6415
Open
rtm516 wants to merge 7 commits into
Open
Conversation
CommandRequestPacket will now trigger the same command checks and handling as TextPacket
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a few Bedrock->Java translation edge cases and a file IO inefficiency that could lead to high CPU usage, aiming to improve stability and consistency in Geyser’s core translators/utilities.
Changes:
- Replace
InputStream.available()-based writing withInputStream#transferToto avoid potential busy-looping/CPU spin while saving assets. - Align
CommandRequestPacketcommand handling withTextPacket(normalize/trim, ignore blank, require leading slash). - Clamp lectern page updates to reduce potential packet spam.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| core/src/main/java/org/geysermc/geyser/util/AssetUtils.java | Simplifies file saving to avoid available() pitfalls and potential CPU spin. |
| core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/BedrockLecternUpdateTranslator.java | Adds page clamping before translating Bedrock lectern page changes to Java click packets. |
| core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/BedrockCommandRequestTranslator.java | Normalizes/validates incoming command request strings to match TextPacket handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
onebeastchris
approved these changes
May 17, 2026
Comment on lines
+53
to
+70
| // Books on java can only be 100 pages so clamp the page number to that | ||
| // This also forces requested pages to be sequential | ||
| // This is 25 for showing page 49/50, and 50 for 99/100 | ||
| int currentPage = lecternContainer.getCurrentBedrockPage(); | ||
| int requestedPage = packet.getPage(); | ||
| int page = MathUtils.constrain(MathUtils.constrain(requestedPage, currentPage - 1, currentPage + 1), 0, 50); | ||
|
|
||
| if (currentPage == requestedPage) { | ||
| // The same page means Bedrock is closing the window | ||
| InventoryUtils.sendJavaContainerClose(holder); | ||
| InventoryUtils.closeInventory(session, holder, false); | ||
| } else if (currentPage == page) { | ||
| // The requested page was clamped back to the current page so do nothing | ||
| } else { | ||
| // Each "page" Bedrock gives to us actually represents two pages (think opening a book and seeing two pages) | ||
| // Each "page" on Java is just one page (think a spiral notebook folded back to only show one page) | ||
| int newJavaPage = (packet.getPage() * 2); | ||
| int currentJavaPage = (lecternContainer.getCurrentBedrockPage() * 2); | ||
| int newJavaPage = (page * 2); | ||
| int currentJavaPage = (currentPage * 2); |
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.
These issues were flagged by Claude and manually fixed by me following some of its guidence.
Fix asset utils breaking on slow zip reading
Validate commands the same regardless of packet type
CommandRequestPacketandTextPacketwere different for commands, these are now the same.Clamp lectern page number