import { world } from "@minecraft/server";
import ScriptingModule from "../modules/scriptingModule";
import { AmbientFog, AmbientParticle, AmbientSound, CheckProperty, sunGlare, checkBiome, PlayerParticle, } from "../modules/ambienceModule";
import { playerWorldEvents } from "../modules/worldEventsModule";
export default class AmbienceModule extends ScriptingModule {
    constructor() {
        super("AmbienceModule");
        this.onInitialize = () => {
            this.registerAmbientParticles();
            this.registerAmbientSounds();
            this.registerAmbientFogs();
            this.registerPlayerParticles();
            checkBiome();
            sunGlare();
            //blockExplode();
        };
        this.surfaceAmbienceLevel = 45;
        this.skyAmbienceLevel = 150;
    }
    registerPlayerParticles() {
        PlayerParticle.register(new PlayerParticle({
            dynamicProperty: "cc_re:particle_sunrays_nether",
            setting: "cc_re:allow_particle_sunrays",
            conditions: (player, tags) => tags.includes("cc_re:nether"),
        }));
        PlayerParticle.register(new PlayerParticle({
            dynamicProperty: "cc_re:particle_sunrays_end",
            setting: "cc_re:allow_particle_sunrays",
            conditions: (player, tags) => tags.includes("cc_re:the_end"),
        }));
        PlayerParticle.register(new PlayerParticle({
            dynamicProperty: "cc_re:particle_clouds",
            setting: "cc_re:allow_particle_clouds",
            conditions: (player, tags) => tags.includes("cc_re:overworld"),
        }));
        PlayerParticle.initialize();
    }
    registerAmbientParticles() {
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:light_ray_close",
            shape: "cylinder",
            radius: 30,
            amount: 20,
            offset: 20,
            loopTime: 1,
            conditions: (player, tags) => 
            //tags.includes("cc_re:overworld") ||
            (((tags.includes("cc_re:forest") && !tags.includes("cc_re:birch")) ||
                tags.includes("cc_re:desert") ||
                tags.includes("cc_re:mesa")) &&
                player.location.y > this.surfaceAmbienceLevel &&
                world.getTimeOfDay() >= -600 &&
                world.getTimeOfDay() <= 13000) ||
                tags.includes("cc_re:nether"),
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_sunrays",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:light_ray_close",
            shape: "cylinder",
            radius: 50,
            amount: 100,
            offset: 20,
            loopTime: 1,
            conditions: (player, tags) => 
            //tags.includes("cc_re:overworld") ||
            (tags.includes("cc_re:jungle") ||
                tags.includes("cc_re:birch") ||
                tags.includes("cc_re:savanna")) &&
                player.location.y > this.surfaceAmbienceLevel &&
                world.getTimeOfDay() >= -600 &&
                world.getTimeOfDay() <= 13000,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_sunrays",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:butterfly",
            shape: "sphere",
            radius: 30,
            //amount: 3,
            amount: 8,
            offset: 0,
            loopTime: 5,
            conditions: (player, tags) => ((tags.includes("cc_re:forest") && !tags.includes("cc_re:cold")) ||
                tags.includes("cc_re:flower_forest") ||
                tags.includes("cc_re:jungle")) &&
                player.location.y > this.surfaceAmbienceLevel &&
                world.getTimeOfDay() >= -600 &&
                world.getTimeOfDay() <= 13000,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_butterfly",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:ocean_light_ray",
            shape: "cylinder",
            y: 64,
            radius: 25,
            amount: 50,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => tags.includes("cc_re:overworld") && player.isInWater,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_ocean_light_rays",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:ocean_spark",
            shape: "cylinder",
            radius: 25,
            amount: 50,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => tags.includes("cc_re:overworld") && player.isInWater,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_ocean_light_rays",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:ocean_lights_surface",
            shape: "cylinder",
            y: 63.4,
            radius: 100,
            amount: 400,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => tags.includes("cc_re:overworld") && playerWorldEvents.get(player.name) === undefined,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_ocean_surface_waves",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:nether_lava_surface",
            shape: "cylinder",
            y: 31.95,
            radius: 100,
            amount: 400,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => tags.includes("cc_re:nether"),
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_ocean_surface_waves",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:oak_leaves_marker",
            shape: "sphere",
            radius: 25,
            amount: 100,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => tags.includes("cc_re:forest") &&
                !tags.includes("cc_re:cold") &&
                !tags.includes("cc_re:taiga"),
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_fallen_leaves",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:birch_leaves_marker",
            shape: "sphere",
            radius: 25,
            amount: 100,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => tags.includes("cc_re:forest") &&
                !tags.includes("cc_re:cold") &&
                !tags.includes("cc_re:taiga"),
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_fallen_leaves",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:jungle_leaves_marker",
            shape: "sphere",
            radius: 25,
            amount: 100,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => tags.includes("cc_re:jungle"),
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_fallen_leaves",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:swamp_leaves_marker",
            shape: "sphere",
            radius: 25,
            amount: 100,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => tags.includes("cc_re:swamp"),
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_fallen_leaves",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:savanna_leaves_marker",
            shape: "sphere",
            radius: 25,
            amount: 100,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => tags.includes("cc_re:savanna"),
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_fallen_leaves",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:taiga_leaves_marker",
            shape: "sphere",
            radius: 25,
            amount: 100,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => tags.includes("cc_re:taiga"),
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_fallen_leaves",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:sand_storm",
            shape: "sphere",
            radius: 20,
            amount: 60,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => playerWorldEvents.get(player.name) === "cc_re:sand_storm",
            checkProperty: CheckProperty.BIOME,
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:sand_storm_fog",
            shape: "sphere",
            radius: 20,
            amount: 60,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => playerWorldEvents.get(player.name) === "cc_re:sand_storm",
            checkProperty: CheckProperty.BIOME,
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:mist_fog_marker",
            shape: "cylinder",
            radius: 50,
            height: 20,
            amount: 150,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => playerWorldEvents.get(player.name) === "cc_re:mist" &&
                player.location.y > this.surfaceAmbienceLevel,
            checkProperty: CheckProperty.BIOME,
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:snow_storm",
            shape: "sphere",
            radius: 20,
            amount: 150,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => playerWorldEvents.get(player.name) === "cc_re:snow_storm",
            checkProperty: CheckProperty.BIOME,
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:snow_storm_fog",
            shape: "sphere",
            radius: 20,
            amount: 60,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => playerWorldEvents.get(player.name) === "cc_re:snow_storm",
            checkProperty: CheckProperty.BIOME,
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:rain_fog",
            shape: "sphere",
            radius: 20,
            amount: 200,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => playerWorldEvents.get(player.name) === "cc_re:rain_storm" &&
                player.location.y > this.surfaceAmbienceLevel,
            checkProperty: CheckProperty.BIOME,
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:fire_fly",
            shape: "cylinder",
            radius: 50,
            height: 10,
            amount: 8,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => ((tags.includes("cc_re:swamp") || tags.includes("cc_re:mangrove_swamp")) &&
                player.location.y > this.surfaceAmbienceLevel) ||
                tags.includes("cc_re:lush_caves"),
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_fire_fly",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:cherry_fly",
            shape: "cylinder",
            radius: 50,
            height: 10,
            amount: 8,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => tags.includes("cc_re:cherry_grove") && player.location.y > this.surfaceAmbienceLevel,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_fire_fly",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:deep_fire_fly",
            shape: "cylinder",
            radius: 50,
            height: 10,
            amount: 30,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => (tags.includes("cc_re:deep_dark") && player.location.y < this.surfaceAmbienceLevel) ||
                tags.includes("cc_re:warped_forest"),
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_fire_fly",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:end_fire_fly",
            shape: "cylinder",
            radius: 50,
            height: 10,
            amount: 30,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => tags.includes("cc_re:the_end"),
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_fire_fly",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:nether_fire_fly",
            shape: "cylinder",
            radius: 50,
            height: 10,
            amount: 30,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => tags.includes("cc_re:nether"),
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_fire_fly",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:mooshroom_fly",
            shape: "cylinder",
            radius: 50,
            height: 10,
            amount: 30,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => tags.includes("cc_re:mooshroom_island"),
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_fire_fly",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:mooshroom_fog_marker",
            shape: "cylinder",
            radius: 50,
            height: 20,
            amount: 200,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => tags.includes("cc_re:mooshroom_island") && player.location.y > this.surfaceAmbienceLevel,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_surface_fog_mooshroom",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:sand",
            shape: "cylinder",
            radius: 50,
            height: 10,
            amount: 8,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => (tags.includes("cc_re:mesa") || tags.includes("cc_re:desert")) &&
                player.location.y > this.surfaceAmbienceLevel,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_desert_sand",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:fire_fly",
            shape: "cylinder",
            radius: 30,
            height: 10,
            amount: 5,
            offset: 0,
            loopTime: 3,
            conditions: (player, tags) => (world.getTimeOfDay() < -600 || world.getTimeOfDay() > 13000) &&
                (tags.includes("cc_re:forest") || tags.includes("cc_re:jungle")) &&
                !tags.includes("cc_re:cold") &&
                !tags.includes("cc_re:ice") &&
                player.location.y > this.surfaceAmbienceLevel,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_fire_fly",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:swamp_fog_marker",
            shape: "cylinder",
            radius: 50,
            height: 20,
            amount: 200,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => (tags.includes("cc_re:swamp") || tags.includes("cc_re:mangrove_swamp")) &&
                player.location.y > this.surfaceAmbienceLevel,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_surface_fog_swamp",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:nether_fog_marker",
            shape: "cylinder",
            radius: 50,
            height: 20,
            amount: 200,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => tags.includes("cc_re:netherwart_forest"),
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_surface_fog_crimson",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:savanna_fog_marker",
            shape: "cylinder",
            radius: 50,
            height: 20,
            amount: 75,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => tags.includes("cc_re:savanna") && player.location.y > this.surfaceAmbienceLevel,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_surface_fog_savanna",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:roofed_fog_marker",
            shape: "cylinder",
            radius: 50,
            height: 20,
            amount: 75,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => tags.includes("cc_re:roofed") && player.location.y > this.surfaceAmbienceLevel,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_surface_fog_roofed",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:savanna_fog_marker",
            shape: "cylinder",
            radius: 50,
            height: 20,
            amount: 75,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => (tags.includes("cc_re:desert") || tags.includes("cc_re:mesa")) &&
                player.location.y > this.surfaceAmbienceLevel,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_surface_fog_desert",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:aurora_emitter",
            shape: "cylinder",
            radius: 120,
            height: 1,
            amount: 3,
            y: 170,
            surface: false,
            loopTime: 5,
            conditions: (player, tags) => (world.getTimeOfDay() < -600 || world.getTimeOfDay() > 13000) &&
                (tags.includes("cc_re:ice") || tags.includes("cc_re:cold")),
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_aurora",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:end_aurora_emitter",
            shape: "cylinder",
            radius: 120,
            height: 1,
            amount: 3,
            y: 170,
            surface: false,
            loopTime: 5,
            conditions: (player, tags) => tags.includes("cc_re:the_end"),
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_aurora",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:stone_dust",
            shape: "sphere",
            radius: 15,
            amount: 50,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => player.location.y < this.surfaceAmbienceLevel,
            checkProperty: CheckProperty.BLOCK,
            dynamicProperty: "cc_re:allow_particle_stone_dust",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:ice_dust",
            shape: "sphere",
            radius: 15,
            amount: 50,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => tags.includes("cc_re:ice"),
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_particle_ice_dust",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:cave_fog_marker",
            shape: "cylinder",
            radius: 50,
            height: 20,
            amount: 300,
            offset: 0,
            loopTime: 1,
            conditions: (player, tags) => player.location.y < this.surfaceAmbienceLevel && tags.includes("cc_re:overworld"),
            checkProperty: CheckProperty.BLOCK,
            dynamicProperty: "cc_re:allow_particle_surface_fog_cave",
        }));
        AmbientParticle.register(new AmbientParticle({
            identifier: "cc_re:wind",
            shape: "sphere",
            radius: 10,
            height: 20,
            amount: 10,
            offset: 0,
            loopTime: 0.1,
            conditions: (player, tags) => player.location.y > 110 ||
                ((tags.includes("cc_re:ice") || tags.includes("cc_re:cold")) &&
                    player.location.y > this.surfaceAmbienceLevel &&
                    !player.isInWater),
            checkProperty: CheckProperty.BLOCK,
            dynamicProperty: "cc_re:allow_particle_wind",
        }));
        // Schedule emission for each particle
        AmbientParticle.initialize();
    }
    registerAmbientSounds() {
        AmbientSound.register(new AmbientSound({
            identifier: "cc_re:sand_storm",
            soundOptions: {
                volume: 1,
                pitch: 1,
            },
            chance: 1.0,
            duration: 13,
            conditions: (player, tags) => playerWorldEvents.get(player.name) === "cc_re:sand_storm" &&
                player.location.y > this.surfaceAmbienceLevel,
            checkProperty: CheckProperty.BLOCK,
            category: "sand_storm",
            canStop: false,
            dynamicProperty: "cc_re:allow_sound_sand_storm",
        }));
        AmbientSound.register(new AmbientSound({
            identifier: "cc_re:sand_storm",
            soundOptions: {
                volume: 1,
                pitch: 1,
            },
            chance: 1.0,
            duration: 13,
            conditions: (player, tags) => playerWorldEvents.get(player.name) === "cc_re:snow_storm" &&
                player.location.y > this.surfaceAmbienceLevel,
            checkProperty: CheckProperty.BLOCK,
            category: "snow_storm",
            canStop: false,
            dynamicProperty: "cc_re:allow_sound_snow_storm",
        }));
        AmbientSound.register(new AmbientSound({
            identifier: "cc_re:rain_storm",
            soundOptions: {
                volume: 1,
                pitch: 1,
            },
            chance: 1.0,
            duration: 10,
            conditions: (player, tags) => playerWorldEvents.get(player.name) === "cc_re:rain_storm" &&
                player.location.y > this.surfaceAmbienceLevel,
            checkProperty: CheckProperty.BIOME,
            category: "rain_storm",
            canStop: false,
            dynamicProperty: "cc_re:allow_sound_rain_storm",
        }));
        AmbientSound.register(new AmbientSound({
            identifier: "cc_re:cave_ambience",
            soundOptions: {
                volume: 1,
                pitch: 1,
            },
            chance: 0.5,
            duration: 20,
            conditions: (player, tags) => player.location.y < this.surfaceAmbienceLevel && tags.includes("cc_re:overworld"),
            checkProperty: CheckProperty.BLOCK,
            category: "default",
            canStop: false,
            dynamicProperty: "cc_re:allow_sound_cave_ambience",
        }));
        AmbientSound.register(new AmbientSound({
            identifier: "cc_re:sand_ambience",
            soundOptions: {
                volume: 1,
                pitch: 1,
            },
            chance: 0.5,
            duration: 10,
            conditions: (player, tags) => (tags.includes("cc_re:mesa") || tags.includes("cc_re:desert")) &&
                player.location.y > this.surfaceAmbienceLevel,
            checkProperty: CheckProperty.BIOME,
            category: "extra",
            canStop: false,
            dynamicProperty: "cc_re:allow_sound_desert_ambience",
        }));
        AmbientSound.register(new AmbientSound({
            identifier: "cc_re:desert_ambience",
            soundOptions: {
                volume: 1,
                pitch: 1,
            },
            chance: 0.5,
            duration: 10,
            conditions: (player, tags) => (tags.includes("cc_re:mesa") || tags.includes("cc_re:desert")) &&
                player.location.y > this.surfaceAmbienceLevel,
            checkProperty: CheckProperty.BIOME,
            category: "default",
            canStop: false,
            dynamicProperty: "cc_re:allow_sound_desert_ambience",
        }));
        AmbientSound.register(new AmbientSound({
            identifier: "cc_re:wind_ambience",
            soundOptions: {
                volume: 1,
                pitch: 1,
            },
            chance: 0.5,
            duration: 10,
            conditions: (player, tags) => player.location.y > 110,
            checkProperty: CheckProperty.BLOCK,
            category: "wind",
            canStop: false,
            dynamicProperty: "cc_re:allow_sound_wind_ambience",
        }));
        AmbientSound.register(new AmbientSound({
            identifier: "cc_re:underwater_ambience",
            soundOptions: {
                volume: 1,
                pitch: 1,
            },
            chance: 1.0,
            duration: 30,
            conditions: (player, tags) => player.isInWater &&
                world.getDimension("overworld").getBlock(player.location)?.above().typeId ===
                    "minecraft:water",
            checkProperty: CheckProperty.BLOCK,
            category: "underwater",
            canStop: true,
            dynamicProperty: "cc_re:allow_sound_underwater_ambience",
        }));
        AmbientSound.register(new AmbientSound({
            identifier: "cc_re:swamp_day_ambience",
            soundOptions: {
                volume: 1,
                pitch: 1,
            },
            chance: 0.5,
            duration: 10,
            conditions: (player, tags) => (tags.includes("cc_re:swamp") || tags.includes("cc_re:mangrove_swamp")) &&
                world.getTimeOfDay() >= -600 &&
                world.getTimeOfDay() <= 13000 &&
                player.location.y > this.surfaceAmbienceLevel,
            checkProperty: CheckProperty.BIOME,
            category: "default",
            canStop: false,
            dynamicProperty: "cc_re:allow_sound_swamp_ambience",
        }));
        AmbientSound.register(new AmbientSound({
            identifier: "cc_re:forest_day_ambience",
            soundOptions: {
                volume: 1,
                pitch: 1,
            },
            chance: 0.5,
            duration: 10,
            conditions: (player, tags) => tags.includes("cc_re:forest") &&
                !tags.includes("cc_re:cold") &&
                !tags.includes("cc_re:ice") &&
                world.getTimeOfDay() >= -600 &&
                world.getTimeOfDay() <= 13000 &&
                player.location.y > this.surfaceAmbienceLevel,
            checkProperty: CheckProperty.BIOME,
            category: "default",
            canStop: false,
            dynamicProperty: "cc_re:allow_sound_forest_ambience",
        }));
        AmbientSound.register(new AmbientSound({
            identifier: "cc_re:forest_night_ambience",
            soundOptions: {
                volume: 1,
                pitch: 1,
            },
            chance: 0.5,
            duration: 10,
            conditions: (player, tags) => tags.includes("cc_re:forest") &&
                !tags.includes("cc_re:cold") &&
                !tags.includes("cc_re:ice") &&
                (world.getTimeOfDay() < -600 || world.getTimeOfDay() > 13000) &&
                player.location.y > this.surfaceAmbienceLevel,
            checkProperty: CheckProperty.BIOME,
            category: "default",
            canStop: false,
            dynamicProperty: "cc_re:allow_sound_forest_ambience",
        }));
        AmbientSound.register(new AmbientSound({
            identifier: "cc_re:savanna_day_ambience",
            soundOptions: {
                volume: 1,
                pitch: 1,
            },
            chance: 0.5,
            duration: 10,
            conditions: (player, tags) => tags.includes("cc_re:savanna") &&
                world.getTimeOfDay() >= -600 &&
                world.getTimeOfDay() <= 13000 &&
                player.location.y > this.surfaceAmbienceLevel,
            checkProperty: CheckProperty.BIOME,
            category: "default",
            canStop: false,
            dynamicProperty: "cc_re:allow_sound_savanna_ambience",
        }));
        AmbientSound.register(new AmbientSound({
            identifier: "cc_re:savanna_night_ambience",
            soundOptions: {
                volume: 1,
                pitch: 1,
            },
            chance: 0.5,
            duration: 10,
            conditions: (player, tags) => tags.includes("cc_re:savanna") &&
                (world.getTimeOfDay() < -600 || world.getTimeOfDay() > 13000) &&
                player.location.y > this.surfaceAmbienceLevel,
            checkProperty: CheckProperty.BIOME,
            category: "default",
            canStop: false,
            dynamicProperty: "cc_re:allow_sound_savanna_ambience",
        }));
        AmbientSound.register(new AmbientSound({
            identifier: "cc_re:swamp_night_ambience",
            soundOptions: {
                volume: 1,
                pitch: 1,
            },
            chance: 0.5,
            duration: 10,
            conditions: (player, tags) => (tags.includes("cc_re:swamp") || tags.includes("cc_re:mangrove_swamp")) &&
                (world.getTimeOfDay() < -600 || world.getTimeOfDay() > 13000) &&
                player.location.y > this.surfaceAmbienceLevel,
            checkProperty: CheckProperty.BIOME,
            category: "default",
            canStop: false,
            dynamicProperty: "cc_re:allow_sound_swamp_ambience",
        }));
        AmbientSound.register(new AmbientSound({
            identifier: "cc_re:beach_ambience",
            soundOptions: {
                volume: 1,
                pitch: 1,
            },
            chance: 0.5,
            duration: 10,
            conditions: (player, tags) => tags.includes("cc_re:beach") && player.location.y > this.surfaceAmbienceLevel,
            checkProperty: CheckProperty.BIOME,
            category: "default",
            canStop: false,
            dynamicProperty: "cc_re:allow_sound_beach_ambience",
        }));
        AmbientSound.register(new AmbientSound({
            identifier: "cc_re:arctic_ambience",
            soundOptions: {
                volume: 1,
                pitch: 1,
            },
            chance: 0.5,
            duration: 10,
            conditions: (player, tags) => (tags.includes("cc_re:ice") || tags.includes("cc_re:cold")) &&
                player.location.y > this.surfaceAmbienceLevel,
            checkProperty: CheckProperty.BIOME,
            category: "default",
            canStop: false,
            dynamicProperty: "cc_re:allow_sound_arctic_wind_ambience",
        }));
        AmbientSound.register(new AmbientSound({
            identifier: "cc_re:jungle_day_ambience",
            soundOptions: {
                volume: 1,
                pitch: 1,
            },
            chance: 1.0,
            duration: 10,
            conditions: (player, tags) => tags.includes("cc_re:jungle") &&
                world.getTimeOfDay() >= -600 &&
                world.getTimeOfDay() <= 13000 &&
                player.location.y > this.surfaceAmbienceLevel,
            checkProperty: CheckProperty.BIOME,
            category: "default",
            canStop: false,
            dynamicProperty: "cc_re:allow_sound_jungle_ambience",
        }));
        AmbientSound.register(new AmbientSound({
            identifier: "cc_re:jungle_night_ambience",
            soundOptions: {
                volume: 1,
                pitch: 1,
            },
            chance: 0.5,
            duration: 13,
            conditions: (player, tags) => tags.includes("cc_re:jungle") &&
                (world.getTimeOfDay() < -600 || world.getTimeOfDay() > 13000) &&
                player.location.y > this.surfaceAmbienceLevel,
            checkProperty: CheckProperty.BIOME,
            category: "default",
            canStop: false,
            dynamicProperty: "cc_re:allow_sound_jungle_ambience",
        }));
        AmbientSound.initialize();
    }
    registerAmbientFogs() {
        AmbientFog.register(new AmbientFog({
            identifier: "cc_re:snow_storm",
            conditions: (player, tags) => playerWorldEvents.get(player.name) === "cc_re:snow_storm",
            checkProperty: CheckProperty.BIOME,
        }));
        AmbientFog.register(new AmbientFog({
            identifier: "cc_re:sand_storm",
            conditions: (player, tags) => playerWorldEvents.get(player.name) === "cc_re:sand_storm",
            checkProperty: CheckProperty.BIOME,
        }));
        AmbientFog.register(new AmbientFog({
            identifier: "cc_re:rain_storm",
            conditions: (player, tags) => playerWorldEvents.get(player.name) === "cc_re:rain_storm",
            checkProperty: CheckProperty.BIOME,
        }));
        AmbientFog.register(new AmbientFog({
            identifier: "cc_re:mist",
            conditions: (player, tags) => playerWorldEvents.get(player.name) === "cc_re:mist",
            checkProperty: CheckProperty.BIOME,
        }));
        AmbientFog.register(new AmbientFog({
            identifier: "cc_re:arctic",
            conditions: (player, tags) => (tags.includes("cc_re:frozen") ||
                tags.includes("cc_re:ice") ||
                tags.includes("cc_re:cold") ||
                tags.includes("cc_re:ice_plains") ||
                tags.includes("cc_re:cold")) &&
                player.location.y < this.skyAmbienceLevel &&
                player.location.y > this.surfaceAmbienceLevel &&
                playerWorldEvents.get(player.name) === undefined,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_fog_arctic",
        }));
        AmbientFog.register(new AmbientFog({
            identifier: "cc_re:cave",
            conditions: (player, tags) => player.location.y < this.surfaceAmbienceLevel &&
                !tags.includes("cc_re:deep_dark") &&
                !tags.includes("cc_re:lush_caves") &&
                tags.includes("cc_re:overworld"),
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_fog_cave",
        }));
        AmbientFog.register(new AmbientFog({
            identifier: "cc_re:cherry",
            conditions: (player, tags) => tags.includes("cc_re:cherry_grove") &&
                player.location.y < this.skyAmbienceLevel &&
                player.location.y > this.surfaceAmbienceLevel &&
                playerWorldEvents.get(player.name) === undefined,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_fog_cherry",
        }));
        AmbientFog.register(new AmbientFog({
            identifier: "cc_re:deep_dark",
            conditions: (player, tags) => tags.includes("cc_re:deep_dark") &&
                player.location.y < this.skyAmbienceLevel &&
                player.location.y < this.surfaceAmbienceLevel &&
                playerWorldEvents.get(player.name) === undefined,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_fog_deep_dark",
        }));
        AmbientFog.register(new AmbientFog({
            identifier: "cc_re:ice_cave",
            conditions: (player, tags) => tags.includes("cc_re:ice") &&
                player.location.y < this.skyAmbienceLevel &&
                player.location.y < this.surfaceAmbienceLevel &&
                playerWorldEvents.get(player.name) === undefined,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_fog_cave",
        }));
        AmbientFog.register(new AmbientFog({
            identifier: "cc_re:jungle",
            conditions: (player, tags) => tags.includes("cc_re:jungle") &&
                player.location.y < this.skyAmbienceLevel &&
                player.location.y > this.surfaceAmbienceLevel &&
                playerWorldEvents.get(player.name) === undefined,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_fog_jungle",
        }));
        AmbientFog.register(new AmbientFog({
            identifier: "cc_re:end",
            conditions: (player, tags) => tags.includes("cc_re:the_end"),
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_fog_end",
        }));
        AmbientFog.register(new AmbientFog({
            identifier: "cc_re:desert",
            conditions: (player, tags) => (tags.includes("cc_re:desert") || tags.includes("cc_re:mesa")) &&
                player.location.y < this.skyAmbienceLevel &&
                player.location.y > this.surfaceAmbienceLevel &&
                playerWorldEvents.get(player.name) === undefined,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_fog_desert",
        }));
        AmbientFog.register(new AmbientFog({
            identifier: "cc_re:birch",
            conditions: (player, tags) => tags.includes("cc_re:birch") &&
                player.location.y < this.skyAmbienceLevel &&
                player.location.y > this.surfaceAmbienceLevel &&
                playerWorldEvents.get(player.name) === undefined,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_fog_birch",
        }));
        AmbientFog.register(new AmbientFog({
            identifier: "cc_re:taiga",
            conditions: (player, tags) => tags.includes("cc_re:taiga") &&
                !tags.includes("cc_re:cold") &&
                player.location.y < this.skyAmbienceLevel &&
                player.location.y > this.surfaceAmbienceLevel &&
                playerWorldEvents.get(player.name) === undefined,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_fog_taiga",
        }));
        AmbientFog.register(new AmbientFog({
            identifier: "cc_re:forest",
            conditions: (player, tags) => tags.includes("cc_re:forest") &&
                !tags.includes("cc_re:taiga") &&
                !tags.includes("cc_re:cold") &&
                !tags.includes("cc_re:birch") &&
                !tags.includes("cc_re:roofed") &&
                player.location.y < this.skyAmbienceLevel &&
                player.location.y > this.surfaceAmbienceLevel &&
                playerWorldEvents.get(player.name) === undefined,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_fog_forest",
        }));
        AmbientFog.register(new AmbientFog({
            identifier: "cc_re:roofed",
            conditions: (player, tags) => tags.includes("cc_re:roofed") &&
                player.location.y < this.skyAmbienceLevel &&
                player.location.y > this.surfaceAmbienceLevel &&
                playerWorldEvents.get(player.name) === undefined,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_fog_roofed",
        }));
        AmbientFog.register(new AmbientFog({
            identifier: "cc_re:plains",
            conditions: (player, tags) => tags.includes("cc_re:plains") &&
                !tags.includes("cc_re:cold") &&
                !tags.includes("cc_re:ice") &&
                player.location.y < this.skyAmbienceLevel &&
                player.location.y > this.surfaceAmbienceLevel &&
                playerWorldEvents.get(player.name) === undefined,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_fog_plains",
        }));
        AmbientFog.register(new AmbientFog({
            identifier: "cc_re:swamp",
            conditions: (player, tags) => (tags.includes("cc_re:swamp") || tags.includes("cc_re:mangrove_swamp")) &&
                player.location.y < this.skyAmbienceLevel &&
                player.location.y > this.surfaceAmbienceLevel &&
                playerWorldEvents.get(player.name) === undefined,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_fog_swamp",
        }));
        AmbientFog.register(new AmbientFog({
            identifier: "cc_re:lush",
            conditions: (player, tags) => tags.includes("cc_re:lush_caves") &&
                player.location.y < this.skyAmbienceLevel &&
                player.location.y < this.surfaceAmbienceLevel &&
                playerWorldEvents.get(player.name) === undefined,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_fog_cave",
        }));
        AmbientFog.register(new AmbientFog({
            identifier: "cc_re:savanna",
            conditions: (player, tags) => tags.includes("cc_re:savanna") &&
                player.location.y < this.skyAmbienceLevel &&
                player.location.y > this.surfaceAmbienceLevel &&
                playerWorldEvents.get(player.name) === undefined,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_fog_savanna",
        }));
        AmbientFog.register(new AmbientFog({
            identifier: "cc_re:mooshroom",
            conditions: (player, tags) => tags.includes("cc_re:mooshroom_island") &&
                player.location.y < this.skyAmbienceLevel &&
                player.location.y > this.surfaceAmbienceLevel &&
                playerWorldEvents.get(player.name) === undefined,
            checkProperty: CheckProperty.BIOME,
            dynamicProperty: "cc_re:allow_fog_mooshroom",
        }));
        AmbientFog.initialize();
    }
}
