package net.minecraft.network.protocol.game;

import net.minecraft.network.PacketListener;
import net.minecraft.world.level.Level;
import java.io.IOException;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.entity.Entity;
import net.minecraft.network.protocol.Packet;

public class ClientboundEntityEventPacket implements Packet<ClientGamePacketListener> {
    private int entityId;
    private byte eventId;
    
    public ClientboundEntityEventPacket() {
    }
    
    public ClientboundEntityEventPacket(final Entity akq, final byte byte2) {
        this.entityId = akq.getId();
        this.eventId = byte2;
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        this.entityId = kv.readInt();
        this.eventId = kv.readByte();
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeInt(this.entityId);
        kv.writeByte(this.eventId);
    }
    
    @Override
    public void handle(final ClientGamePacketListener lw) {
        lw.handleEntityEvent(this);
    }
    
    public Entity getEntity(final Level bjw) {
        return bjw.getEntity(this.entityId);
    }
    
    public byte getEventId() {
        return this.eventId;
    }
}
