the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 60 lines 1.7 kB view raw
1#include "stdafx.h" 2#include "net.minecraft.world.entity.ai.control.h" 3#include "net.minecraft.world.entity.animal.h" 4#include "net.minecraft.world.entity.player.h" 5#include "net.minecraft.world.level.h" 6#include "net.minecraft.world.item.h" 7#include "BegGoal.h" 8 9BegGoal::BegGoal(Wolf *wolf, float lookDistance) 10{ 11 player = weak_ptr<Player>(); 12 lookTime = 0; 13 14 this->wolf = wolf; 15 this->level = wolf->level; 16 this->lookDistance = lookDistance; 17 setRequiredControlFlags(Control::LookControlFlag); 18} 19 20bool BegGoal::canUse() 21{ 22 player = weak_ptr<Player>(level->getNearestPlayer(wolf->shared_from_this(), lookDistance)); 23 if (player.lock() == NULL) return false; 24 wolf->setDespawnProtected(); 25 return playerHoldingInteresting(player.lock()); 26} 27 28bool BegGoal::canContinueToUse() 29{ 30 if (player.lock() == NULL || !player.lock()->isAlive()) return false; 31 if (wolf->distanceToSqr(player.lock()) > lookDistance * lookDistance) return false; 32 wolf->setDespawnProtected(); 33 return lookTime > 0 && playerHoldingInteresting(player.lock()); 34} 35 36void BegGoal::start() 37{ 38 wolf->setIsInterested(true); 39 lookTime = 40 + wolf->getRandom()->nextInt(40); 40} 41 42void BegGoal::stop() 43{ 44 wolf->setIsInterested(false); 45 player = weak_ptr<Player>(); 46} 47 48void BegGoal::tick() 49{ 50 wolf->getLookControl()->setLookAt(player.lock()->x, player.lock()->y + player.lock()->getHeadHeight(), player.lock()->z, 10, wolf->getMaxHeadXRot()); 51 --lookTime; 52} 53 54bool BegGoal::playerHoldingInteresting(shared_ptr<Player> player) 55{ 56 shared_ptr<ItemInstance> item = player->inventory->getSelected(); 57 if (item == NULL) return false; 58 if (!wolf->isTame() && item->id == Item::bone_Id) return true; 59 return wolf->isFood(item); 60}