Skip to content

Commit

Permalink
Added Slab handling
Browse files Browse the repository at this point in the history
Added Slab handling
  • Loading branch information
milutinke authored May 20, 2023
2 parents 4ff7712 + 64eb48f commit a4fb677
Show file tree
Hide file tree
Showing 5 changed files with 683 additions and 239 deletions.
38 changes: 16 additions & 22 deletions MinecraftClient/Commands/Sneak.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ namespace MinecraftClient.Commands
{
public class Sneak : Command
{
private bool sneaking = false;
public override string CmdName { get { return "sneak"; } }
public override string CmdUsage { get { return "sneak"; } }
public override string CmdDesc { get { return Translations.cmd_sneak_desc; } }
public override string CmdName => "sneak";
public override string CmdUsage => "sneak";
public override string CmdDesc => Translations.cmd_sneak_desc;

public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
{
Expand Down Expand Up @@ -39,27 +38,22 @@ private int GetUsage(CmdResult r, string? cmd)

private int DoSneak(CmdResult r)
{
McClient handler = CmdResult.currentHandler!;
if (sneaking)
{
var result = handler.SendEntityAction(Protocol.EntityActionType.StopSneaking);
if (result)
sneaking = false;
if (result)
return r.SetAndReturn(CmdResult.Status.Done, Translations.cmd_sneak_off);
else
return r.SetAndReturn(CmdResult.Status.Fail);
}
else
var handler = CmdResult.currentHandler!;

if (handler.IsSneaking)
{
var result = handler.SendEntityAction(Protocol.EntityActionType.StartSneaking);
if (result)
sneaking = true;
if (result)
return r.SetAndReturn(CmdResult.Status.Done, Translations.cmd_sneak_on);
else
if (!handler.SendEntityAction(Protocol.EntityActionType.StopSneaking))
return r.SetAndReturn(CmdResult.Status.Fail);

handler.IsSneaking = false;
return r.SetAndReturn(CmdResult.Status.Done, Translations.cmd_sneak_off);
}

if (!handler.SendEntityAction(Protocol.EntityActionType.StartSneaking))
return r.SetAndReturn(CmdResult.Status.Fail);

handler.IsSneaking = true;
return r.SetAndReturn(CmdResult.Status.Done, Translations.cmd_sneak_on);
}
}
}
Loading

0 comments on commit a4fb677

Please sign in to comment.