mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Bug fix
This commit is contained in:
parent
127978615c
commit
94a3c92b36
62 changed files with 371 additions and 297 deletions
|
|
@ -13,7 +13,7 @@ namespace MinecraftClient.Commands
|
|||
public override string CmdUsage { get { return "blockinfo <x> <y> <z> [-s]"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_blockinfo_desc; } }
|
||||
|
||||
public override void RegisterCommand(McClient handler, CommandDispatcher<CmdResult> dispatcher)
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
{
|
||||
dispatcher.Register(l => l.Literal("help")
|
||||
.Then(l => l.Literal(CmdName)
|
||||
|
|
@ -24,13 +24,13 @@ namespace MinecraftClient.Commands
|
|||
);
|
||||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Executes(r => LogBlockInfo(r.Source, handler, handler.GetCurrentLocation(), false))
|
||||
.Executes(r => LogBlockInfo(r.Source, null, false))
|
||||
.Then(l => l.Literal("-s")
|
||||
.Executes(r => LogBlockInfo(r.Source, handler, handler.GetCurrentLocation(), true)))
|
||||
.Executes(r => LogBlockInfo(r.Source, null, true)))
|
||||
.Then(l => l.Argument("Location", MccArguments.Location())
|
||||
.Executes(r => LogBlockInfo(r.Source, handler, MccArguments.GetLocation(r, "Location"), false))
|
||||
.Executes(r => LogBlockInfo(r.Source, MccArguments.GetLocation(r, "Location"), false))
|
||||
.Then(l => l.Literal("-s")
|
||||
.Executes(r => LogBlockInfo(r.Source, handler, MccArguments.GetLocation(r, "Location"), true))))
|
||||
.Executes(r => LogBlockInfo(r.Source, MccArguments.GetLocation(r, "Location"), true))))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
);
|
||||
|
|
@ -47,13 +47,18 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private static int LogBlockInfo(CmdResult r, McClient handler, Location targetBlock, bool reportSurrounding)
|
||||
private static int LogBlockInfo(CmdResult r, Location? targetBlock, bool reportSurrounding)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetTerrainEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedTerrain);
|
||||
|
||||
targetBlock.ToAbsolute(handler.GetCurrentLocation());
|
||||
Block block = handler.GetWorld().GetBlock(targetBlock);
|
||||
if (targetBlock.HasValue)
|
||||
targetBlock.Value.ToAbsolute(handler.GetCurrentLocation());
|
||||
else
|
||||
targetBlock = handler.GetCurrentLocation();
|
||||
|
||||
Block block = handler.GetWorld().GetBlock(targetBlock.Value);
|
||||
|
||||
handler.Log.Info($"{Translations.cmd_blockinfo_BlockType}: {block.GetTypeString()}");
|
||||
if (reportSurrounding)
|
||||
|
|
@ -61,12 +66,13 @@ namespace MinecraftClient.Commands
|
|||
StringBuilder sb = new();
|
||||
sb.AppendLine($"{Translations.cmd_blockinfo_BlocksAround}:");
|
||||
|
||||
Block blockXPositive = handler.GetWorld().GetBlock(new Location(targetBlock.X + 1, targetBlock.Y, targetBlock.Z));
|
||||
Block blockXNegative = handler.GetWorld().GetBlock(new Location(targetBlock.X - 1, targetBlock.Y, targetBlock.Z));
|
||||
Block blockYPositive = handler.GetWorld().GetBlock(new Location(targetBlock.X, targetBlock.Y + 1, targetBlock.Z));
|
||||
Block blockYNegative = handler.GetWorld().GetBlock(new Location(targetBlock.X, targetBlock.Y - 1, targetBlock.Z));
|
||||
Block blockZPositive = handler.GetWorld().GetBlock(new Location(targetBlock.X, targetBlock.Y, targetBlock.Z + 1));
|
||||
Block blockZNegative = handler.GetWorld().GetBlock(new Location(targetBlock.X, targetBlock.Y, targetBlock.Z - 1));
|
||||
double X = targetBlock.Value.X, Y = targetBlock.Value.Y, Z = targetBlock.Value.Z;
|
||||
Block blockXPositive = handler.GetWorld().GetBlock(new Location(X + 1, Y, Z));
|
||||
Block blockXNegative = handler.GetWorld().GetBlock(new Location(X - 1, Y, Z));
|
||||
Block blockYPositive = handler.GetWorld().GetBlock(new Location(X, Y + 1, Z));
|
||||
Block blockYNegative = handler.GetWorld().GetBlock(new Location(X, Y - 1, Z));
|
||||
Block blockZPositive = handler.GetWorld().GetBlock(new Location(X, Y, Z + 1));
|
||||
Block blockZNegative = handler.GetWorld().GetBlock(new Location(X, Y, Z - 1));
|
||||
|
||||
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()}");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue