-
Notifications
You must be signed in to change notification settings - Fork 46
Clients
Different functionalities in Botcraft are implemented through a hierarchy of Client classes. Depending on your needs and what you want to achieve, you'll need to use one of them (either directly or by inheriting it). This page explains what each class does.
Note that for any client in this hierarchy, you only need to override the Handle(ProtocolCraft::PacketName)
function to automatically react to incoming PacketName
packets. However, if this Handle was already implemented in a parent, don't forget to call Parent::Handle
at the top of your own Handle
to avoid overriding library code with your own. For example, the Handle(ClientboundLoginDisconnectPacket& msg)
function on a custom class derived from ConnectionClient
would be:
void MyClient::Handle(ClientboundLoginDisconnectPacket &msg)
{
ConnectionClient::Handle(msg);
// My code here
}
ConnectionClient
is the most basic class. Its role is to keep the connection with the server. It only reacts to packets required to maintain this connection, and can't do much more by itself (it can send chat messages though). However, it is very lightweight for both the RAM and CPU, as it doesn't load the game assets, store chunks data or process any physics. Ideal for an AFK only client.
It also contains a should_be_closed
boolean that can be checked to see if this client should be closed (if the server closed the connection for example).
ManagersClient
extends the previous one by having all the minecraft environment data available through multiple managers: chunks, blocks, entities, inventory... It also runs the client-side physics to keep the player on the ground and preventing it to enter solid blocks. Ideal if you want to get some world data without needing all the behaviour stuff of the other clients.
This is the base abstract class for the botcraft behaviour system (you can check the detailed wiki page about that). It contains a Blackboard
element, that can be used to store arbitrary data. You should not inherit or use this class directly.
Derived from the abstract class, it handles all the behaviour tree running mecanism. It uses the Curiously Recurring Template Pattern to ensure behaviour trees built for derived classes can also be used properly.
You should use this class if you want to use the behaviour tree system AND the leaves of your tree should access fields in your derived class (ChatCommandExample illustrates how to inherit in this case). If the blackboard is sufficient for you, the SimpleBehaviourClient
should be used instead.
Doesn't have anything specific. Just a specialization of TemplatedBehaviourClient
that you can use as template argument for your behaviour trees. You can also inherit from this class if you need new Handle
functions.