mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Upgrade GetLookingBlock
This commit is contained in:
parent
ba6a954f45
commit
4aa6c1c99f
11 changed files with 213 additions and 74 deletions
|
|
@ -17,28 +17,41 @@ namespace MinecraftClient.Commands
|
|||
if (!handler.GetTerrainEnabled())
|
||||
return Translations.Get("extra.terrainandmovement_required");
|
||||
|
||||
if (hasArg(command))
|
||||
string[] args = getArgs(command);
|
||||
if (args.Length == 0)
|
||||
{
|
||||
string[] args = getArgs(command);
|
||||
if (args.Length == 3)
|
||||
{
|
||||
try
|
||||
{
|
||||
Location current = handler.GetCurrentLocation();
|
||||
Location blockToBreak = Location.Parse(current, args[0], args[1], args[2]);
|
||||
if (blockToBreak.DistanceSquared(current.EyesLocation()) > 25)
|
||||
return Translations.Get("cmd.dig.too_far");
|
||||
if (handler.GetWorld().GetBlock(blockToBreak).Type == Material.Air)
|
||||
return Translations.Get("cmd.dig.no_block");
|
||||
if (handler.DigBlock(blockToBreak))
|
||||
return Translations.Get("cmd.dig.dig", blockToBreak.X, blockToBreak.Y, blockToBreak.Z);
|
||||
else return "cmd.dig.fail";
|
||||
}
|
||||
catch (FormatException) { return GetCmdDescTranslated(); }
|
||||
}
|
||||
else return GetCmdDescTranslated();
|
||||
(bool hasBlock, Location blockLoc, Block block) = RaycastHelper.RaycastBlock(handler, 4.5, false);
|
||||
if (!hasBlock)
|
||||
return Translations.Get("cmd.dig.too_far");
|
||||
else if (block.Type == Material.Air)
|
||||
return Translations.Get("cmd.dig.no_block");
|
||||
else if (handler.DigBlock(blockLoc, lookAtBlock: false))
|
||||
return Translations.Get("cmd.dig.dig", blockLoc.X, blockLoc.Y, blockLoc.Z, block.Type);
|
||||
else
|
||||
return Translations.Get("cmd.dig.fail");
|
||||
}
|
||||
else if (args.Length == 3)
|
||||
{
|
||||
try
|
||||
{
|
||||
Location current = handler.GetCurrentLocation();
|
||||
Location blockToBreak = Location.Parse(current, args[0], args[1], args[2]);
|
||||
if (blockToBreak.DistanceSquared(current.EyesLocation()) > 25)
|
||||
return Translations.Get("cmd.dig.too_far");
|
||||
Block block = handler.GetWorld().GetBlock(blockToBreak);
|
||||
if (block.Type == Material.Air)
|
||||
return Translations.Get("cmd.dig.no_block");
|
||||
else if (handler.DigBlock(blockToBreak))
|
||||
return Translations.Get("cmd.dig.dig", blockToBreak.X, blockToBreak.Y, blockToBreak.Z, block.Type);
|
||||
else
|
||||
return Translations.Get("cmd.dig.fail");
|
||||
}
|
||||
catch (FormatException) { return GetCmdDescTranslated(); }
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetCmdDescTranslated();
|
||||
}
|
||||
else return GetCmdDescTranslated();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue