2022-10-16 13:33:04 +02:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Text;
|
2022-10-26 08:54:54 +08:00
|
|
|
|
using Brigadier.NET;
|
2022-10-16 13:33:04 +02:00
|
|
|
|
using MinecraftClient.Mapping;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MinecraftClient.Commands
|
|
|
|
|
|
{
|
|
|
|
|
|
public class BlockInfo : Command
|
|
|
|
|
|
{
|
|
|
|
|
|
public override string CmdName { get { return "blockinfo"; } }
|
|
|
|
|
|
public override string CmdUsage { get { return "blockinfo <x> <y> <z> [-s]"; } }
|
2022-10-28 11:13:20 +08:00
|
|
|
|
public override string CmdDesc { get { return Translations.cmd_blockinfo_desc; } }
|
2022-10-16 13:33:04 +02:00
|
|
|
|
|
2022-10-26 08:54:54 +08:00
|
|
|
|
public override void RegisterCommand(McClient handler, CommandDispatcher<CommandSource> dispatcher)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-17 16:17:23 +02:00
|
|
|
|
public override string Run(McClient handler, string command, Dictionary<string, object>? localVars)
|
2022-10-16 13:33:04 +02:00
|
|
|
|
{
|
2022-10-17 15:14:55 +02:00
|
|
|
|
if (!handler.GetTerrainEnabled())
|
2022-10-28 11:13:20 +08:00
|
|
|
|
return Translations.error_terrain_not_enabled;
|
2022-10-17 15:14:55 +02:00
|
|
|
|
|
2022-10-16 13:33:04 +02:00
|
|
|
|
string[] args = GetArgs(command);
|
|
|
|
|
|
|
|
|
|
|
|
if (args.Length < 3)
|
|
|
|
|
|
return CmdUsage;
|
|
|
|
|
|
|
|
|
|
|
|
bool reportSurrounding = args.Length >= 4 && args[3].Equals("-s", System.StringComparison.OrdinalIgnoreCase);
|
|
|
|
|
|
|
|
|
|
|
|
Location current = handler.GetCurrentLocation();
|
|
|
|
|
|
Location targetBlockLocation = Location.Parse(current, args[0], args[1], args[2]);
|
|
|
|
|
|
|
|
|
|
|
|
Block block = handler.GetWorld().GetBlock(targetBlockLocation);
|
|
|
|
|
|
|
2022-10-28 11:13:20 +08:00
|
|
|
|
handler.Log.Info($"{Translations.cmd_blockinfo_BlockType}: {block.GetTypeString()}");
|
2022-10-16 13:33:04 +02:00
|
|
|
|
|
|
|
|
|
|
if (reportSurrounding)
|
|
|
|
|
|
{
|
|
|
|
|
|
StringBuilder sb = new();
|
2022-10-28 11:13:20 +08:00
|
|
|
|
sb.AppendLine($"{Translations.cmd_blockinfo_BlocksAround}:");
|
2022-10-16 13:33:04 +02:00
|
|
|
|
|
|
|
|
|
|
Block blockXPositive = handler.GetWorld().GetBlock(new Location(targetBlockLocation.X + 1, targetBlockLocation.Y, targetBlockLocation.Z));
|
|
|
|
|
|
Block blockXNegative = handler.GetWorld().GetBlock(new Location(targetBlockLocation.X - 1, targetBlockLocation.Y, targetBlockLocation.Z));
|
|
|
|
|
|
Block blockYPositive = handler.GetWorld().GetBlock(new Location(targetBlockLocation.X, targetBlockLocation.Y + 1, targetBlockLocation.Z));
|
|
|
|
|
|
Block blockYNegative = handler.GetWorld().GetBlock(new Location(targetBlockLocation.X, targetBlockLocation.Y - 1, targetBlockLocation.Z));
|
|
|
|
|
|
Block blockZPositive = handler.GetWorld().GetBlock(new Location(targetBlockLocation.X, targetBlockLocation.Y, targetBlockLocation.Z + 1));
|
|
|
|
|
|
Block blockZNegative = handler.GetWorld().GetBlock(new Location(targetBlockLocation.X, targetBlockLocation.Y, targetBlockLocation.Z - 1));
|
|
|
|
|
|
|
2022-10-28 11:13:20 +08:00
|
|
|
|
sb.AppendLine($"[X {Translations.cmd_blockinfo_Positive}] {Translations.cmd_blockinfo_BlockType}: {blockXPositive.GetTypeString()}");
|
|
|
|
|
|
sb.AppendLine($"[X {Translations.cmd_blockinfo_Negative}] {Translations.cmd_blockinfo_BlockType}: {blockXNegative.GetTypeString()}");
|
2022-10-17 16:17:23 +02:00
|
|
|
|
|
2022-10-16 13:33:04 +02:00
|
|
|
|
sb.AppendLine(" ");
|
2022-10-17 16:17:23 +02:00
|
|
|
|
|
2022-10-28 11:13:20 +08:00
|
|
|
|
sb.AppendLine($"[Y {Translations.cmd_blockinfo_Positive}] {Translations.cmd_blockinfo_BlockType}: {blockYPositive.GetTypeString()}");
|
|
|
|
|
|
sb.AppendLine($"[Y {Translations.cmd_blockinfo_Negative}] {Translations.cmd_blockinfo_BlockType}: {blockYNegative.GetTypeString()}");
|
2022-10-17 16:17:23 +02:00
|
|
|
|
|
2022-10-16 13:33:04 +02:00
|
|
|
|
sb.AppendLine(" ");
|
2022-10-17 16:17:23 +02:00
|
|
|
|
|
2022-10-28 11:13:20 +08:00
|
|
|
|
sb.AppendLine($"[Z {Translations.cmd_blockinfo_Positive}] {Translations.cmd_blockinfo_BlockType}: {blockZPositive.GetTypeString()}");
|
|
|
|
|
|
sb.AppendLine($"[Z {Translations.cmd_blockinfo_Negative}] {Translations.cmd_blockinfo_BlockType}: {blockZNegative.GetTypeString()}");
|
2022-10-16 13:33:04 +02:00
|
|
|
|
|
|
|
|
|
|
handler.Log.Info(sb.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|