package net.minecraft.network.protocol.game;

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

public class ClientboundTeleportEntityPacket implements Packet<ClientGamePacketListener> {
    private int id;
    private double x;
    private double y;
    private double z;
    private byte yRot;
    private byte xRot;
    private boolean onGround;
    
    public ClientboundTeleportEntityPacket() {
    }
    
    public ClientboundTeleportEntityPacket(final Entity akq) {
        this.id = akq.getId();
        this.x = akq.getX();
        this.y = akq.getY();
        this.z = akq.getZ();
        this.yRot = (byte)(akq.yRot * 256.0f / 360.0f);
        this.xRot = (byte)(akq.xRot * 256.0f / 360.0f);
        this.onGround = akq.onGround;
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        this.id = kv.readVarInt();
        this.x = kv.readDouble();
        this.y = kv.readDouble();
        this.z = kv.readDouble();
        this.yRot = kv.readByte();
        this.xRot = kv.readByte();
        this.onGround = kv.readBoolean();
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeVarInt(this.id);
        kv.writeDouble(this.x);
        kv.writeDouble(this.y);
        kv.writeDouble(this.z);
        kv.writeByte(this.yRot);
        kv.writeByte(this.xRot);
        kv.writeBoolean(this.onGround);
    }
    
    @Override
    public void handle(final ClientGamePacketListener lw) {
        lw.handleTeleportEntity(this);
    }
    
    public int getId() {
        return this.id;
    }
    
    public double getX() {
        return this.x;
    }
    
    public double getY() {
        return this.y;
    }
    
    public double getZ() {
        return this.z;
    }
    
    public byte getyRot() {
        return this.yRot;
    }
    
    public byte getxRot() {
        return this.xRot;
    }
    
    public boolean isOnGround() {
        return this.onGround;
    }
}
