Skip to content

fix: ServerboundPlaceRecipe sends a RecipeDisplayId, not a resource location (1.21.2+) - #392

Closed
RobioEpo wants to merge 2 commits into
azalea-rs:mainfrom
RobioEpo:fix-place-recipe-display-id
Closed

RobioEpo wants to merge 2 commits into
azalea-rs:mainfrom
RobioEpo:fix-place-recipe-display-id

Conversation

@RobioEpo

Copy link
Copy Markdown

fix: ServerboundPlaceRecipe sends a resource location where 1.21.2+ reads a RecipeDisplayId

What's wrong

ServerboundPlaceRecipe serializes its second field as an Identifier (a resource-location
string). Since 1.21.2 that field is a RecipeDisplayId — a VarInt. A real craft therefore
writes ~23 bytes where the server reads 3, and the server disconnects the client:

DecoderException: Packet serverbound/minecraft:place_recipe (ServerboundPlaceRecipePacket)
was larger than I expected, found 20 bytes extra whilst reading packet
serverbound/minecraft:place_recipe

Reproduced (azalea's own code)

Serializing the real packet with AzBuf (ServerboundPlaceRecipe { container_id: 0, recipe: Identifier::new("minecraft:oak_planks"), shift_down: true }) gives, on current main/ddef371:

azalea writes 23 bytes: [0, 20, "minecraft:oak_planks"(20), 1]

VarInt(containerId=0) · VarInt(len=20) · the 20-byte string · bool = 23 bytes.
The 1.21.2+ server reads VarInt(containerId) + VarInt(RecipeDisplayId) + bool = 3, so it
reports 20 bytes extra — exactly the disconnect above.

Evidence

  • NeoForge 26.1: record ServerboundPlaceRecipePacket(int containerId, RecipeDisplayId recipe, boolean useMaxItems).
  • mappings.dev 1.21.10: the field is RecipeDisplayId.
  • PacketEvents: "getRecipe() … Replaced in 1.21.2 with getRecipeId() / RecipeDisplayId".

This affects main (26.2) as well — the struct is unchanged.

Fix

Add a RecipeDisplayId VarInt newtype and use it in the packet. With the fix the same serialization
is 3 bytes ([0, 20, 1]), matching the server, and azalea-protocol compiles cleanly.

(Sending a specific recipe then needs the display id from the recipe book — a separate concern from
this serialization fix.)

@RobioEpo RobioEpo closed this Oct 14, 2026
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