the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 44 lines 1.2 kB view raw
1#include "stdafx.h" 2#include "net.minecraft.world.entity.ai.control.h" 3#include "net.minecraft.world.entity.npc.h" 4#include "net.minecraft.world.entity.animal.h" 5#include "net.minecraft.world.level.h" 6#include "net.minecraft.world.phys.h" 7#include "OfferFlowerGoal.h" 8 9OfferFlowerGoal::OfferFlowerGoal(VillagerGolem *golem) 10{ 11 this->golem = golem; 12 setRequiredControlFlags(Control::MoveControlFlag | Control::LookControlFlag); 13} 14 15bool OfferFlowerGoal::canUse() 16{ 17 if (!golem->level->isDay()) return false; 18 if (golem->getRandom()->nextInt(8000) != 0) return false; 19 villager = weak_ptr<Villager>(dynamic_pointer_cast<Villager>( golem->level->getClosestEntityOfClass(typeid(Villager), golem->bb->grow(6, 2, 6), golem->shared_from_this()) )); 20 return villager.lock() != NULL; 21} 22 23bool OfferFlowerGoal::canContinueToUse() 24{ 25 return _tick > 0 && villager.lock() != NULL; 26} 27 28void OfferFlowerGoal::start() 29{ 30 _tick = OFFER_TICKS; 31 golem->offerFlower(true); 32} 33 34void OfferFlowerGoal::stop() 35{ 36 golem->offerFlower(false); 37 villager = weak_ptr<Villager>(); 38} 39 40void OfferFlowerGoal::tick() 41{ 42 golem->getLookControl()->setLookAt(villager.lock(), 30, 30); 43 --_tick; 44}