the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "net.minecraft.world.entity.ai.control.h"
3#include "net.minecraft.world.entity.ai.navigation.h"
4#include "net.minecraft.world.entity.ai.util.h"
5#include "net.minecraft.world.entity.h"
6#include "net.minecraft.world.phys.h"
7#include "MoveTowardsTargetGoal.h"
8
9MoveTowardsTargetGoal::MoveTowardsTargetGoal(PathfinderMob *mob, double speedModifier, float within)
10{
11 this->mob = mob;
12 this->speedModifier = speedModifier;
13 this->within = within;
14 setRequiredControlFlags(Control::MoveControlFlag);
15}
16
17bool MoveTowardsTargetGoal::canUse()
18{
19 target = weak_ptr<LivingEntity>(mob->getTarget());
20 if (target.lock() == NULL) return false;
21 if (target.lock()->distanceToSqr(mob->shared_from_this()) > within * within) return false;
22 Vec3 *pos = RandomPos::getPosTowards(dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 16, 7, Vec3::newTemp(target.lock()->x, target.lock()->y, target.lock()->z));
23 if (pos == NULL) return false;
24 wantedX = pos->x;
25 wantedY = pos->y;
26 wantedZ = pos->z;
27 return true;
28}
29
30bool MoveTowardsTargetGoal::canContinueToUse()
31{
32 return target.lock() != NULL && !mob->getNavigation()->isDone() && target.lock()->isAlive() && target.lock()->distanceToSqr(mob->shared_from_this()) < within * within;
33}
34
35void MoveTowardsTargetGoal::stop()
36{
37 target = weak_ptr<Mob>();
38}
39
40void MoveTowardsTargetGoal::start()
41{
42 mob->getNavigation()->moveTo(wantedX, wantedY, wantedZ, speedModifier);
43}