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": "Lobby Portal Transfer",
|
||||
"description": "Auto-transfers players when they step into portal areas",
|
||||
"uuid": "a1b2c3d4-1111-2222-3333-abcdef123456",
|
||||
"version": [1, 0, 3],
|
||||
"version": [1, 0, 4],
|
||||
"min_engine_version": [1, 21, 0]
|
||||
},
|
||||
"modules": [
|
||||
@@ -12,7 +12,7 @@
|
||||
"type": "script",
|
||||
"language": "javascript",
|
||||
"uuid": "a1b2c3d4-4444-5555-6666-abcdef789012",
|
||||
"version": [1, 0, 3],
|
||||
"version": [1, 0, 4],
|
||||
"entry": "scripts/main.js"
|
||||
}
|
||||
],
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { world, system } from "@minecraft/server";
|
||||
import { transferPlayer } from "@minecraft/server-admin";
|
||||
|
||||
// Portal definitions: name, center position, and direct transfer target
|
||||
// Portal definitions: name, center position, color, and direct transfer target
|
||||
const portals = [
|
||||
{ name: "Jamie's World", x: -15, y: 65, z: -24, host: "10.0.0.247", port: 19133 },
|
||||
{ name: "Lyla's World", x: 0, y: 65, z: -24, host: "10.0.0.247", port: 19134 },
|
||||
{ name: "Mya's World", x: 15, y: 65, z: -24, host: "10.0.0.247", port: 19135 },
|
||||
{ name: "Jamie's World", x: -15, y: 65, z: -24, host: "10.0.0.247", port: 19133, color: "§a" },
|
||||
{ name: "Lyla's World", x: 0, y: 65, z: -24, host: "10.0.0.247", port: 19134, color: "§d" },
|
||||
{ name: "Mya's World", x: 15, y: 65, z: -24, host: "10.0.0.247", port: 19135, color: "§b" },
|
||||
];
|
||||
|
||||
const PORTAL_RADIUS_X = 2.5;
|
||||
@@ -43,6 +43,9 @@ system.runInterval(() => {
|
||||
|
||||
if (dx < PORTAL_RADIUS_X && dy < PORTAL_RADIUS_Y && dz < PORTAL_RADIUS_Z) {
|
||||
cooldowns.set(playerId, system.currentTick);
|
||||
// Show title notification
|
||||
player.runCommand(`titleraw @s title {"rawtext":[{"text":"${portal.color}${portal.name}"}]}`);
|
||||
player.runCommand(`titleraw @s subtitle {"rawtext":[{"text":"§7Transferring..."}]}`);
|
||||
player.sendMessage(`§6Transferring to ${portal.name}...`);
|
||||
try {
|
||||
transferPlayer(player, { hostname: portal.host, port: portal.port });
|
||||
@@ -61,6 +64,45 @@ world.afterEvents.playerLeave.subscribe((event) => {
|
||||
spawnTicks.delete(event.playerId);
|
||||
});
|
||||
|
||||
// ─── Place signs above each portal on load ──────────────────────
|
||||
|
||||
function placePortalSigns() {
|
||||
const overworld = world.getDimension("overworld");
|
||||
const signs = [
|
||||
{ x: -15, y: 70, z: -23, name: "Jamie's", color: "§a" },
|
||||
{ x: 0, y: 70, z: -23, name: "Lyla's", color: "§d" },
|
||||
{ x: 15, y: 70, z: -23, name: "Mya's", color: "§b" },
|
||||
];
|
||||
|
||||
for (const sign of signs) {
|
||||
try {
|
||||
// Place wall sign facing south (toward players approaching from +Z)
|
||||
overworld.runCommand(`setblock ${sign.x} ${sign.y} ${sign.z} oak_wall_sign ["facing_direction":3]`);
|
||||
} catch (e) {
|
||||
// Non-fatal — chunks may not be loaded
|
||||
}
|
||||
}
|
||||
|
||||
// Delay to let sign blocks register, then write text
|
||||
system.runTimeout(() => {
|
||||
for (const sign of signs) {
|
||||
try {
|
||||
const block = overworld.getBlock({ x: sign.x, y: sign.y, z: sign.z });
|
||||
if (!block) continue;
|
||||
const signComponent = block.getComponent("minecraft:sign");
|
||||
if (!signComponent) continue;
|
||||
signComponent.setText(`${sign.color}${sign.name}\n${sign.color}World\n§7▼ Step in ▼`);
|
||||
} catch (e) {
|
||||
// Non-fatal
|
||||
}
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
|
||||
system.runTimeout(() => {
|
||||
placePortalSigns();
|
||||
}, 40);
|
||||
|
||||
system.run(() => {
|
||||
world.sendMessage("§6[Hub] §7Portal transfer system loaded!");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user