34 constexpr std::array variable_names = {
40 blackboard.
Trace(variable_names[0], msg);
47 constexpr std::array variable_names = {
54 const std::string& msg = blackboard.
Get<std::string>(variable_names[0]);
62 std::shared_ptr<LocalPlayer> local_player = client.
GetLocalPlayer();
64 if (local_player ==
nullptr)
72#if PROTOCOL_VERSION < 766
73 constexpr double range = 4.5;
75 const double range = local_player->GetAttributePlayerBlockInteractionRangeValue();
87 std::shared_ptr<ProtocolCraft::ServerboundUseItemOnPacket> place_block_packet = std::make_shared<ProtocolCraft::ServerboundUseItemOnPacket>();
89 place_block_packet->SetDirection(
static_cast<int>(face));
93 place_block_packet->SetCursorPositionX(0.5f);
94 place_block_packet->SetCursorPositionY(0.0f);
95 place_block_packet->SetCursorPositionZ(0.5f);
98 place_block_packet->SetCursorPositionX(0.5f);
99 place_block_packet->SetCursorPositionY(1.0f);
100 place_block_packet->SetCursorPositionZ(0.5f);
103 place_block_packet->SetCursorPositionX(0.5f);
104 place_block_packet->SetCursorPositionY(0.5f);
105 place_block_packet->SetCursorPositionZ(0.0f);
108 place_block_packet->SetCursorPositionX(0.5f);
109 place_block_packet->SetCursorPositionY(0.5f);
110 place_block_packet->SetCursorPositionZ(1.0f);
113 place_block_packet->SetCursorPositionX(1.0f);
114 place_block_packet->SetCursorPositionY(0.5f);
115 place_block_packet->SetCursorPositionZ(0.5f);
118 place_block_packet->SetCursorPositionX(0.0f);
119 place_block_packet->SetCursorPositionY(0.5f);
120 place_block_packet->SetCursorPositionZ(0.5f);
125#if PROTOCOL_VERSION > 452
126 place_block_packet->SetInside(
false);
128 place_block_packet->SetHand(
static_cast<int>(
Hand::Right));
129#if PROTOCOL_VERSION > 758
130 place_block_packet->SetSequence(client.
GetWorld()->GetNextWorldInteractionSequenceId());
134#if PROTOCOL_VERSION < 777
137 std::shared_ptr<ProtocolCraft::ServerboundSwingPacket> animation_packet = std::make_shared<ProtocolCraft::ServerboundSwingPacket>();
138 animation_packet->SetHand(
static_cast<int>(
Hand::Right));
150 constexpr std::array variable_names = {
151 "InteractWithBlock.pos",
152 "InteractWithBlock.face",
153 "InteractWithBlock.animation"
158 blackboard.
Trace(variable_names[0], pos);
159 blackboard.
Trace(variable_names[1], face);
160 blackboard.
Trace(variable_names[2], animation);
167 constexpr std::array variable_names = {
168 "InteractWithBlock.pos",
169 "InteractWithBlock.face",
170 "InteractWithBlock.animation"
180 const bool animation = blackboard.
Get(variable_names[2],
true);
193 constexpr std::array variable_names = {
194 "CheckBlackboardBoolData.key"
199 blackboard.
Trace(variable_names[0], key);
206 constexpr std::array variable_names = {
207 "CheckBlackboardBoolData.key"
213 const std::string& key = blackboard.
Get<std::string>(variable_names[0]);
228 constexpr std::array variable_names = {
229 "RemoveBlackboardData.key"
234 blackboard.
Trace(variable_names[0], key);
241 constexpr std::array variable_names = {
242 "RemoveBlackboardData.key"
248 const std::string& key = blackboard.
Get<std::string>(variable_names[0]);
261 constexpr std::array variable_names = {
267 blackboard.
Trace(variable_names[0], threshold);
274 constexpr std::array variable_names = {
281 const int threshold = blackboard.
Get<
int>(variable_names[0], 20);
296 constexpr std::array variable_names = {
297 "CopyBlackboardData.src",
298 "CopyBlackboardData.dst"
303 blackboard.
Trace(variable_names[0], src);
304 blackboard.
Trace(variable_names[1], dst);
311 constexpr std::array variable_names = {
312 "CopyBlackboardData.src",
313 "CopyBlackboardData.dst"
319 const std::string& src = blackboard.
Get<std::string>(variable_names[0]);
320 const std::string& dst = blackboard.
Get<std::string>(variable_names[1]);
A ManagersClient extended with a blackboard that can store any kind of data and a virtual Yield funct...
Blackboard & GetBlackboard()
A map wrapper to store arbitrary data.
void Erase(const std::string &key)
Remove a map entry if present.
void Copy(const std::string &src, const std::string &dst)
Copy a blackboard value.
const T & Get(const std::string &key)
Get the map value at key, casting it to T.
void Trace(const std::string &key, const std::any &value, const bool add_trace_prefix=true) const
Notify observers of a value without storing it (debug view only)
std::shared_ptr< NetworkManager > GetNetworkManager() const
void SendChatMessage(const std::string &msg)
Send a message in the game chat.
void SetShouldBeClosed(const bool b)
std::shared_ptr< LocalPlayer > GetLocalPlayer() const
int GetDayTime() const
Get the current tick.
std::shared_ptr< World > GetWorld() const
Status IsHungryBlackboard(BehaviourClient &client)
Same thing as IsHungry, but reads its parameters from the blackboard.
Status RemoveBlackboardDataBlackboard(BehaviourClient &client)
Same thing as RemoveBlackboardData, but reads its parameters from the blackboard.
Status SayBlackboard(BehaviourClient &client)
Same thing as Say, but reads its parameters from the blackboard.
Status RemoveBlackboardDataImpl(BehaviourClient &client, const std::string &key)
Status GoTo(BehaviourClient &client, const Position &goal, const int dist_tolerance=0, const int min_end_dist=0, const int min_end_dist_xz=0, const bool allow_jump=true, const bool sprint=true, const float speed_factor=1.0f)
Find a path to a block position and navigate to it.
Status InteractWithBlockImpl(BehaviourClient &client, const Position &pos, const PlayerDiggingFace face, const bool animation)
Status CopyBlackboardData(BehaviourClient &client, const std::string &src, const std::string &dst)
Copy a blackboard data.
Status SayImpl(BehaviourClient &client, const std::string &msg)
Status IsHungry(BehaviourClient &client, const int threshold=20)
Return success if player food is below a threshold.
Status Disconnect(BehaviourClient &client)
Ask this client to disconnect from the server by setting should_be_closed to true.
Status CopyBlackboardDataBlackboard(BehaviourClient &client)
Same thing as CopyBlackboardData, but reads its parameters from the blackboard.
Status Yield(BehaviourClient &client)
Just call client.Yield().
Status Say(BehaviourClient &client, const std::string &msg)
Send a message in the game chat.
Status CheckBlackboardBoolDataBlackboard(BehaviourClient &client)
Same thing as CheckBlackboardBoolData, but reads its parameters from the blackboard.
Status LookAt(BehaviourClient &client, const Vector3< double > &target, const bool set_pitch=true, const bool sync_to_server=true)
Turn the camera to look at a given target and send the new rotation to the server.
Status InteractWithBlock(BehaviourClient &client, const Position &pos, const PlayerDiggingFace face=PlayerDiggingFace::Up, const bool animation=true)
Interact (right click) with the block at the given location.
Status IsHungryImpl(BehaviourClient &client, const int threshold)
Status IsNightTime(BehaviourClient &client)
Return Success if it's night time (sleep is possible)
Status InteractWithBlockBlackboard(BehaviourClient &client)
Same thing as InteractWithBlock, but reads its parameters from the blackboard.
Status CheckBlackboardBoolDataImpl(BehaviourClient &client, const std::string &key)
Status CopyBlackboardDataImpl(BehaviourClient &client, const std::string &src, const std::string &dst)
Status CheckBlackboardBoolData(BehaviourClient &client, const std::string &key)
Check in the blackboard if the bool at key is true.
Status RemoveBlackboardData(BehaviourClient &client, const std::string &key)
Remove a value from the blackboard if exist.
Status IsAlive(BehaviourClient &client)
Return success if player is alive.
double SqrDist(const Vector3 &v) const
ProtocolCraft::NetworkPosition ToNetworkPosition() const