import { system } from "@minecraft/server";

system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity: entity }) => {
    if (id !== "sapphire_meteors:spawn_loot") return;
    const { x, y, z } = entity.location;
    const entityName = entity.typeId.replace("sapphire_meteors:", "");

    entity.dimension.runCommand(`loot spawn ${x} ${y} ${z} loot "sapphire/meteors/entities/${entityName}"`);
});