package moe.ymc.acron.s2c; import com.google.gson.annotations.SerializedName; import com.mojang.authlib.GameProfile; import moe.ymc.acron.common.Vec3d; import moe.ymc.acron.common.WorldKey; import net.minecraft.entity.EntityType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.UUID; public record Entity(@SerializedName("name") @NotNull String name, @SerializedName("uuid") @NotNull UUID uuid, @SerializedName("type") @NotNull String type, @SerializedName("pos") @Nullable Vec3d pos, @SerializedName("world") @Nullable WorldKey world) { public Entity(@NotNull net.minecraft.entity.Entity entity) { this(entity.getName().getString(), entity.getUuid(), EntityType.getId(entity.getType()).toString(), new Vec3d(entity.getPos()), WorldKey.create(entity.world.getRegistryKey().getValue())); } public Entity(@NotNull GameProfile profile) { this(profile.getName(), profile.getId(), "minecraft:player", null, null); } }