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.h"
3#include "net.minecraft.world.entity.ai.control.h"
4#include "net.minecraft.world.entity.ai.navigation.h"
5#include "net.minecraft.world.entity.ai.util.h"
6#include "net.minecraft.world.phys.h"
7#include "SharedConstants.h"
8#include "RandomStrollGoal.h"
9
10RandomStrollGoal::RandomStrollGoal(PathfinderMob *mob, double speedModifier)
11{
12 this->mob = mob;
13 this->speedModifier = speedModifier;
14 setRequiredControlFlags(Control::MoveControlFlag | Control::LookControlFlag);
15}
16
17bool RandomStrollGoal::canUse()
18{
19 // 4J - altered a little so we can do some more random strolling when appropriate, to try and move any animals that aren't confined to a fenced-off region far enough to determine we can despawn them
20 if (mob->getNoActionTime() < SharedConstants::TICKS_PER_SECOND * 5)
21 {
22 if (mob->getRandom()->nextInt(120) == 0)
23 {
24 Vec3 *pos = RandomPos::getPos(dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 10, 7);
25 if (pos == NULL) return false;
26 wantedX = pos->x;
27 wantedY = pos->y;
28 wantedZ = pos->z;
29 return true;
30 }
31 }
32 else
33 {
34 // This entity wouldn't normally be randomly strolling. However, if our management system says that it should do, then do. Don't
35 // bother waiting for random conditions to be met before picking a direction though as the point here is to see if it is possible to
36 // stroll out of a given area and so waiting around is just wasting time
37
38 if( mob->isExtraWanderingEnabled() )
39 {
40 Vec3 *pos = RandomPos::getPos(dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 10, 7,mob->getWanderingQuadrant());
41 if (pos == NULL) return false;
42 wantedX = pos->x;
43 wantedY = pos->y;
44 wantedZ = pos->z;
45 return true;
46 }
47
48 }
49 return false;
50}
51
52bool RandomStrollGoal::canContinueToUse()
53{
54 return !mob->getNavigation()->isDone();
55}
56
57void RandomStrollGoal::start()
58{
59 mob->getNavigation()->moveTo(wantedX, wantedY, wantedZ, speedModifier);
60}