mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-24 05:10:42 -04:00
add /client teleport
This commit is contained in:
parent
8fc9a9bd72
commit
8f81cb6d9a
@ -27,6 +27,7 @@ namespace ClassicalSharp.Commands {
|
||||
if (!game.Server.IsSinglePlayer) return;
|
||||
Register(new ModelCommand());
|
||||
Register(new CuboidCommand());
|
||||
Register(new TeleportCommand());
|
||||
}
|
||||
|
||||
public void Ready(Game game) { }
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using ClassicalSharp.Entities;
|
||||
using ClassicalSharp.Events;
|
||||
using ClassicalSharp.Renderers;
|
||||
using OpenTK.Input;
|
||||
@ -126,4 +127,31 @@ namespace ClassicalSharp.Commands {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class TeleportCommand : Command {
|
||||
|
||||
public TeleportCommand() {
|
||||
Name = "Teleport";
|
||||
Help = new string[] {
|
||||
"&a/client teleport [x y z]",
|
||||
"&eMoves you to the given coordinates.",
|
||||
};
|
||||
}
|
||||
|
||||
public override void Execute(string[] args) {
|
||||
if (args.Length != 4) {
|
||||
game.Chat.Add("&e/client teleport: &cYou didn't specify X, Y and Z coordinates.");
|
||||
} else {
|
||||
float x = 0, y = 0, z = 0;
|
||||
if (!Utils.TryParseDecimal(args[1], out x) ||
|
||||
!Utils.TryParseDecimal(args[2], out y) ||
|
||||
!Utils.TryParseDecimal(args[3], out z)) {
|
||||
game.Chat.Add("&e/client teleport: &cCoordinates must be decimals");
|
||||
}
|
||||
|
||||
LocationUpdate update = LocationUpdate.MakePos(x, y, z, false);
|
||||
game.LocalPlayer.SetLocation(update, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user