ServerboundPlaceRecipePacket 0x27

ServerboundPlaceRecipePacket: Minecraft 26.3 packet (0x27 Play serverbound). Wire name 'place_recipe', fields: containerId, recipe, useMaxItems, handled

Minecraft 26.3PlayServerboundnet.minecraft.network.protocol.game

Protocol slots (1)

IDdecStateDirectionRegistry
0x2739PLAYServerboundGamePacketTypes.SERVERBOUND_PLACE_RECIPE: "place_recipe"

Packet ids are positional: the id is the index of the addPacket call in the protocol builder (see ProtocolInfoBuilder.listPackets). Ids change between game versions.

Wire fields (3)

FieldType
containerIdint
recipeRecipeDisplayId
useMaxItemsboolean

Fields are the components of the packet record.

Stream codec

static final StreamCodec<FriendlyByteBuf, ServerboundPlaceRecipePacket> STREAM_CODEC = StreamCodec.composite( ByteBufCodecs.CONTAINER_ID, ServerboundPlaceRecipePacket::containerId, RecipeDisplayId.STR

Modern packets serialize through StreamCodecs instead of read/write methods.

Handling

Resolved on the ServerGamePacketListener packet-listener interface by void handlePlaceRecipe(ServerboundPlaceRecipePacket serverboundplacerecipepacket). The implementation in the game is ServerGamePacketListenerImpl.

Full Source

ServerboundPlaceRecipePacket.java30 lines · Minecraft 26.3 · verbatimSource page ↗
1
package net.minecraft.network.protocol.game;
2
3
import net.minecraft.network.FriendlyByteBuf;
4
import net.minecraft.network.codec.ByteBufCodecs;
5
import net.minecraft.network.codec.StreamCodec;
6
import net.minecraft.network.protocol.Packet;
7
import net.minecraft.network.protocol.PacketType;
8
import net.minecraft.world.item.crafting.display.RecipeDisplayId;
9
10
public record ServerboundPlaceRecipePacket(int containerId, RecipeDisplayId recipe, boolean useMaxItems) implements Packet<ServerGamePacketListener> {
11
	public static final StreamCodec<FriendlyByteBuf, ServerboundPlaceRecipePacket> STREAM_CODEC = StreamCodec.composite(
12
		ByteBufCodecs.CONTAINER_ID,
13
		ServerboundPlaceRecipePacket::containerId,
14
		RecipeDisplayId.STREAM_CODEC,
15
		ServerboundPlaceRecipePacket::recipe,
16
		ByteBufCodecs.BOOL,
17
		ServerboundPlaceRecipePacket::useMaxItems,
18
		ServerboundPlaceRecipePacket::new
19
	);
20
21
	@Override
22
	public PacketType<ServerboundPlaceRecipePacket> type() {
23
		return GamePacketTypes.SERVERBOUND_PLACE_RECIPE;
24
	}
25
26
	public void handle(final ServerGamePacketListener listener) {
27
		listener.handlePlaceRecipe(this);
28
	}
29
}
30