feat(portals): add portal signs, transfer notifications, and welcome titles
Lobby portals now have oak wall signs showing whose world each portal leads to (Jamie/Lyla/Mya with color-coded text). Players see a title notification when entering a portal. Child worlds show a welcome title with the world name on arrival, read from variables.json via @minecraft/server-admin. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
"name": "Hub Return Transfer",
|
||||
"description": "Transfers players back to lobby when they step on the return portal",
|
||||
"uuid": "b2c3d4e5-1111-2222-3333-fedcba654321",
|
||||
"version": [1, 0, 3],
|
||||
"version": [1, 0, 4],
|
||||
"min_engine_version": [1, 21, 0]
|
||||
},
|
||||
"modules": [
|
||||
@@ -12,7 +12,7 @@
|
||||
"type": "script",
|
||||
"language": "javascript",
|
||||
"uuid": "b2c3d4e5-4444-5555-6666-fedcba987654",
|
||||
"version": [1, 0, 3],
|
||||
"version": [1, 0, 4],
|
||||
"entry": "scripts/main.js"
|
||||
}
|
||||
],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { world, system, ItemStack } from "@minecraft/server";
|
||||
import { transferPlayer } from "@minecraft/server-admin";
|
||||
import { transferPlayer, variables } from "@minecraft/server-admin";
|
||||
|
||||
const LOBBY_HOST = "10.0.0.247";
|
||||
const LOBBY_PORT = 19132;
|
||||
@@ -47,13 +47,23 @@ function giveCompassIfMissing(player) {
|
||||
player.sendMessage("§b[Hub] §fYou received a §dHub Compass§f — use it to return to the lobby!");
|
||||
}
|
||||
|
||||
// Get the world name from server variables.json for the welcome message
|
||||
let WORLD_NAME = "this world";
|
||||
try {
|
||||
WORLD_NAME = variables.get("world_name") || "this world";
|
||||
} catch (e) {
|
||||
// variables.json may not exist — use fallback
|
||||
}
|
||||
|
||||
world.afterEvents.playerSpawn.subscribe((event) => {
|
||||
const player = event.player;
|
||||
// Mark spawn time for portal protection (prevents transfer loop on arrival)
|
||||
spawnTimes.set(player.name, Date.now());
|
||||
// Small delay to let inventory load
|
||||
// Show welcome title and give compass after a short delay
|
||||
system.runTimeout(() => {
|
||||
try {
|
||||
player.runCommand(`titleraw @s title {"rawtext":[{"text":"§6Welcome!"}]}`);
|
||||
player.runCommand(`titleraw @s subtitle {"rawtext":[{"text":"§7You are now in §e${WORLD_NAME}"}]}`);
|
||||
giveCompassIfMissing(player);
|
||||
} catch (e) {
|
||||
// Silently ignore — player may have disconnected
|
||||
|
||||
Reference in New Issue
Block a user