Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/server/command/spawn.zig
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ pub const usage =
\\/spawn <x> <y> <z>
\\/spawn @<playerIndex>
\\/spawn @<playerIndex> <x> <y> <z>
\\/spawn @<playerIndex> <reset>

@IntegratedQuantum IntegratedQuantum Sep 6, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's optional, /spawn <reset> is also allowed, please add it to the list

\\/spawn world
\\/spawn world <x> <y> <z>
;

pub const Args = union(enum) {
@"/spawn <playerIndex> <x> <y> <z>": struct { playerIndex: ?command.PlayerIndex, x: command.Coordinate, y: command.Coordinate, z: command.Coordinate },
@"/spawn <playerIndex> <reset>": struct { playerIndex: ?command.PlayerIndex, reset: enum { reset } },
@"/spawn <world> <x> <y> <z>": struct { world: enum { world }, x: command.Coordinate, y: command.Coordinate, z: command.Coordinate },
@"/spawn <world>": struct { world: enum { world } },
@"/spawn <playerIndex>": struct { playerIndex: ?command.PlayerIndex },
Expand All @@ -28,6 +30,10 @@ pub fn execute(args: Args, source: Source) void {
const target = command.Target.fromPlayerIndex(params.playerIndex, source) catch return;
target.user.spawnPos = command.resolveCoordinates(params.x, params.y, params.z, source) catch return;
},
.@"/spawn <playerIndex> <reset>" => |params| {
const target = command.Target.fromPlayerIndex(params.playerIndex, source) catch return;
target.user.spawnPos = null;
},
.@"/spawn <playerIndex>" => |params| {
const target = command.Target.fromPlayerIndex(params.playerIndex, source) catch return;
source.sendMessage("#ffff00{}", .{target.user.getSpawnPos()});
Expand Down
Loading