import { system, world } from "@minecraft/server";
const TIME_DAY_START = 0;
const TIME_DAY_END = 13000;
const TIME_NIGHT_START = 13001;
const TIME_NIGHT_END = 24000;
const NEAR_NEST_RANGE = 12;
const NEAR_PLAYER_RANGE = 32;
const NEAR_MOUNT_RANGE = 16;
const MOUNT_FAMILY = "kicu_mmad_mount";
const NEST_FAMILY = "kicu_mmad_nest";
function getMcTime() {
    return world.getTimeOfDay();
}
function getAllMounts() {
    return world.getDimension("overworld").getEntities({ families: ["kicu_mmad_wild_mount"] });
}
function isFlying(mount) {
    return mount.getProperty("kicu_mmad:wild_fly") || !mount.isOnGround;
}
function isNearNest(entity) {
    return (entity.dimension.getEntities({
        location: entity.location,
        families: [NEST_FAMILY],
        maxDistance: NEAR_NEST_RANGE,
        closest: 1,
    }).length > 0);
}
function isNearTamedMount(entity) {
    return (entity.dimension.getEntities({
        location: entity.location,
        families: [MOUNT_FAMILY],
        maxDistance: NEAR_MOUNT_RANGE,
        closest: 1,
    }).length > 0);
}
function isNearPlayer(entity) {
    return (entity.dimension.getPlayers({
        location: entity.location,
        maxDistance: NEAR_PLAYER_RANGE,
        closest: 1,
    }).length > 0);
}
function isDay(timeOfDay) {
    if (timeOfDay >= TIME_DAY_START && timeOfDay < TIME_DAY_END) {
        return true;
    }
    else if (timeOfDay >= TIME_NIGHT_START && timeOfDay < TIME_NIGHT_END) {
        return false;
    }
    return true;
}
export function checkIsDay() {
    const timeOfDay = getMcTime();
    return isDay(timeOfDay);
}
export function canSleep(mount) {
    return !isFlying(mount) && !isNearPlayer(mount) && !isNearTamedMount(mount) && isNearNest(mount);
}
export function isSleeping(mount) {
    return mount.getProperty("kicu_mmad:sleep");
}
export function setWake(mount) {
    system.run(() => {
        mount.runCommand("event entity @s kicu_mmad:set_sleep_false");
    });
}
export function setSleep(mount) {
    system.run(() => {
        mount.runCommand("event entity @s kicu_mmad:set_sleep_true");
    });
}

//# sourceMappingURL=../../../../../_KiCuMountsBPDebug/kicu/mmad/C/Sleeping.js.map
