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->GetAttributeEntityInteractionRangeValue();
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> packet_interact = std::make_shared<ServerboundInteractPacket>();
55 packet_interact->SetEntityId(entity_id);
56#if PROTOCOL_VERSION < 775
57 packet_interact->SetAction(0);
59 packet_interact->SetHand(
static_cast<int>(hand));
60#if PROTOCOL_VERSION > 722
61 packet_interact->SetUsingSecondaryAction(
false);
63 network_manager->Send(packet_interact);
67 std::shared_ptr<ServerboundSwingPacket> packet_swing = std::make_shared<ServerboundSwingPacket>();
68 packet_swing->SetHand(
static_cast<int>(hand));
70 network_manager->Send(packet_swing);
78 constexpr std::array variable_names = {
79 "InteractEntity.entity_id",
80 "InteractEntity.hand",
81 "InteractEntity.swing"
86 blackboard.
Set<
int>(variable_names[0], entity_id);
87 blackboard.
Set<
Hand>(variable_names[1], hand);
88 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.