neoLegacy/Minecraft.World/SwellGoal.cpp
NSDeathman 42ee0b519e
Some checks are pending
Sync branches with main / sync (push) Waiting to run
feat(TU31): Creepers can be ignited with flint and steel (#84)
* TU31 feature: Creepers can be ignited with flint and steel

* make mobInteract more accurate to decomp

---------

Co-authored-by: piebot <274605694+pieeebot@users.noreply.github.com>
2026-05-18 22:02:31 +03:00

61 lines
1.1 KiB
C++

#include "stdafx.h"
#include "net.minecraft.world.entity.ai.control.h"
#include "net.minecraft.world.entity.ai.sensing.h"
#include "net.minecraft.world.entity.ai.navigation.h"
#include "net.minecraft.world.entity.monster.h"
#include "SwellGoal.h"
SwellGoal::SwellGoal(Creeper *creeper)
{
target = weak_ptr<LivingEntity>();
this->creeper = creeper;
setRequiredControlFlags(Control::MoveControlFlag);
}
bool SwellGoal::canUse()
{
shared_ptr<LivingEntity> target = creeper->getTarget();
return creeper->getSwellDir() > 0 || (target != nullptr && (creeper->distanceToSqr(target) < 3 * 3));
}
void SwellGoal::start()
{
creeper->getNavigation()->stop();
target = weak_ptr<LivingEntity>(creeper->getTarget());
}
void SwellGoal::stop()
{
target = weak_ptr<LivingEntity>();
}
void SwellGoal::tick()
{
if(creeper->isIgnited())
{
creeper->setSwellDir(1);
return;
}
if (target.lock() == nullptr)
{
creeper->setSwellDir(-1);
return;
}
if (creeper->distanceToSqr(target.lock()) > 7 * 7)
{
creeper->setSwellDir(-1);
return;
}
if (!creeper->getSensing()->canSee(target.lock()))
{
creeper->setSwellDir(-1);
return;
}
creeper->setSwellDir(1);
}