Tp command
This commit is contained in:
@@ -113,6 +113,7 @@ Commands can only be registered during `setup`.
|
|||||||
| `/time` | Shows the time |
|
| `/time` | Shows the time |
|
||||||
| `/time set <day\|noon\|sunset\|night\|midnight\|ticks>` | Jumps to the next time of day. Time never goes back |
|
| `/time set <day\|noon\|sunset\|night\|midnight\|ticks>` | Jumps to the next time of day. Time never goes back |
|
||||||
| `/time add <ticks>` | Moves time forward |
|
| `/time add <ticks>` | Moves time forward |
|
||||||
|
| `/tp <x> <y> <z>` | Teleports you there |
|
||||||
| `/tps` | Shows how the game loop keeps up |
|
| `/tps` | Shows how the game loop keeps up |
|
||||||
| `/skin [url] [slim\|normal]` | Changes your skin to a 64×64 PNG, or back to the default |
|
| `/skin [url] [slim\|normal]` | Changes your skin to a 64×64 PNG, or back to the default |
|
||||||
| `/help [command]` | Every command's usage, or one's |
|
| `/help [command]` | Every command's usage, or one's |
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import {
|
|||||||
integer,
|
integer,
|
||||||
item,
|
item,
|
||||||
literal,
|
literal,
|
||||||
|
number,
|
||||||
word,
|
word,
|
||||||
} from "$/common/commands.ts";
|
} from "$/common/commands.ts";
|
||||||
import type { GameLoop } from "./game_loop.ts";
|
import type { GameLoop } from "./game_loop.ts";
|
||||||
@@ -1218,6 +1219,21 @@ export class GameServer {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// TODO: only let operators do this
|
||||||
|
register(
|
||||||
|
literal<ServerCommandSource>("tp").describe("Teleports you to x y z").then(
|
||||||
|
argument<number, ServerCommandSource>("x", number()).then(
|
||||||
|
argument<number, ServerCommandSource>("y", number()).then(
|
||||||
|
argument<number, ServerCommandSource>("z", number()).executes((context) => {
|
||||||
|
const [x, y, z] = ["x", "y", "z"].map((axis) => context.get<number>(axis));
|
||||||
|
this.teleport(context.source.server_player, x, y, z);
|
||||||
|
context.source.send_message(`Teleported to ${x} ${y} ${z}`);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
register(
|
register(
|
||||||
literal<ServerCommandSource>("tps").describe("Shows how the game loop keeps up").executes((context) => {
|
literal<ServerCommandSource>("tps").describe("Shows how the game loop keeps up").executes((context) => {
|
||||||
if (!this.loop) {
|
if (!this.loop) {
|
||||||
|
|||||||
@@ -217,3 +217,9 @@ Deno.test("/effect gives you an effect, for 30 seconds or as many as you say", a
|
|||||||
t.send(1, { type: "chat", text: "/effect bworld:regeneration 5" });
|
t.send(1, { type: "chat", text: "/effect bworld:regeneration 5" });
|
||||||
assertEquals(t.player.get_effect("bworld:regeneration")?.duration, 100);
|
assertEquals(t.player.get_effect("bworld:regeneration")?.duration, 100);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Deno.test("/tp x y z teleports you there", async () => {
|
||||||
|
const t = await setup();
|
||||||
|
t.send(1, { type: "chat", text: "/tp 10 120.5 -3" });
|
||||||
|
assertEquals([t.player.x, t.player.y, t.player.z], [10, 120.5, -3]);
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user