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

export async function getBiome(player = Player.prototype) {
    try {
        const entity = player.dimension.spawnEntity('cyd_dino:biome_checker', player.location)

        const biome = await new Promise((resolve) => {
            system.runTimeout(() => {
                const biome = entity.getProperty('cyd_dino:biome')
                if (!biome) return

                entity.remove()
                resolve(biome)
            }, 2)
        })

        return biome

    } catch (error) {
    }
}