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 ServerboundSetCreativeModeSlotPacket implements Packet<ServerGamePacketListener> {
    private int slotNum;
    private ItemStack itemStack;
    
    public ServerboundSetCreativeModeSlotPacket() {
        this.itemStack = ItemStack.EMPTY;
    }
    
    public ServerboundSetCreativeModeSlotPacket(final int integer, final ItemStack ben) {
        this.itemStack = ItemStack.EMPTY;
        this.slotNum = integer;
        this.itemStack = ben.copy();
    }
    
    @Override
    public void handle(final ServerGamePacketListener pl) {
        pl.handleSetCreativeModeSlot(this);
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        this.slotNum = kv.readShort();
        this.itemStack = kv.readItem();
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeShort(this.slotNum);
        kv.writeItem(this.itemStack);
    }
    
    public int getSlotNum() {
        return this.slotNum;
    }
    
    public ItemStack getItem() {
        return this.itemStack;
    }
}
