import { world, system } from '@minecraft/server'

let nextWind = system.currentTick + Math.floor(Math.random() * (144000 - 72000 + 1)) + 72000;
let nextDuration = Math.floor(Math.random() * (24000 - 12000 + 1)) + 12000;

system.runInterval(() => {
    const currentTick = system.currentTick
    if (currentTick < nextWind) return;
    if (currentTick - nextWind > nextDuration) {
        nextWind = currentTick + Math.floor(Math.random() * (144000 - 72000 + 1)) + 72000;
        nextDuration = Math.floor(Math.random() * (24000 - 12000 + 1)) + 12000;
        return;
    }

    world.getDimension('overworld').getEntities({ families: ['flying'] })/*.concat(NETHER.getEntities({ families: ['flying'] }).concat(THE_END.getEntities({ families: ['flying'] })))*/.forEach(entity => entity.addEffect('speed', 20))
    world.getAllPlayers().forEach(player => {
        player.spawnParticle('cyd_dino:wind_1', player.location)
        player.spawnParticle('cyd_dino:wind_2', player.location)
    })
}, 19)