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 bke, final int integer) {
        this.item = bke;
        this.duration = integer;
    }
    
    @Override
    public void read(final FriendlyByteBuf mg) throws IOException {
        this.item = Item.byId(mg.readVarInt());
        this.duration = mg.readVarInt();
    }
    
    @Override
    public void write(final FriendlyByteBuf mg) throws IOException {
        mg.writeVarInt(Item.getId(this.item));
        mg.writeVarInt(this.duration);
    }
    
    @Override
    public void handle(final ClientGamePacketListener nl) {
        nl.handleItemCooldown(this);
    }
    
    public Item getItem() {
        return this.item;
    }
    
    public int getDuration() {
        return this.duration;
    }
}
