package net.minecraft.network.protocol.game; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.PacketType; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.crafting.RecipeHolder; public class ClientboundPlaceGhostRecipePacket implements Packet { public static final StreamCodec STREAM_CODEC = Packet.codec( ClientboundPlaceGhostRecipePacket::write, ClientboundPlaceGhostRecipePacket::new ); private final int containerId; private final ResourceLocation recipe; public ClientboundPlaceGhostRecipePacket(int containerId, RecipeHolder recipe) { this.containerId = containerId; this.recipe = recipe.id(); } private ClientboundPlaceGhostRecipePacket(FriendlyByteBuf buffer) { this.containerId = buffer.readByte(); this.recipe = buffer.readResourceLocation(); } /** * Writes the raw packet data to the data stream. */ private void write(FriendlyByteBuf byteBuf) { byteBuf.writeByte(this.containerId); byteBuf.writeResourceLocation(this.recipe); } @Override public PacketType type() { return GamePacketTypes.CLIENTBOUND_PLACE_GHOST_RECIPE; } /** * Passes this Packet on to the NetHandler for processing. */ public void handle(ClientGamePacketListener handler) { handler.handlePlaceRecipe(this); } public ResourceLocation getRecipe() { return this.recipe; } public int getContainerId() { return this.containerId; } }