/*
 * Copyright (c) 2026 盐灯水母
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */

package com.remains_cave.dungeon;

import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.EntityType;

/**
 * 记录一个实体的放置信息，包括世界坐标和NBT数据。
 */
public record EntityPlacement(BlockPos pos, CompoundTag nbt) {

    public void spawn(ServerLevel level) {
        EntityType.loadEntityRecursive(nbt, level, entity -> {
            entity.setPos(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5);
            level.addFreshEntity(entity);
            return entity;
        });
    }
}