the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 51 lines 1.0 kB view raw
1#include "stdafx.h" 2#include "net.minecraft.world.entity.npc.h" 3#include "net.minecraft.world.entity.ai.control.h" 4#include "net.minecraft.world.entity.ai.navigation.h" 5#include "net.minecraft.world.inventory.h" 6#include "TradeWithPlayerGoal.h" 7 8TradeWithPlayerGoal::TradeWithPlayerGoal(Villager *mob) 9{ 10 this->mob = mob; 11 setRequiredControlFlags(Control::JumpControlFlag | Control::MoveControlFlag); 12} 13 14bool TradeWithPlayerGoal::canUse() 15{ 16 if (!mob->isAlive()) return false; 17 if (mob->isInWater()) return false; 18 if (!mob->onGround) return false; 19 if (mob->hurtMarked) return false; 20 21 shared_ptr<Player> trader = mob->getTradingPlayer(); 22 if (trader == NULL) 23 { 24 // no interaction 25 return false; 26 } 27 28 if (mob->distanceToSqr(trader) > (4 * 4)) 29 { 30 // too far away 31 return false; 32 } 33 34 if (!(trader->containerMenu == trader->inventoryMenu)) 35 { 36 // closed container 37 return false; 38 } 39 40 return true; 41} 42 43void TradeWithPlayerGoal::start() 44{ 45 mob->getNavigation()->stop(); 46} 47 48void TradeWithPlayerGoal::stop() 49{ 50 mob->setTradingPlayer(nullptr); 51}