4jcraft/Minecraft.World/AI/Goals/PanicGoal.cpp
2026-03-21 15:10:07 -05:00

31 lines
1 KiB
C++

#include "../../Platform/stdafx.h"
#include "../../Headers/net.minecraft.world.entity.ai.control.h"
#include "../../Headers/net.minecraft.world.entity.ai.navigation.h"
#include "../../Headers/net.minecraft.world.entity.ai.util.h"
#include "../../Headers/net.minecraft.world.entity.h"
#include "../../Headers/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() == NULL && !mob->isOnFire()) return false;
Vec3* pos = RandomPos::getPos(
std::dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 5,
4);
if (pos == NULL) 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(); }