package net.minecraft.network.protocol.game;

import net.minecraft.network.PacketListener;
import java.io.IOException;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.network.protocol.Packet;

public class ClientboundPlaceGhostRecipePacket implements Packet<ClientGamePacketListener> {
    private int containerId;
    private ResourceLocation recipe;
    
    public ClientboundPlaceGhostRecipePacket() {
    }
    
    public ClientboundPlaceGhostRecipePacket(final int integer, final Recipe<?> bgw) {
        this.containerId = integer;
        this.recipe = bgw.getId();
    }
    
    public ResourceLocation getRecipe() {
        return this.recipe;
    }
    
    public int getContainerId() {
        return this.containerId;
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        this.containerId = kv.readByte();
        this.recipe = kv.readResourceLocation();
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeByte(this.containerId);
        kv.writeResourceLocation(this.recipe);
    }
    
    @Override
    public void handle(final ClientGamePacketListener lw) {
        lw.handlePlaceRecipe(this);
    }
}
