Files
shooting_star_bp
shooting_star_rp
package_mcaddon.py
Code
6 436
shooting_star_bp/scripts/main.js
import { ItemStack, system, world } from "@minecraft/server";
const TAGS = {
started: "shootingstar.started",
examined: "shootingstar.examined",
heard: "shootingstar.heard",
followed: "shootingstar.followed",
released: "shootingstar.released",
kept: "shootingstar.kept",
resolved: "shootingstar.resolved"
};
const PREFIX = "§8[§bShooting Star§8] §r";
function tell(player, message) {
player.sendMessage(`${PREFIX}${message}`);
}
function emit(player, particle, offset = 1) {
const location = player.location;
player.dimension.spawnParticle(particle, {
x: location.x,
y: location.y + offset,
z: location.z
});
}
function isNight() {
const time = world.getTimeOfDay();
return time >= 13000 && time <= 23000;
}
function showHelp(player) {
tell(player, "§fA strange light has fallen. Use these chat commands:");
player.sendMessage("§b!star begin §7— begin the story");
player.sendMessage("§b!star examine §7— investigate the fallen fragment");
player.sendMessage("§b!star listen §7— hear the message within it");
player.sendMessage("§b!star follow §7— follow its trail after dark");
player.sendMessage("§b!star release §7— let the Wisp return to the sky");
player.sendMessage("§b!star keep §7— ask the Wisp to stay");
player.sendMessage("§b!star journal §7— review your progress");
}
function showJournal(player) {
if (!player.hasTag(TAGS.started)) {
tell(player, "Your journal is empty. Use §b!star begin§r to start.");
return;
}
const objective = player.hasTag(TAGS.resolved)
? player.hasTag(TAGS.kept)
? "You asked the Wisp to stay. Its light follows you now."
: "You released the Wisp, and its final light is yours to carry."
: !player.hasTag(TAGS.examined)
? "Find the fallen fragment and examine it."
: !player.hasTag(TAGS.heard)
? "Listen for the voice hidden in the fragment."
: !player.hasTag(TAGS.followed)
? "Follow the Wisp's trail after dark in the Overworld."
: "Choose whether to release the Wisp or ask it to stay.";
tell(player, `Journal: ${objective}`);
}
function handleCommand(player, command) {
if (command === "resolve") {
command = "release";
}
if (command === "" || command === "help") {
showHelp(player);
return;
}
if (command === "begin") {
if (player.hasTag(TAGS.started)) {
tell(player, "The story has already begun. Use §b!star journal§r to see your next step.");
return;
}
player.addTag(TAGS.started);
const location = player.location;
const wisp = player.dimension.spawnEntity("shootingstar:star_wisp", {
x: location.x + 2,
y: location.y + 1,
z: location.z
});
wisp.nameTag = "The Fallen Star";
emit(player, "minecraft:totem_particle", 2);
tell(player, "A streak of pale light falls nearby. Something is moving in its wake.");
tell(player, "Use §b!star examine§r to investigate the fragment.");
return;
}
if (command === "journal") {
showJournal(player);
return;
}
if (!player.hasTag(TAGS.started)) {
tell(player, "Begin the story first with §b!star begin§r.");
return;
}
if (player.hasTag(TAGS.resolved)) {
tell(player, "The night is quiet now. The Wisp's story has reached its end.");
return;
}
if (command === "examine") {
if (player.hasTag(TAGS.examined)) {
tell(player, "The fragment's markings are already in your journal.");
return;
}
player.addTag(TAGS.examined);
emit(player, "minecraft:basic_flame_particle", 1);
emit(player, "minecraft:totem_particle", 2);
tell(player, "The fragment is cold, but its silver markings pulse like a distant heartbeat.");
tell(player, "Use §b!star listen§r and wait for the silence to answer.");
return;
}
if (command === "listen") {
if (!player.hasTag(TAGS.examined)) {
tell(player, "Examine the fallen fragment before trying to hear its message.");
return;
}
if (player.hasTag(TAGS.heard)) {
tell(player, "The whisper is familiar now: it is calling you toward the night sky.");
return;
}
player.addTag(TAGS.heard);
player.addEffect("night_vision", 400, {
amplifier: 0,
showParticles: false
});
try {
player.playSound("ambient.cave", {
volume: 0.7,
pitch: 0.7
});
} catch {
// Continue the story even if a sound is unavailable in a particular game build.
}
emit(player, "minecraft:totem_particle", 2);
tell(player, "A whisper crosses your thoughts: “I remember the sky, but not the way home.”");
tell(player, "Follow the Wisp's trail after dark in the Overworld with §b!star follow§r.");
return;
}
if (command === "follow") {
if (!player.hasTag(TAGS.heard)) {
tell(player, "Listen to the fragment before following the Wisp.");
return;
}
if (player.dimension.id !== "minecraft:overworld" || !isNight()) {
tell(player, "The trail appears only after dark in the Overworld.");
return;
}
if (player.hasTag(TAGS.followed)) {
tell(player, "You have found the trail. Choose with §b!star release§r or §b!star keep§r.");
return;
}
player.addTag(TAGS.followed);
emit(player, "minecraft:totem_particle", 3);
tell(player, "Above the treeline, the stars bend toward the Wisp. It is searching for a way back.");
tell(player, "Choose with §b!star release§r or §b!star keep§r when you are ready.");
return;
}
if (command === "release" || command === "keep") {
if (!player.hasTag(TAGS.followed)) {
tell(player, "Follow the Wisp's trail after dark before making your choice.");
return;
}
player.addTag(TAGS.resolved);
const wisps = player.dimension.getEntities({
type: "shootingstar:star_wisp",
location: player.location,
maxDistance: 48
});
if (command === "keep") {
player.addTag(TAGS.kept);
for (const wisp of wisps) {
wisp.nameTag = "The Bound Star";
}
player.dimension.spawnItem(new ItemStack("minecraft:glowstone_dust", 1), player.location);
player.addEffect("slow_falling", 300, { amplifier: 0, showParticles: false });
emit(player, "minecraft:totem_particle", 2);