b3feddfef3
* try to resolve merge conflict * feat: TU19 (Dec 2014) Features & Content (#32) * December 2014 files * Working release build * Fix compilation issues * Add sound to Windows64Media * Add DLC content and force Tutorial DLC * Revert "Add DLC content and force Tutorial DLC" This reverts commit 97a43994725008e35fceb984d5549df9c8cea470. * Disable broken light packing * Disable breakpoint during DLC texture map load Allows DLC loading but the DLC textures are still broken * Fix post build not working * ... * fix vs2022 build * fix cmake build --------- Co-authored-by: Loki <lokirautio@gmail.com>
40 lines
1.1 KiB
C++
40 lines
1.1 KiB
C++
#include "stdafx.h"
|
|
#include "net.minecraft.world.entity.ai.control.h"
|
|
#include "net.minecraft.world.entity.h"
|
|
#include "LeapAtTargetGoal.h"
|
|
|
|
LeapAtTargetGoal::LeapAtTargetGoal(Mob *mob, float yd)
|
|
{
|
|
target = weak_ptr<LivingEntity>();
|
|
|
|
this->mob = mob;
|
|
this->yd = yd;
|
|
setRequiredControlFlags(Control::JumpControlFlag | Control::MoveControlFlag);
|
|
}
|
|
|
|
bool LeapAtTargetGoal::canUse()
|
|
{
|
|
target = weak_ptr<LivingEntity>(mob->getTarget());
|
|
if (target.lock() == NULL) return false;
|
|
double d = mob->distanceToSqr(target.lock());
|
|
if (d < 2 * 2 || d > 4 * 4) return false;
|
|
if (!mob->onGround) return false;
|
|
if (mob->getRandom()->nextInt(5) != 0) return false;
|
|
return true;
|
|
}
|
|
|
|
bool LeapAtTargetGoal::canContinueToUse()
|
|
{
|
|
return target.lock() != NULL && !mob->onGround;
|
|
}
|
|
|
|
void LeapAtTargetGoal::start()
|
|
{
|
|
// TODO: move to control?
|
|
double xdd = target.lock()->x - mob->x;
|
|
double zdd = target.lock()->z - mob->z;
|
|
float dd = sqrt(xdd * xdd + zdd * zdd);
|
|
mob->xd += (xdd / dd * 0.5f) * 0.8f + mob->xd * 0.2f;
|
|
mob->zd += (zdd / dd * 0.5f) * 0.8f + mob->zd * 0.2f;
|
|
mob->yd = yd;
|
|
} |