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 aom, final byte byte2) {
        this.entityId = aom.getId();
        this.eventId = byte2;
    }
    
    @Override
    public void read(final FriendlyByteBuf mg) throws IOException {
        this.entityId = mg.readInt();
        this.eventId = mg.readByte();
    }
    
    @Override
    public void write(final FriendlyByteBuf mg) throws IOException {
        mg.writeInt(this.entityId);
        mg.writeByte(this.eventId);
    }
    
    @Override
    public void handle(final ClientGamePacketListener nl) {
        nl.handleEntityEvent(this);
    }
    
    public Entity getEntity(final Level bqb) {
        return bqb.getEntity(this.entityId);
    }
    
    public byte getEventId() {
        return this.eventId;
    }
}
