mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
Allow bots to perform small teleports (#1067)
Small teleport jumps within a 4-block ranges. May cause invalid moves and/or trigger anti-cheat plugins.
This commit is contained in:
parent
ab05d697ef
commit
ee8bc7f308
2 changed files with 23 additions and 10 deletions
|
|
@ -730,7 +730,7 @@ namespace MinecraftClient
|
|||
/// </summary>
|
||||
protected void SetSlot(int slotNum)
|
||||
{
|
||||
Handler.ChangeSlot((short) slotNum);
|
||||
Handler.ChangeSlot((short)slotNum);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -757,11 +757,12 @@ namespace MinecraftClient
|
|||
/// Move to the specified location
|
||||
/// </summary>
|
||||
/// <param name="location">Location to reach</param>
|
||||
/// <param name="allowUnsafe">Allow possible but unsafe locations</param>
|
||||
/// <param name="allowUnsafe">Allow possible but unsafe locations thay may hurt the player: lava, cactus...</param>
|
||||
/// <param name="allowSmallTeleport">Allow non-vanilla small teleport instead of computing path, but may cause invalid moves and/or trigger anti-cheat plugins</param>
|
||||
/// <returns>True if a path has been found</returns>
|
||||
protected bool MoveToLocation(Mapping.Location location, bool allowUnsafe = false)
|
||||
protected bool MoveToLocation(Mapping.Location location, bool allowUnsafe = false, bool allowSmallTeleport = false)
|
||||
{
|
||||
return Handler.MoveTo(location, allowUnsafe);
|
||||
return Handler.MoveTo(location, allowUnsafe, allowSmallTeleport);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -788,18 +788,30 @@ namespace MinecraftClient
|
|||
/// Move to the specified location
|
||||
/// </summary>
|
||||
/// <param name="location">Location to reach</param>
|
||||
/// <param name="allowUnsafe">Allow possible but unsafe locations</param>
|
||||
/// <param name="allowUnsafe">Allow possible but unsafe locations thay may hurt the player: lava, cactus...</param>
|
||||
/// <param name="allowSmallTeleport">Allow non-vanilla small teleport instead of computing path, but may cause invalid moves and/or trigger anti-cheat plugins</param>
|
||||
/// <returns>True if a path has been found</returns>
|
||||
public bool MoveTo(Location location, bool allowUnsafe = false)
|
||||
public bool MoveTo(Location location, bool allowUnsafe = false, bool allowSmallTeleport = false)
|
||||
{
|
||||
lock (locationLock)
|
||||
{
|
||||
if (allowSmallTeleport && location.DistanceSquared(this.location) <= 16)
|
||||
{
|
||||
// Allow small teleport within a range of 4 blocks. 1-step path to the desired location without checking anything
|
||||
path = null;
|
||||
steps = new Queue<Location>(new[] { location });
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Calculate path through pathfinding. Path contains a list of 1-block movement that will be divided into steps
|
||||
if (Movement.GetAvailableMoves(world, this.location, allowUnsafe).Contains(location))
|
||||
path = new Queue<Location>(new[] { location });
|
||||
else path = Movement.CalculatePath(world, this.location, location, allowUnsafe);
|
||||
return path != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Received some text from the server
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue