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

world.afterEvents.playerEmote.subscribe((event) => {
    const player = event.player;
    const lookingAt = player.getEntitiesFromViewDirection({ maxDistance: 1000, type: "sapphire_meteors:stars" });

    if (lookingAt.length > 0) {

        player.dimension.playSound("random.levelup", player.location);
        player.runCommand(`loot give @s loot "sapphire/meteors/stars_loot"`);
        world.sendMessage(`§eYou've looked at the stars!`);
    }
});