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

public class ClientboundSetEquippedItemPacket implements Packet<ClientGamePacketListener> {
    private int entity;
    private EquipmentSlot slot;
    private ItemStack itemStack;
    
    public ClientboundSetEquippedItemPacket() {
        this.itemStack = ItemStack.EMPTY;
    }
    
    public ClientboundSetEquippedItemPacket(final int integer, final EquipmentSlot akv, final ItemStack ben) {
        this.itemStack = ItemStack.EMPTY;
        this.entity = integer;
        this.slot = akv;
        this.itemStack = ben.copy();
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        this.entity = kv.readVarInt();
        this.slot = kv.<EquipmentSlot>readEnum(EquipmentSlot.class);
        this.itemStack = kv.readItem();
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeVarInt(this.entity);
        kv.writeEnum(this.slot);
        kv.writeItem(this.itemStack);
    }
    
    @Override
    public void handle(final ClientGamePacketListener lw) {
        lw.handleSetEquippedItem(this);
    }
    
    public ItemStack getItem() {
        return this.itemStack;
    }
    
    public int getEntity() {
        return this.entity;
    }
    
    public EquipmentSlot getSlot() {
        return this.slot;
    }
}
