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 ClientboundRotateHeadPacket implements Packet<ClientGamePacketListener> {
    private int entityId;
    private byte yHeadRot;
    
    public ClientboundRotateHeadPacket() {
    }
    
    public ClientboundRotateHeadPacket(final Entity akq, final byte byte2) {
        this.entityId = akq.getId();
        this.yHeadRot = byte2;
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        this.entityId = kv.readVarInt();
        this.yHeadRot = kv.readByte();
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeVarInt(this.entityId);
        kv.writeByte(this.yHeadRot);
    }
    
    @Override
    public void handle(final ClientGamePacketListener lw) {
        lw.handleRotateMob(this);
    }
    
    public Entity getEntity(final Level bjw) {
        return bjw.getEntity(this.entityId);
    }
    
    public byte getYHeadRot() {
        return this.yHeadRot;
    }
}
