mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Support using relative coordinates in /useblock
This commit is contained in:
parent
2a2e47a955
commit
85f6d807bf
2 changed files with 16 additions and 9 deletions
|
|
@ -12,22 +12,28 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "useblock <x> <y> <z>"; } }
|
||||
public override string CmdDesc { get { return "cmd.useblock.desc"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
||||
{
|
||||
if (!handler.GetTerrainEnabled()) return Translations.Get("extra.terrainandmovement_required");
|
||||
if (hasArg(command))
|
||||
if (!handler.GetTerrainEnabled())
|
||||
return Translations.Get("extra.terrainandmovement_required");
|
||||
else if (hasArg(command))
|
||||
{
|
||||
string[] args = getArgs(command);
|
||||
if (args.Length >= 3)
|
||||
{
|
||||
int x = Convert.ToInt32(args[0]);
|
||||
int y = Convert.ToInt32(args[1]);
|
||||
int z = Convert.ToInt32(args[2]);
|
||||
handler.PlaceBlock(new Location(x, y, z), Direction.Down);
|
||||
Location current = handler.GetCurrentLocation();
|
||||
double x = args[0].StartsWith('~') ? current.X + (args[0].Length > 1 ? double.Parse(args[0][1..]) : 0) : double.Parse(args[0]);
|
||||
double y = args[1].StartsWith('~') ? current.Y + (args[1].Length > 1 ? double.Parse(args[1][1..]) : 0) : double.Parse(args[1]);
|
||||
double z = args[2].StartsWith('~') ? current.Z + (args[2].Length > 1 ? double.Parse(args[2][1..]) : 0) : double.Parse(args[2]);
|
||||
Location block = new Location(x, y, z).ToFloor(), blockCenter = block.ToCenter();
|
||||
bool res = handler.PlaceBlock(block, Direction.Down);
|
||||
return Translations.Get("cmd.useblock.use", blockCenter.X, blockCenter.Y, blockCenter.Z, res ? "succeeded" : "failed");
|
||||
}
|
||||
else { return GetCmdDescTranslated(); }
|
||||
else
|
||||
return GetCmdDescTranslated();
|
||||
}
|
||||
return GetCmdDescTranslated();
|
||||
else
|
||||
return GetCmdDescTranslated();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -382,6 +382,7 @@ cmd.tps.current=Current tps
|
|||
|
||||
# Useblock
|
||||
cmd.useblock.desc=Place a block or open chest
|
||||
cmd.useblock.use=Useblock at ({0:0.0}, {1:0.0}, {2:0.0}) {3}
|
||||
|
||||
# Useitem
|
||||
cmd.useitem.desc=Use (left click) an item on the hand
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue