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

public class ClientboundCooldownPacket implements Packet<ClientGamePacketListener> {
    private Item item;
    private int duration;
    
    public ClientboundCooldownPacket() {
    }
    
    public ClientboundCooldownPacket(final Item bei, final int integer) {
        this.item = bei;
        this.duration = integer;
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        this.item = Item.byId(kv.readVarInt());
        this.duration = kv.readVarInt();
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeVarInt(Item.getId(this.item));
        kv.writeVarInt(this.duration);
    }
    
    @Override
    public void handle(final ClientGamePacketListener lw) {
        lw.handleItemCooldown(this);
    }
    
    public Item getItem() {
        return this.item;
    }
    
    public int getDuration() {
        return this.duration;
    }
}
