import { EntityRideableComponent, MinecraftDimensionTypes, Player, system, world } from "@minecraft/server";
system.runInterval(() => {
    const dimensions = [
        world.getDimension(MinecraftDimensionTypes.overworld),
        world.getDimension(MinecraftDimensionTypes.nether),
        world.getDimension(MinecraftDimensionTypes.theEnd)
    ];
    for (const dimension of dimensions) {
        const rideablesWithJumpFlag = dimension.getEntities().filter(entity => entity.getProperty("nps_atm:has_rider_jumping") != undefined);
        for (const entity of rideablesWithJumpFlag) {
            const ERC = entity.getComponent(EntityRideableComponent.componentId);
            if (!ERC)
                continue;
            const riders = ERC.getRiders();
            const pilot = riders[0];
            const isJumping = pilot instanceof Player ? pilot.isJumping : false;
            entity.setProperty("nps_atm:has_rider_jumping", isJumping);
        }
    }
}, 10);
