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 aom) {
        this.cameraId = aom.getId();
    }
    
    @Override
    public void read(final FriendlyByteBuf mg) throws IOException {
        this.cameraId = mg.readVarInt();
    }
    
    @Override
    public void write(final FriendlyByteBuf mg) throws IOException {
        mg.writeVarInt(this.cameraId);
    }
    
    @Override
    public void handle(final ClientGamePacketListener nl) {
        nl.handleSetCamera(this);
    }
    
    @Nullable
    public Entity getEntity(final Level bqb) {
        return bqb.getEntity(this.cameraId);
    }
}
