mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Upgrade old coordinate parsing.
This commit is contained in:
parent
e01eab28a2
commit
cfdc035617
4 changed files with 9 additions and 18 deletions
|
|
@ -24,16 +24,14 @@ namespace MinecraftClient.Commands
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int x = int.Parse(args[0]);
|
Location current = handler.GetCurrentLocation();
|
||||||
int y = int.Parse(args[1]);
|
Location blockToBreak = Location.Parse(current, args[0], args[1], args[2]);
|
||||||
int z = int.Parse(args[2]);
|
if (blockToBreak.DistanceSquared(current.EyesLocation()) > 25)
|
||||||
Location blockToBreak = new Location(x, y, z);
|
|
||||||
if (blockToBreak.DistanceSquared(handler.GetCurrentLocation().EyesLocation()) > 25)
|
|
||||||
return Translations.Get("cmd.dig.too_far");
|
return Translations.Get("cmd.dig.too_far");
|
||||||
if (handler.GetWorld().GetBlock(blockToBreak).Type == Material.Air)
|
if (handler.GetWorld().GetBlock(blockToBreak).Type == Material.Air)
|
||||||
return Translations.Get("cmd.dig.no_block");
|
return Translations.Get("cmd.dig.no_block");
|
||||||
if (handler.DigBlock(blockToBreak))
|
if (handler.DigBlock(blockToBreak))
|
||||||
return Translations.Get("cmd.dig.dig", x, y, z);
|
return Translations.Get("cmd.dig.dig", blockToBreak.X, blockToBreak.Y, blockToBreak.Z);
|
||||||
else return "cmd.dig.fail";
|
else return "cmd.dig.fail";
|
||||||
}
|
}
|
||||||
catch (FormatException) { return GetCmdDescTranslated(); }
|
catch (FormatException) { return GetCmdDescTranslated(); }
|
||||||
|
|
|
||||||
|
|
@ -51,12 +51,9 @@ namespace MinecraftClient.Commands
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int x = int.Parse(args[0]);
|
Location current = handler.GetCurrentLocation();
|
||||||
int y = int.Parse(args[1]);
|
Location block = Location.Parse(current, args[0], args[1], args[2]);
|
||||||
int z = int.Parse(args[2]);
|
handler.UpdateLocation(current, block);
|
||||||
|
|
||||||
Location block = new Location(x, y, z);
|
|
||||||
handler.UpdateLocation(handler.GetCurrentLocation(), block);
|
|
||||||
|
|
||||||
return Translations.Get("cmd.look.block", block);
|
return Translations.Get("cmd.look.block", block);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,6 @@ namespace MinecraftClient.Commands
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Location current = handler.GetCurrentLocation(), currentCenter = current.ToCenter();
|
Location current = handler.GetCurrentLocation(), currentCenter = current.ToCenter();
|
||||||
|
|
||||||
Location goal = Location.Parse(current, args[0], args[1], args[2]);
|
Location goal = Location.Parse(current, args[0], args[1], args[2]);
|
||||||
|
|
||||||
if (!Movement.CheckChunkLoading(handler.GetWorld(), current, goal))
|
if (!Movement.CheckChunkLoading(handler.GetWorld(), current, goal))
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,8 @@ namespace MinecraftClient.Commands
|
||||||
string[] args = getArgs(command);
|
string[] args = getArgs(command);
|
||||||
if (args.Length >= 3)
|
if (args.Length >= 3)
|
||||||
{
|
{
|
||||||
Location current = handler.GetCurrentLocation();
|
Location block = Location.Parse(handler.GetCurrentLocation(), args[0], args[1], args[2]).ToFloor();
|
||||||
double x = args[0].StartsWith('~') ? current.X + (args[0].Length > 1 ? double.Parse(args[0][1..]) : 0) : double.Parse(args[0]);
|
Location blockCenter = block.ToCenter();
|
||||||
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);
|
bool res = handler.PlaceBlock(block, Direction.Down);
|
||||||
return Translations.Get("cmd.useblock.use", blockCenter.X, blockCenter.Y, blockCenter.Z, res ? "succeeded" : "failed");
|
return Translations.Get("cmd.useblock.use", blockCenter.X, blockCenter.Y, blockCenter.Z, res ? "succeeded" : "failed");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue