From d4129e04bba583d1c9fe84d1c5f0ef5a8baad5d2 Mon Sep 17 00:00:00 2001 From: Milutinke Date: Sun, 16 Oct 2022 13:33:04 +0200 Subject: [PATCH 1/2] Implemented block reporting as requested in #1762 --- MinecraftClient/Commands/BlockInfo.cs | 57 +++++++++++++++++++++++++++ MinecraftClient/Resources/lang/en.ini | 3 ++ 2 files changed, 60 insertions(+) create mode 100644 MinecraftClient/Commands/BlockInfo.cs diff --git a/MinecraftClient/Commands/BlockInfo.cs b/MinecraftClient/Commands/BlockInfo.cs new file mode 100644 index 00000000..41c01376 --- /dev/null +++ b/MinecraftClient/Commands/BlockInfo.cs @@ -0,0 +1,57 @@ +using System.Collections.Generic; +using System.Text; +using MinecraftClient.Mapping; + +namespace MinecraftClient.Commands +{ + public class BlockInfo : Command + { + public override string CmdName { get { return "blockinfo"; } } + public override string CmdUsage { get { return "blockinfo [-s]"; } } + public override string CmdDesc { get { return "cmd.blockinfo.desc"; } } + + public override string Run(McClient handler, string command, Dictionary localVars) + { + 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); + + handler.Log.Info("Block Type: " + block.Type); + + if (reportSurrounding) + { + StringBuilder sb = new(); + sb.AppendLine("Blocks around:"); + + 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)); + + sb.AppendLine("\t[X Positive] Block Type: " + blockXPositive.Type); + sb.AppendLine("\t[X Negative] Block Type: " + blockXNegative.Type); + sb.AppendLine(" "); + sb.AppendLine("\t[Y Positive] Block Type: " + blockYPositive.Type); + sb.AppendLine("\t[Y Negative] Block Type: " + blockYNegative.Type); + sb.AppendLine(" "); + sb.AppendLine("\t[Z Positive] Block Type: " + blockZPositive.Type); + sb.AppendLine("\t[Z Negative] Block Type: " + blockZNegative.Type); + + handler.Log.Info(sb.ToString()); + } + + + return ""; + } + } +} diff --git a/MinecraftClient/Resources/lang/en.ini b/MinecraftClient/Resources/lang/en.ini index de64ae86..f9f198e7 100644 --- a/MinecraftClient/Resources/lang/en.ini +++ b/MinecraftClient/Resources/lang/en.ini @@ -418,6 +418,9 @@ cmd.bed.cant_reach_safely=Can not reach the bed safely! cmd.bed.moving=Moving to (X: {0:0.0}, Y: {1:0.0}, Z: {2:0.0}) where the bed is located. cmd.bed.failed_to_reach_in_time=Failed to reach the bed position (X: {0:0.0}, Y: {1:0.0}, Z: {2:0.0}) in time (30 seconds). Giving up! +# Block info +cmd.blockinfo.desc=Reports the type of the block on the provided coordinates. (Use -s to report blocks around the target block). + # List cmd.list.desc=get the player list. cmd.list.players=PlayerList: {0} From df410a9c8e7c73512263155844a14fdd0a083425 Mon Sep 17 00:00:00 2001 From: Milutinke Date: Sun, 16 Oct 2022 13:37:49 +0200 Subject: [PATCH 2/2] Fully transalted. --- MinecraftClient/Commands/BlockInfo.cs | 16 ++++++++-------- MinecraftClient/Resources/lang/en.ini | 4 ++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/MinecraftClient/Commands/BlockInfo.cs b/MinecraftClient/Commands/BlockInfo.cs index 41c01376..391dbe84 100644 --- a/MinecraftClient/Commands/BlockInfo.cs +++ b/MinecraftClient/Commands/BlockInfo.cs @@ -24,12 +24,12 @@ namespace MinecraftClient.Commands Block block = handler.GetWorld().GetBlock(targetBlockLocation); - handler.Log.Info("Block Type: " + block.Type); + handler.Log.Info(Translations.TryGet("cmd.blockinfo.BlockType") + ": " + block.Type); if (reportSurrounding) { StringBuilder sb = new(); - sb.AppendLine("Blocks around:"); + sb.AppendLine(Translations.TryGet("cmd.blockinfo.BlocksAround") + ":"); 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)); @@ -38,14 +38,14 @@ namespace MinecraftClient.Commands 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)); - sb.AppendLine("\t[X Positive] Block Type: " + blockXPositive.Type); - sb.AppendLine("\t[X Negative] Block Type: " + blockXNegative.Type); + sb.AppendLine("[X " + Translations.TryGet("cmd.blockinfo.Positive") + "] " + Translations.TryGet("cmd.blockinfo.BlockType") + ": " + blockXPositive.Type); + sb.AppendLine("[X " + Translations.TryGet("cmd.blockinfo.Negative") + "] " + Translations.TryGet("cmd.blockinfo.BlockType") + ": " + blockXNegative.Type); sb.AppendLine(" "); - sb.AppendLine("\t[Y Positive] Block Type: " + blockYPositive.Type); - sb.AppendLine("\t[Y Negative] Block Type: " + blockYNegative.Type); + sb.AppendLine("[Y " + Translations.TryGet("cmd.blockinfo.Positive") + "] " + Translations.TryGet("cmd.blockinfo.BlockType") + ": " + blockYPositive.Type); + sb.AppendLine("[Y " + Translations.TryGet("cmd.blockinfo.Negative") + "] " + Translations.TryGet("cmd.blockinfo.BlockType") + ": " + blockYNegative.Type); sb.AppendLine(" "); - sb.AppendLine("\t[Z Positive] Block Type: " + blockZPositive.Type); - sb.AppendLine("\t[Z Negative] Block Type: " + blockZNegative.Type); + sb.AppendLine("[Z " + Translations.TryGet("cmd.blockinfo.Positive") + "] " + Translations.TryGet("cmd.blockinfo.BlockType") + ": " + blockZPositive.Type); + sb.AppendLine("[Z " + Translations.TryGet("cmd.blockinfo.Negative") + "] " + Translations.TryGet("cmd.blockinfo.BlockType") + ": " + blockZNegative.Type); handler.Log.Info(sb.ToString()); } diff --git a/MinecraftClient/Resources/lang/en.ini b/MinecraftClient/Resources/lang/en.ini index f9f198e7..10298512 100644 --- a/MinecraftClient/Resources/lang/en.ini +++ b/MinecraftClient/Resources/lang/en.ini @@ -420,6 +420,10 @@ cmd.bed.failed_to_reach_in_time=Failed to reach the bed position (X: {0:0.0}, Y: # Block info cmd.blockinfo.desc=Reports the type of the block on the provided coordinates. (Use -s to report blocks around the target block). +cmd.blockinfo.Positive=Positive +cmd.blockinfo.Negative=Negative +cmd.blockinfo.BlockType=Block type +cmd.blockinfo.BlocksAround=Blocks around # List cmd.list.desc=get the player list.