package net.minecraft.network.protocol.game;

import net.minecraft.network.PacketListener;
import javax.annotation.Nullable;
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 ClientboundSetCameraPacket implements Packet<ClientGamePacketListener> {
    public int cameraId;
    
    public ClientboundSetCameraPacket() {
    }
    
    public ClientboundSetCameraPacket(final Entity akq) {
        this.cameraId = akq.getId();
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        this.cameraId = kv.readVarInt();
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeVarInt(this.cameraId);
    }
    
    @Override
    public void handle(final ClientGamePacketListener lw) {
        lw.handleSetCamera(this);
    }
    
    @Nullable
    public Entity getEntity(final Level bjw) {
        return bjw.getEntity(this.cameraId);
    }
}
