import { world } from "@minecraft/server";
const entityTypes = [
    "minecraft:pig",
    "minecraft:sheep",
    "minecraft:cow"
];
export class VanillaSpawner {
    constructor() {
        world.afterEvents.entitySpawn.subscribe((event) => {
            if (event.entity.typeId === "pu_biomes:util")
                return;
            if (event.entity.typeId !== "pu_biomes:vanilla_spawner")
                return;
            try {
                this._processVanillaSpawner(event.entity);
            }
            catch (error) {
                try {
                    event.entity.remove();
                }
                catch (error) {
                    throw error;
                }
            }
        });
    }
    _processVanillaSpawner(entity) {
        const typeId = entityTypes[Math.floor(Math.random() * entityTypes.length)];
        const count = Math.floor(Math.random() * 3) + 1;
        for (let i = 0; i < count; i++) {
            entity.dimension.spawnEntity(typeId, entity.location);
        }
        entity.remove();
    }
}
