2015-12-12 16:48:29 +01:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using MinecraftClient.Mapping;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MinecraftClient.Commands
|
|
|
|
|
|
{
|
|
|
|
|
|
public class Move : Command
|
|
|
|
|
|
{
|
2020-10-17 19:41:31 +08:00
|
|
|
|
public override string CmdName { get { return "move"; } }
|
|
|
|
|
|
public override string CmdUsage { get { return "move <on|off|get|up|down|east|west|north|south|x y z>"; } }
|
|
|
|
|
|
public override string CmdDesc { get { return "walk or start walking."; } }
|
2015-12-12 16:48:29 +01:00
|
|
|
|
|
2020-06-20 15:01:16 +02:00
|
|
|
|
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
2015-12-12 16:48:29 +01:00
|
|
|
|
{
|
2019-04-28 21:32:03 +02:00
|
|
|
|
string[] args = getArgs(command);
|
|
|
|
|
|
string argStr = getArg(command).Trim().ToLower();
|
|
|
|
|
|
|
|
|
|
|
|
if (argStr == "on")
|
|
|
|
|
|
{
|
|
|
|
|
|
handler.SetTerrainEnabled(true);
|
2020-10-17 19:41:31 +08:00
|
|
|
|
return Translations.Get("cmd.move.enable");
|
2019-04-28 21:32:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
else if (argStr == "off")
|
|
|
|
|
|
{
|
|
|
|
|
|
handler.SetTerrainEnabled(false);
|
2020-10-17 19:41:31 +08:00
|
|
|
|
return Translations.Get("cmd.move.disable");
|
2019-04-28 21:32:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
else if (handler.GetTerrainEnabled())
|
2015-12-12 16:48:29 +01:00
|
|
|
|
{
|
|
|
|
|
|
if (args.Length == 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
Direction direction;
|
2019-04-28 21:32:03 +02:00
|
|
|
|
switch (argStr)
|
2015-12-12 16:48:29 +01:00
|
|
|
|
{
|
|
|
|
|
|
case "up": direction = Direction.Up; break;
|
|
|
|
|
|
case "down": direction = Direction.Down; break;
|
|
|
|
|
|
case "east": direction = Direction.East; break;
|
|
|
|
|
|
case "west": direction = Direction.West; break;
|
|
|
|
|
|
case "north": direction = Direction.North; break;
|
|
|
|
|
|
case "south": direction = Direction.South; break;
|
2016-03-11 10:52:19 +01:00
|
|
|
|
case "get": return handler.GetCurrentLocation().ToString();
|
2020-10-17 19:41:31 +08:00
|
|
|
|
default: return Translations.Get("cmd.look.unknown", argStr);
|
2015-12-12 16:48:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
if (Movement.CanMove(handler.GetWorld(), handler.GetCurrentLocation(), direction))
|
|
|
|
|
|
{
|
|
|
|
|
|
handler.MoveTo(Movement.Move(handler.GetCurrentLocation(), direction));
|
2020-10-17 19:41:31 +08:00
|
|
|
|
return Translations.Get("cmd.move.moving", argStr);
|
2015-12-12 16:48:29 +01:00
|
|
|
|
}
|
2020-10-17 19:41:31 +08:00
|
|
|
|
else return Translations.Get("cmd.move.dir_fail");
|
2015-12-12 16:48:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
else if (args.Length == 3)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
int x = int.Parse(args[0]);
|
|
|
|
|
|
int y = int.Parse(args[1]);
|
|
|
|
|
|
int z = int.Parse(args[2]);
|
|
|
|
|
|
Location goal = new Location(x, y, z);
|
|
|
|
|
|
if (handler.MoveTo(goal))
|
2020-10-17 19:41:31 +08:00
|
|
|
|
return Translations.Get("cmd.move.walk", goal);
|
|
|
|
|
|
return Translations.Get("cmd.move.fail", goal);
|
2015-12-12 16:48:29 +01:00
|
|
|
|
}
|
2020-10-17 19:41:31 +08:00
|
|
|
|
catch (FormatException) { return GetCmdDescTranslated(); }
|
2015-12-12 16:48:29 +01:00
|
|
|
|
}
|
2020-10-17 19:41:31 +08:00
|
|
|
|
else return GetCmdDescTranslated();
|
2015-12-12 16:48:29 +01:00
|
|
|
|
}
|
2020-10-17 19:41:31 +08:00
|
|
|
|
else return Translations.Get("extra.terrainandmovement_required");
|
2015-12-12 16:48:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|