the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 52 lines 1.4 kB view raw
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.h" 5#include "net.minecraft.world.level.h" 6#include "net.minecraft.world.phys.h" 7#include "FleeSunGoal.h" 8 9FleeSunGoal::FleeSunGoal(PathfinderMob *mob, double speedModifier) 10{ 11 this->mob = mob; 12 this->speedModifier = speedModifier; 13 this->level = mob->level; 14 setRequiredControlFlags(Control::MoveControlFlag); 15} 16 17bool FleeSunGoal::canUse() 18{ 19 if (!level->isDay()) return false; 20 if (!mob->isOnFire()) return false; 21 if (!level->canSeeSky(Mth::floor(mob->x), (int) mob->bb->y0, Mth::floor(mob->z))) return false; 22 23 Vec3 *pos = getHidePos(); 24 if (pos == NULL) return false; 25 wantedX = pos->x; 26 wantedY = pos->y; 27 wantedZ = pos->z; 28 return true; 29} 30 31bool FleeSunGoal::canContinueToUse() 32{ 33 return !mob->getNavigation()->isDone(); 34} 35 36void FleeSunGoal::start() 37{ 38 mob->getNavigation()->moveTo(wantedX, wantedY, wantedZ, speedModifier); 39} 40 41Vec3 *FleeSunGoal::getHidePos() 42{ 43 Random *random = mob->getRandom(); 44 for (int i = 0; i < 10; i++) 45 { 46 int xt = Mth::floor(mob->x + random->nextInt(20) - 10); 47 int yt = Mth::floor(mob->bb->y0 + random->nextInt(6) - 3); 48 int zt = Mth::floor(mob->z + random->nextInt(20) - 10); 49 if (!level->canSeeSky(xt, yt, zt) && mob->getWalkTargetValue(xt, yt, zt) < 0) return Vec3::newTemp(xt, yt, zt); 50 } 51 return NULL; 52}