package net.minecraft.network.protocol.game;

import net.minecraft.network.PacketListener;
import javax.annotation.Nullable;
import net.minecraft.world.entity.Entity;
import net.minecraft.server.level.ServerLevel;
import java.io.IOException;
import net.minecraft.network.FriendlyByteBuf;
import java.util.UUID;
import net.minecraft.network.protocol.Packet;

public class ServerboundTeleportToEntityPacket implements Packet<ServerGamePacketListener> {
    private UUID uuid;
    
    public ServerboundTeleportToEntityPacket() {
    }
    
    public ServerboundTeleportToEntityPacket(final UUID uUID) {
        this.uuid = uUID;
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        this.uuid = kv.readUUID();
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeUUID(this.uuid);
    }
    
    @Override
    public void handle(final ServerGamePacketListener pl) {
        pl.handleTeleportToEntityPacket(this);
    }
    
    @Nullable
    public Entity getEntity(final ServerLevel xd) {
        return xd.getEntity(this.uuid);
    }
}
