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.animal.h"
5#include "net.minecraft.world.entity.ai.navigation.h"
6#include "net.minecraft.world.entity.player.h"
7#include "net.minecraft.world.level.h"
8#include "RandomPos.h"
9#include "RunAroundLikeCrazyGoal.h"
10
11RunAroundLikeCrazyGoal::RunAroundLikeCrazyGoal(EntityHorse *mob, double speedModifier)
12{
13 horse = mob;
14 this->speedModifier = speedModifier;
15 setRequiredControlFlags(Control::MoveControlFlag);
16}
17
18bool RunAroundLikeCrazyGoal::canUse()
19{
20 if (horse->isTamed() || horse->rider.lock() == NULL) return false;
21 Vec3 *pos = RandomPos::getPos(dynamic_pointer_cast<PathfinderMob>(horse->shared_from_this()), 5, 4);
22 if (pos == NULL) return false;
23 posX = pos->x;
24 posY = pos->y;
25 posZ = pos->z;
26 return true;
27}
28
29void RunAroundLikeCrazyGoal::start()
30{
31 horse->getNavigation()->moveTo(posX, posY, posZ, speedModifier);
32}
33
34bool RunAroundLikeCrazyGoal::canContinueToUse()
35{
36 return !horse->getNavigation()->isDone() && horse->rider.lock() != NULL;
37}
38
39void RunAroundLikeCrazyGoal::tick()
40{
41 if (horse->getRandom()->nextInt(50) == 0)
42 {
43
44 if ( horse->rider.lock()->instanceof(eTYPE_PLAYER) )
45 {
46 int temper = horse->getTemper();
47 int maxTemper = horse->getMaxTemper();
48 if (maxTemper > 0 && horse->getRandom()->nextInt(maxTemper) < temper)
49 {
50 horse->tameWithName(dynamic_pointer_cast<Player>(horse->rider.lock()));
51 horse->level->broadcastEntityEvent(horse->shared_from_this(), EntityEvent::TAMING_SUCCEEDED);
52 return;
53 }
54 horse->modifyTemper(5);
55 }
56
57 horse->rider.lock()->ride(nullptr);
58 horse->rider = weak_ptr<LivingEntity>();
59 horse->makeMad();
60 horse->level->broadcastEntityEvent(horse->shared_from_this(), EntityEvent::TAMING_FAILED);
61 }
62}