ClientboundPlaceGhostRecipePacket 0x40

ClientboundPlaceGhostRecipePacket: Minecraft 26.3 packet (0x40 Play clientbound). Wire name 'place_ghost_recipe', fields: containerId, recipeDisplay

Minecraft 26.3PlayClientboundnet.minecraft.network.protocol.game

Protocol slots (1)

IDdecStateDirectionRegistry
0x4064PLAYClientboundGamePacketTypes.CLIENTBOUND_PLACE_GHOST_RECIPE: "place_ghost_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 (2)

FieldType
containerIdint
recipeDisplayRecipeDisplay

Fields are the components of the packet record.

Stream codec

static final StreamCodec<RegistryFriendlyByteBuf, ClientboundPlaceGhostRecipePacket> STREAM_CODEC = StreamCodec.composite( ByteBufCodecs.CONTAINER_ID, ClientboundPlaceGhostRecipePacket::containerId, R

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

Handling

Resolved on the ClientGamePacketListener packet-listener interface by void handlePlaceRecipe(ClientboundPlaceGhostRecipePacket clientboundplaceghostrecipepacket). The implementation in the game is ClientPacketListener.

Full Source

ClientboundPlaceGhostRecipePacket.java28 lines · Minecraft 26.3 · verbatimSource page ↗
1
package net.minecraft.network.protocol.game;
2
3
import net.minecraft.network.RegistryFriendlyByteBuf;
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.RecipeDisplay;
9
10
public record ClientboundPlaceGhostRecipePacket(int containerId, RecipeDisplay recipeDisplay) implements Packet<ClientGamePacketListener> {
11
	public static final StreamCodec<RegistryFriendlyByteBuf, ClientboundPlaceGhostRecipePacket> STREAM_CODEC = StreamCodec.composite(
12
		ByteBufCodecs.CONTAINER_ID,
13
		ClientboundPlaceGhostRecipePacket::containerId,
14
		RecipeDisplay.STREAM_CODEC,
15
		ClientboundPlaceGhostRecipePacket::recipeDisplay,
16
		ClientboundPlaceGhostRecipePacket::new
17
	);
18
19
	@Override
20
	public PacketType<ClientboundPlaceGhostRecipePacket> type() {
21
		return GamePacketTypes.CLIENTBOUND_PLACE_GHOST_RECIPE;
22
	}
23
24
	public void handle(final ClientGamePacketListener listener) {
25
		listener.handlePlaceRecipe(this);
26
	}
27
}
28