mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +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,21 +12,27 @@ namespace MinecraftClient.Commands
|
||||||
public override string CmdUsage { get { return "useblock <x> <y> <z>"; } }
|
public override string CmdUsage { get { return "useblock <x> <y> <z>"; } }
|
||||||
public override string CmdDesc { get { return "cmd.useblock.desc"; } }
|
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 (!handler.GetTerrainEnabled())
|
||||||
if (hasArg(command))
|
return Translations.Get("extra.terrainandmovement_required");
|
||||||
|
else if (hasArg(command))
|
||||||
{
|
{
|
||||||
string[] args = getArgs(command);
|
string[] args = getArgs(command);
|
||||||
if (args.Length >= 3)
|
if (args.Length >= 3)
|
||||||
{
|
{
|
||||||
int x = Convert.ToInt32(args[0]);
|
Location current = handler.GetCurrentLocation();
|
||||||
int y = Convert.ToInt32(args[1]);
|
double x = args[0].StartsWith('~') ? current.X + (args[0].Length > 1 ? double.Parse(args[0][1..]) : 0) : double.Parse(args[0]);
|
||||||
int z = Convert.ToInt32(args[2]);
|
double y = args[1].StartsWith('~') ? current.Y + (args[1].Length > 1 ? double.Parse(args[1][1..]) : 0) : double.Parse(args[1]);
|
||||||
handler.PlaceBlock(new Location(x, y, z), Direction.Down);
|
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();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
return GetCmdDescTranslated();
|
return GetCmdDescTranslated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -382,6 +382,7 @@ cmd.tps.current=Current tps
|
||||||
|
|
||||||
# Useblock
|
# Useblock
|
||||||
cmd.useblock.desc=Place a block or open chest
|
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
|
# Useitem
|
||||||
cmd.useitem.desc=Use (left click) an item on the hand
|
cmd.useitem.desc=Use (left click) an item on the hand
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue