Skip to content

fix: rewrite recipe book add displays for 26.1 clients#4

Merged
ohnodev merged 1 commit intomainfrom
fix/recipe-book-add-legacy-rewrite
Apr 12, 2026
Merged

fix: rewrite recipe book add displays for 26.1 clients#4
ohnodev merged 1 commit intomainfrom
fix/recipe-book-add-legacy-rewrite

Conversation

@ohnodev
Copy link
Copy Markdown
Owner

@ohnodev ohnodev commented Apr 12, 2026

Handle CLIENTBOUND_RECIPE_BOOK_ADD in LegacyPacketHandler and remap item-bearing RecipeDisplay/SlotDisplay paths so legacy clients never receive 26.2-only item ids during recipe book sync.

Summary by CodeRabbit

  • New Features
    • Improved recipe book display and functionality for legacy client compatibility.

Handle CLIENTBOUND_RECIPE_BOOK_ADD in LegacyPacketHandler and remap item-bearing RecipeDisplay/SlotDisplay paths so legacy clients never receive 26.2-only item ids during recipe book sync.

Made-with: Cursor
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e9cddfc8-0cdd-4dc5-8a4e-7e242d64a099

📥 Commits

Reviewing files that changed from the base of the PR and between b663622 and a8b54d7.

📒 Files selected for processing (2)
  • src/main/java/dev/ohno/legacylink/handler/LegacyPacketHandler.java
  • src/main/java/dev/ohno/legacylink/handler/rewrite/RecipeBookAddRewriter.java

📝 Walkthrough

Walkthrough

Added support for handling recipe book packets in the play-phase packet dispatch. Introduced a new packet handler method that delegates to a comprehensive rewriter utility, which iterates through recipe entries and remaps their display structures and constituent items for legacy compatibility.

Changes

Cohort / File(s) Summary
Packet Handler Integration
src/main/java/dev/ohno/legacylink/handler/LegacyPacketHandler.java
Added remapRecipeBookAdd() method to detect and route ClientboundRecipeBookAddPacket through the play-phase dispatcher.
Recipe Book Rewriter
src/main/java/dev/ohno/legacylink/handler/rewrite/RecipeBookAddRewriter.java
New utility class implementing comprehensive packet rewriting logic: iterates recipe entries, remaps RecipeDisplay subtypes (shapeless, shaped, furnace, stonecutter, smithing), rewrites nested SlotDisplay structures (item, template, composite, remainder, demo variants), and applies item legacy remapping via ItemRewriter helpers.

Sequence Diagram

sequenceDiagram
    participant Client
    participant LegacyPacketHandler
    participant RecipeBookAddRewriter
    participant ItemRewriter
    
    Client->>LegacyPacketHandler: ClientboundRecipeBookAddPacket
    LegacyPacketHandler->>LegacyPacketHandler: routePlayPacket() detects packet type
    LegacyPacketHandler->>RecipeBookAddRewriter: rewrite(packet)
    
    loop For each recipe entry
        RecipeBookAddRewriter->>RecipeBookAddRewriter: remapDisplay(RecipeDisplay)
        alt Display type matched
            RecipeBookAddRewriter->>RecipeBookAddRewriter: remapSlotDisplays(slots)
            loop For each slot
                RecipeBookAddRewriter->>RecipeBookAddRewriter: remapSlotDisplay(slot)
                RecipeBookAddRewriter->>ItemRewriter: remapItemToLegacySafe(item)
                ItemRewriter-->>RecipeBookAddRewriter: remapped item
            end
        end
        RecipeBookAddRewriter->>ItemRewriter: remapTemplate(craftingRequirements)
        ItemRewriter-->>RecipeBookAddRewriter: remapped requirements
    end
    
    RecipeBookAddRewriter-->>LegacyPacketHandler: ClientboundRecipeBookAddPacket (rewritten)
    LegacyPacketHandler-->>Client: rewritten packet
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 A recipe book hops through the ages,
With displays remapped through all its pages,
Each slot and slot display we tend,
Shaped, shapeless, smithing—no end!
Legacy code now gets a treat,
The rewriter makes old recipes sweet! 🎂

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: adding recipe book add display rewriting for legacy client support.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/recipe-book-add-legacy-rewrite

Comment @coderabbitai help to get the list of available commands and usage tips.

@ohnodev ohnodev merged commit 55f73a8 into main Apr 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant