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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using MinecraftClient.Mapping;
|
||||
|
||||
|
|
@ -17,7 +18,20 @@ namespace MinecraftClient.Commands
|
|||
if (handler.GetTerrainEnabled())
|
||||
{
|
||||
string[] args = getArgs(command);
|
||||
if (args.Length == 1)
|
||||
if (args.Length == 0)
|
||||
{
|
||||
const double maxDistance = 8.0;
|
||||
(bool hasBlock, Location target, Block block) = RaycastHelper.RaycastBlock(handler, maxDistance, false);
|
||||
if (!hasBlock)
|
||||
return Translations.Get("cmd.look.noinspection", maxDistance);
|
||||
else
|
||||
{
|
||||
Location current = handler.GetCurrentLocation(), target_center = target.ToCenter();
|
||||
return Translations.Get("cmd.look.inspection", block.Type, target.X, target.Y, target.Z,
|
||||
current.Distance(target_center), current.EyesLocation().Distance(target_center));
|
||||
}
|
||||
}
|
||||
else if (args.Length == 1)
|
||||
{
|
||||
string dirStr = getArg(command).Trim().ToLower();
|
||||
Direction direction;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue