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

system.runInterval(() => {
    const duckEntities = world.getDimension("overworld").getEntities({ type: "ecbl_bc:duck" });

    duckEntities.forEach(duck => {
        const testForCommand = `testforblock ~~-1~ air`;

        duck.runCommandAsync(testForCommand).then((result) => {
            if (result.successCount > 0) {

                duck.runCommand('playsound mob.ecbl_bc.duck.fly @a[r=10] ~~~ 1 1')
            }
        })

    });
}, 10);

system.runInterval(() => {
    const duckEntities = world.getDimension("overworld").getEntities({ type: "ecbl_bc:goose" });

    duckEntities.forEach(goose => {
        const testForCommand = `testforblock ~~-1~ air`;

        goose.runCommandAsync(testForCommand).then((result) => {
            if (result.successCount > 0) {

                goose.runCommand('playsound mob.ecbl_bc.goose.fly @a[r=10] ~~~ 1 1')
            }
        })

    });
}, 10);