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 bgq, final ItemStack bki, final short short6) {
        this.itemStack = ItemStack.EMPTY;
        this.containerId = integer1;
        this.slotNum = integer2;
        this.buttonNum = integer3;
        this.itemStack = bki.copy();
        this.uid = short6;
        this.clickType = bgq;
    }
    
    @Override
    public void handle(final ServerGamePacketListener qz) {
        qz.handleContainerClick(this);
    }
    
    @Override
    public void read(final FriendlyByteBuf mg) throws IOException {
        this.containerId = mg.readByte();
        this.slotNum = mg.readShort();
        this.buttonNum = mg.readByte();
        this.uid = mg.readShort();
        this.clickType = mg.<ClickType>readEnum(ClickType.class);
        this.itemStack = mg.readItem();
    }
    
    @Override
    public void write(final FriendlyByteBuf mg) throws IOException {
        mg.writeByte(this.containerId);
        mg.writeShort(this.slotNum);
        mg.writeByte(this.buttonNum);
        mg.writeShort(this.uid);
        mg.writeEnum(this.clickType);
        mg.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;
    }
}
