package net.minecraft.network.protocol.game;

import net.minecraft.network.PacketListener;
import java.io.IOException;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.inventory.ClickType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.network.protocol.Packet;

public class ServerboundContainerClickPacket implements Packet<ServerGamePacketListener> {
    private int containerId;
    private int slotNum;
    private int buttonNum;
    private short uid;
    private ItemStack itemStack;
    private ClickType clickType;
    
    public ServerboundContainerClickPacket() {
        this.itemStack = ItemStack.EMPTY;
    }
    
    public ServerboundContainerClickPacket(final int integer1, final int integer2, final int integer3, final ClickType bav, final ItemStack ben, final short short6) {
        this.itemStack = ItemStack.EMPTY;
        this.containerId = integer1;
        this.slotNum = integer2;
        this.buttonNum = integer3;
        this.itemStack = ben.copy();
        this.uid = short6;
        this.clickType = bav;
    }
    
    @Override
    public void handle(final ServerGamePacketListener pl) {
        pl.handleContainerClick(this);
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        this.containerId = kv.readByte();
        this.slotNum = kv.readShort();
        this.buttonNum = kv.readByte();
        this.uid = kv.readShort();
        this.clickType = kv.<ClickType>readEnum(ClickType.class);
        this.itemStack = kv.readItem();
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeByte(this.containerId);
        kv.writeShort(this.slotNum);
        kv.writeByte(this.buttonNum);
        kv.writeShort(this.uid);
        kv.writeEnum(this.clickType);
        kv.writeItem(this.itemStack);
    }
    
    public int getContainerId() {
        return this.containerId;
    }
    
    public int getSlotNum() {
        return this.slotNum;
    }
    
    public int getButtonNum() {
        return this.buttonNum;
    }
    
    public short getUid() {
        return this.uid;
    }
    
    public ItemStack getItem() {
        return this.itemStack;
    }
    
    public ClickType getClickType() {
        return this.clickType;
    }
}
