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.ItemStack;
import net.minecraft.network.protocol.Packet;

public class ClientboundContainerSetSlotPacket implements Packet<ClientGamePacketListener> {
    private int containerId;
    private int slot;
    private ItemStack itemStack;
    
    public ClientboundContainerSetSlotPacket() {
        this.itemStack = ItemStack.EMPTY;
    }
    
    public ClientboundContainerSetSlotPacket(final int integer1, final int integer2, final ItemStack ben) {
        this.itemStack = ItemStack.EMPTY;
        this.containerId = integer1;
        this.slot = integer2;
        this.itemStack = ben.copy();
    }
    
    @Override
    public void handle(final ClientGamePacketListener lw) {
        lw.handleContainerSetSlot(this);
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        this.containerId = kv.readByte();
        this.slot = kv.readShort();
        this.itemStack = kv.readItem();
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeByte(this.containerId);
        kv.writeShort(this.slot);
        kv.writeItem(this.itemStack);
    }
    
    public int getContainerId() {
        return this.containerId;
    }
    
    public int getSlot() {
        return this.slot;
    }
    
    public ItemStack getItem() {
        return this.itemStack;
    }
}
