Files
GabsPuNs-Project_Zenith_Main/Minecraft.World/PanicGoal.cpp
GabsPuNs bc6c09146a New File System and Cleanup some code Part 3
* Remove stdafx.h and some <unordered_set> includes
* Update Minecraft Server Defines and remove more unused folders/files
* Unbloat stdafx.h from Minecraft.World
2026-05-24 22:21:41 -04:00

36 lines
916 B
C++

#include "net.minecraft.world.entity.ai.control.h"
#include "net.minecraft.world.entity.ai.navigation.h"
#include "net.minecraft.world.entity.ai.util.h"
#include "net.minecraft.world.entity.h"
#include "net.minecraft.world.phys.h"
#include "PanicGoal.h"
PanicGoal::PanicGoal(PathfinderMob *mob, double speedModifier)
{
this->mob = mob;
this->speedModifier = speedModifier;
setRequiredControlFlags(Control::MoveControlFlag);
}
bool PanicGoal::canUse()
{
if (mob->getLastHurtByMob() == nullptr && !mob->isOnFire()) return false;
const Vec3 *pos = RandomPos::getPos(dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 5, 4);
if (pos == nullptr) return false;
posX = pos->x;
posY = pos->y;
posZ = pos->z;
return true;
}
void PanicGoal::start()
{
mob->getNavigation()->moveTo(posX, posY, posZ, speedModifier);
}
bool PanicGoal::canContinueToUse()
{
return !mob->getNavigation()->isDone();
}