the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 49 lines 1.6 kB view raw
1#include "stdafx.h" 2#include "net.minecraft.world.entity.ai.navigation.h" 3#include "net.minecraft.world.entity.ai.village.h" 4#include "net.minecraft.world.entity.h" 5#include "net.minecraft.world.level.h" 6#include "RestrictOpenDoorGoal.h" 7 8RestrictOpenDoorGoal::RestrictOpenDoorGoal(PathfinderMob *mob) 9{ 10 this->mob = mob; 11} 12 13bool RestrictOpenDoorGoal::canUse() 14{ 15 if (mob->level->isDay()) return false; 16 shared_ptr<Village> village = mob->level->villages->getClosestVillage(Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z), 16); 17 if (village == NULL) return false; 18 shared_ptr<DoorInfo> _doorInfo = village->getClosestDoorInfo(Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z)); 19 if (_doorInfo == NULL) return false; 20 doorInfo = _doorInfo; 21 return _doorInfo->distanceToInsideSqr(Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z)) < 1.5 * 1.5; 22} 23 24bool RestrictOpenDoorGoal::canContinueToUse() 25{ 26 if (mob->level->isDay()) return false; 27 shared_ptr<DoorInfo> _doorInfo = doorInfo.lock(); 28 if ( _doorInfo == NULL ) return false; 29 return !_doorInfo->removed && _doorInfo->isInsideSide(Mth::floor(mob->x), Mth::floor(mob->z)); 30} 31 32void RestrictOpenDoorGoal::start() 33{ 34 mob->getNavigation()->setCanOpenDoors(false); 35 mob->getNavigation()->setCanPassDoors(false); 36} 37 38void RestrictOpenDoorGoal::stop() 39{ 40 mob->getNavigation()->setCanOpenDoors(true); 41 mob->getNavigation()->setCanPassDoors(true); 42 doorInfo = weak_ptr<DoorInfo>(); 43} 44 45void RestrictOpenDoorGoal::tick() 46{ 47 shared_ptr<DoorInfo> _doorInfo = doorInfo.lock(); 48 if ( _doorInfo ) _doorInfo->incBookingCount(); 49}