Comment on page
Player
Methods | Properties |
GetUuid | State |
GetUsername | Manager |
GetPosition | PhysicsEngine |
GetLocation | Crafting |
GetRotation | Controls |
GetHealth | |
GetFood | |
GetFoodSaturation | |
GetEntityId | |
GetHeldSlot | |
GetHeldIndex | |
IsDead | |
GetExperienceLevel | |
GetExperience | |
GetEffects | |
HasEffect | |
SetCrouchState | |
IsCrouching | |
Chat | |
Respawn | |
SwapItemInHands | |
UseHeld | |
Swing | |
Eat | |
SetLook | |
LookAt | |
LookAtSmooth | |
Jump | |
MoveDirection | |
MoveTo | |
MoveToRange | |
MoveToRangeCustom | |
MoveToInteactionRange | |
CreateReusablePath | |
ExecuteReusablePath | |
Disconnect | |
The state can be accessed by Context.Player.State.
The state contains information that is relevant to the current session of the bot, such as LoggedIn, Spawned, Eating, etc.
The controls can be accessed by Context.Player.Controls.
Provides high-level controls over the bot. This class allows you to use mouse and keyboard controls such as ClickMouseButton, HoldMouseButton, SpamMouseButton, KeyboardHoldForward, etc.
The crafting manager can be accessed by Context.Player.Crafting.
Provides a high-level crafting interface. This class gives you access to functions Craft(CraftingTask task), and GetMaxCrafts(CraftingTask task).
Note: comments on Github provide adequate explanations for this class.
Returns the bot's uuid. You can use https://mcuuid.net/ to convert a username to an uuid manually. The returned value is in the format of `91a546fca6fe44c99550ab2291f28760` (does not have dashes).
string GetUuid();
Returns the username of the bot.
string GetUsername();
Returns the position of the bot.
IPosition GetPosition();
Returns the Location of the bot, where the coordinates are rounded down from doubles to integers.
ILocation GetLocation();
Returns the rotation (yaw, pitch) of the bot.
IRotation GetRotation();
Returns the health of the bot.
Note: the Health is measured 0 (aka dead) up to 20 (full health), not up to 10 like Minecraft's visual indicators.
float GetHealth();
Returns the how much food the bot has.
Note: the Food is measured 0 up to 20, not up to 10 like Minecraft's visual indicators.
float GetFood();
Returns the food saturation of the bot.
float GetFoodSaturation();
Returns the bot's entity's id. This is sent over by the server to the bot and other bots may have different entity ids for this bot.
int GetEntityId();
Returns the hobar slot that the bot has currently selected. This can be null or empty.
ISlot GetHeldSlot();
Returns the index (0-8) of the hotbar slot that the bot has currently selected.
short GetHeldIndex();
Returns whether the bot is dead.
bool IsDead();
Returns the bot's experience level.
int GetExperienceLevel();
Returns the total experience points of the bot.
int GetExperience();
Returns the IEffectContainer of the bot, which can be used to determine the bot's status effects (e.g.: poisoned, regeneration, strength), their duration, and their level.
IEffectContainer GetEffects()
Returns whether the bot has the specified effect.
bool HasEffect(Effects effect)
Sets the crouching state of the bot to the specified mode (Couch, Uncrouched).
Task SetCrouchState(CrouchStates mode);
Returns whether the bot is crouching.
bool IsCrouching();
Sends a chat message to the server. Server commands are also sent from this, however they have
/
appended to the beginning of the message.
Note: protocols up to 1.11 have a character limit of 100 characters per message, where as 1.11 and later protocols can have messages with up to 256 characters.void Chat(string message);
Attempts to respawn the bot. The task that this function returns is completed once a world reload is done.
Task Respawn();
Swaps the item that the player is currently holding in it's primary hand to it's off-hand and vice-versa.
Note: this only works on 1.9+.
Task SwapItemInHands();
Right clicks the currently held item.
Task UseHeld();
Performs the (left) arm swing animation. This is only the animation and will not hit any mobs or blocks.
Task Swing();
Attempts to "eat" (hold right click) on the selected item. This does not check whether the player is currently holding food, that is up to the developer to do!
Task<bool> Eat();
Sets the bot's rotation to the specified value. You can optionally await for this function as the server can take a bit to update the change. The await value is always 1 tick and is here only for the convenience.
Task SetLook(IRotation rotation);
Task SetLook(Directions direction);
Sets the bot's rotation to look at the specified position. You can optionally await for this function as the server can take a bit to update the change. The await value is always 1 tick and is here only for the convenience.
Task LookAt(IPosition position);
Task LookAt(ILocation location);
Smoothly (slowly, per multiple ticks) sets the bot's rotation to look at the specified position. You should await for this function to complete, as the rotation time is dynamic. You can optionally specify the look speed, however it is recommended to leave it as 'auto'.
Task LookAtSmooth(IPosition position, LookSpeed speed = LookSpeed.auto);
Task LookAtSmooth(ILocation location, LookSpeed speed = LookSpeed.auto);
The bot attempts to jump up. This will not move the bot horizontally, only vertically.
void Jump();
Attempts to move the player in the specified direction.
You can optionally specify the MapOptions, which control what the bot can and cannot do while pathing (e.g.: can't build, can't walk on sand).
Returns IMoveTask, which has functions to affect the current path, such as
SetNewTarget()
and Stop()
. IMoveTask also contains the task that will be marked completed once the path is completed/cancelled. The task can be awaited by doing await IMoveTask.Task
and returns a MoveResult, which contains the path that was used (MoveResult.Path) and the outcome (MoveResult.Result).
Note: Path can be used by re-used withcontext.player.ExecuteReusablePath
.MoveDirection(Direction direction, MapOptions options = null);
Attempts to move the player to the specified location.
You can optionally specify the MapOptions, which control what the bot can and cannot do while pathing (e.g.: can't build, can't walk on sand).
Returns IMoveTask, which has functions to affect the current path, such as
SetNewTarget()
and Stop()
. IMoveTask also contains the task that will be marked completed once the path is completed/cancelled. The task can be awaited by doing await IMoveTask.Task
and returns a MoveResult, which contains the path that was used (MoveResult.Path) and the outcome (MoveResult.Result).
Note: Path can be used by re-used withcontext.player.ExecuteReusablePath
.IMoveTask MoveTo(ILocation location, MapOptions options = null);
IMoveTask MoveTo(IPosition position, MapOptions options = null);
IMoveTask MoveTo(int x, int y, int z, MapOptions options = null);
/*
* E.g. of pathing and waiting for it to finish
*/
public async Task OnTick() {
var moveResult = await Context.Player.MoveTo(new Location(100, 40, 100)).Task;
if(moveResult.Result == MoveResultType.Completed)
Console.WriteLine("Moved to 100/40/100");
else
Console.WriteLine("Failed to move to 100/40/100, path was "
+ moveResult.Result);
}
Attempts to move the player in range to the specified (within the specified range) or to the specified location it self. The range is circular, that means that the total distance to the block must be within the specified radius.
You can optionally specify the MapOptions, which control what the bot can and cannot do while pathing (e.g.: can't build, can't walk on sand).
Returns IMoveTask, which has functions to affect the current path, such as
SetNewTarget()
and Stop()
. IMoveTask also contains the task that will be marked completed once the path is completed/cancelled. The task can be awaited by doing await IMoveTask.Task
and returns a MoveResult, which contains the path that was used (MoveResult.Path) and the outcome (MoveResult.Result).
Note: Path can be used by re-used withcontext.player.ExecuteReusablePath
.IMoveTask MoveToRange(ILocation location, int range, MapOptions options = null);
IMoveTask MoveToRange(IPosition position, int range, MapOptions options = null);
IMoveTask MoveToRange(int x, int y, int z, int range, MapOptions options = null);
Attempts to move the player onto a block that is within a specified range of the location and canBlockBePicked returns true for the selected block. This allows developers to customize the block that the bot will pick to stand on.
You can optionally specify the MapOptions, which control what the bot can and cannot do while pathing (e.g.: can't build, can't walk on sand).
Returns IMoveTask, which has functions to affect the current path, such as
SetNewTarget()
and Stop()
. IMoveTask also contains the task that will be marked completed once the path is completed/cancelled. The task can be awaited by doing await IMoveTask.Task
and returns a MoveResult, which contains the path that was used (MoveResult.Path) and the outcome (MoveResult.Result).
Note: Path can be used by re-used withcontext.player.ExecuteReusablePath
.IMoveTask MoveToRangeCustom(ILocation location, int range, Func<IBlock, bool> canBlockBePicked, MapOptions options = null);
IMoveTask MoveToRangeCustom(IPosition position, int range, Func<IBlock, bool> canBlockBePicked, MapOptions options = null);
IMoveTask MoveToRangeCustom(int x, int y, int z, int range, Func<IBlock, bool> canBlockBePicked, MapOptions options = null);
Attempts to move the player onto a block that the specified location can be reached from and seen from. This means that this takes both the interaction range of the player (~4.5 blocks) and the visibility into account when looking for a block.
You can optionally specify the MapOptions, which control what the bot can and cannot do while pathing (e.g.: can't build, can't walk on sand).
Returns IMoveTask, which has functions to affect the current path, such as
SetNewTarget()
and Stop()
. IMoveTask also contains the task that will be marked completed once the path is completed/cancelled. The task can be awaited by doing await IMoveTask.Task
and returns a MoveResult, which contains the path that was used (MoveResult.Path) and the outcome (MoveResult.Result).
Note: Path can be used by re-used withcontext.player.ExecuteReusablePath
.IMoveTask MoveToInteractionRange(ILocation location, MapOptions options = null);
IMoveTask MoveToInteractionRange(IPosition position, MapOptions options = null);
IMoveTask MoveToInteractionRange(int x, int y, int z, MapOptions options = null);
Makes the bot follow the specified entity. You can optionally specify the maxRange and the minRange that the bot must keep to the player. If no maxRange is specified then 1 is used, meaning the bot will path to the same position as the player is in.
Returns IMoveTask, which has functions to affect the current path, such as
SetNewTarget()
and Stop()
. IMoveTask also contains the task that will be marked completed once the path is completed/cancelled. The task can be awaited by doing await IMoveTask.Task
and returns a MoveResult, the outcome of the path (MoveResult.Result).
The IMoveTask.Task is marked as completed when either the player is reached or the player dies/moves out of ranges or when a new path is specified. Therefore for constant following you should place this on a loop where if the path is done then you re-queue another follow call.IMoveTask FollowEntity(IEntity entity, MapOptions options = null);
IMoveTask FollowEntity(IEntity entity, int maxRange, MapOptions options = null);
IMoveTask FollowEntity(IEntity entity, int maxRange, int minRange, MapOptions options = null);
Performs a path lookup and stores it into a reusable variable, which can be used later. The result of this function can be used with ExecuteReusablePath to actually perform that movement of the path.
Note: When reusing paths, the bots must start at the same location the path was created at.
Task<ICachedPath> CreateReusablePath(IPosition start, IPosition end, MapOptions options = null);
Task<ICachedPath> CreateReusablePath(ILocation start, ILocation end, MapOptions options = null);
The bot must be standing in the same location that the path originates from otherwise the bot may not path as expected.
Attempts to re-use a path that has been calculated beforehand.
Returns IMoveTask, which has functions to affect the current path, such as
SetNewTarget()
and Stop()
. IMoveTask also contains the task that will be marked completed once the path is completed/cancelled. The task can be awaited by doing await IMoveTask.Task
and returns a MoveResult, which contains the path that was used (MoveResult.Path) and the outcome (MoveResult.Result).IMoveTask ExecuteReusablePath(ICachedPath path);
Disconnects the bot from the server. You can optionally specify the disconnect message, which will be shown in the accounts tab.
void Disconnect(string message = null);
Last modified 4yr ago