import { world, Player, EntityComponentTypes, } from "@minecraft/server";
import { itemLoreConfig } from "../DATA/LoreConfig";
export function processLinkedMountsAndRiders() {
    const allPlayers = world.getAllPlayers();
    allPlayers.forEach((player) => {
        addLoreLines(player);
    });
}
function addLoreLines(player) {
    const inventory = player.getComponent("minecraft:inventory");
    const inv = inventory.container;
    for (let slot = 0; slot < inventory.inventorySize; slot++) {
        const item = inv.getItem(slot);
        if (!item)
            continue;
        const loreConfig = itemLoreConfig[item.typeId];
        if (loreConfig && item.getLore().length < 1) {
            item.setLore(loreConfig);
            inv.setItem(slot, item);
        }
    }
}
export function getLinkedPlayer(mount) {
    const rideableComponent = mount.getComponent(EntityComponentTypes.Rideable);
    if (rideableComponent.getRiders()[0] instanceof Player) {
        return rideableComponent.getRiders()[0];
    }
    return null;
}
export function getLinkedMount(player) {
    const ridingComponent = player.getComponent(EntityComponentTypes.Riding);
    if (ridingComponent && ridingComponent.entityRidingOn) {
        return [ridingComponent.entityRidingOn];
    }
    return [];
}

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