the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 54 lines 1.1 kB view raw
1#include "stdafx.h" 2#include "net.minecraft.world.entity.ai.control.h" 3#include "net.minecraft.world.entity.ai.sensing.h" 4#include "net.minecraft.world.entity.ai.navigation.h" 5#include "net.minecraft.world.entity.monster.h" 6#include "SwellGoal.h" 7 8SwellGoal::SwellGoal(Creeper *creeper) 9{ 10 target = weak_ptr<LivingEntity>(); 11 12 this->creeper = creeper; 13 setRequiredControlFlags(Control::MoveControlFlag); 14} 15 16bool SwellGoal::canUse() 17{ 18 shared_ptr<LivingEntity> target = creeper->getTarget(); 19 return creeper->getSwellDir() > 0 || (target != NULL && (creeper->distanceToSqr(target) < 3 * 3)); 20} 21 22void SwellGoal::start() 23{ 24 creeper->getNavigation()->stop(); 25 target = weak_ptr<LivingEntity>(creeper->getTarget()); 26} 27 28void SwellGoal::stop() 29{ 30 target = weak_ptr<LivingEntity>(); 31} 32 33void SwellGoal::tick() 34{ 35 if (target.lock() == NULL) 36 { 37 creeper->setSwellDir(-1); 38 return; 39 } 40 41 if (creeper->distanceToSqr(target.lock()) > 7 * 7) 42 { 43 creeper->setSwellDir(-1); 44 return; 45 } 46 47 if (!creeper->getSensing()->canSee(target.lock())) 48 { 49 creeper->setSwellDir(-1); 50 return; 51 } 52 53 creeper->setSwellDir(1); 54}