21 std::shared_ptr<Entity> entity = entity_manager->GetEntity(entity_id);
25 LOG_WARNING(
"Can't interact with unexisting entity: " << entity_id);
29 std::shared_ptr<LocalPlayer> local_player = entity_manager->GetLocalPlayer();
34#if PROTOCOL_VERSION < 766
35 constexpr double range = 3.0;
37 const double range = local_player->GetAttributePlayerEntityInteractionRangeValue();
40 while (position.
SqrDist(entity_position) > range * range)
47 entity_position = entity->GetPosition();
48 position = local_player->GetPosition();
51 local_player->LookAt(entity_position +
Vector3<double>(0, entity->GetHeight() / 2.0, 0),
true);
54 std::shared_ptr<ServerboundInteractPacket> msg_interact = std::make_shared<ServerboundInteractPacket>();
55 msg_interact->SetEntityId(entity_id);
56 msg_interact->SetAction(0);
57 msg_interact->SetHand(
static_cast<int>(hand));
58#if PROTOCOL_VERSION > 722
59 msg_interact->SetUsingSecondaryAction(
false);
61 network_manager->Send(msg_interact);
65 std::shared_ptr<ServerboundSwingPacket> msg_swing = std::make_shared<ServerboundSwingPacket>();
66 msg_swing->SetHand(
static_cast<int>(hand));
68 network_manager->Send(msg_swing);
76 constexpr std::array variable_names = {
77 "InteractEntity.entity_id",
78 "InteractEntity.hand",
79 "InteractEntity.swing"
84 blackboard.
Set<
int>(variable_names[0], entity_id);
85 blackboard.
Set<
Hand>(variable_names[1], hand);
86 blackboard.
Set<
bool>(variable_names[2], swing);
Status InteractEntity(BehaviourClient &client, const int entity_id, const Hand hand=Hand::Main, const bool swing=false)
Interact with a given entity.
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.