* 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 97a4399472.
* 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>
54 lines
1.3 KiB
C++
54 lines
1.3 KiB
C++
#include "stdafx.h"
|
|
#include "net.minecraft.world.entity.h"
|
|
#include "net.minecraft.world.entity.ai.control.h"
|
|
#include "BodyControl.h"
|
|
|
|
const float BodyControl::maxClampAngle = 75.0f;
|
|
|
|
BodyControl::BodyControl(LivingEntity *mob)
|
|
{
|
|
this->mob = mob;
|
|
|
|
timeStill = 0;
|
|
lastHeadY = 0.0f;
|
|
}
|
|
|
|
void BodyControl::clientTick()
|
|
{
|
|
double xd = mob->x - mob->xo;
|
|
double zd = mob->z - mob->zo;
|
|
|
|
if (xd * xd + zd * zd > MoveControl::MIN_SPEED_SQR)
|
|
{
|
|
// we are moving.
|
|
mob->yBodyRot = mob->yRot;
|
|
mob->yHeadRot = clamp(mob->yBodyRot, mob->yHeadRot, maxClampAngle);
|
|
lastHeadY = mob->yHeadRot;
|
|
timeStill = 0;
|
|
return;
|
|
}
|
|
|
|
// Body will align to head after looking long enough in a direction
|
|
float clampAngle = maxClampAngle;
|
|
if (abs(mob->yHeadRot - lastHeadY) > 15)
|
|
{
|
|
timeStill = 0;
|
|
lastHeadY = mob->yHeadRot;
|
|
}
|
|
else
|
|
{
|
|
++timeStill;
|
|
static const int timeStillBeforeTurn = 10;
|
|
if (timeStill > timeStillBeforeTurn) clampAngle = max(1 - (timeStill - timeStillBeforeTurn) / 10.f, 0.0f) * maxClampAngle;
|
|
}
|
|
|
|
mob->yBodyRot = clamp(mob->yHeadRot, mob->yBodyRot, clampAngle);
|
|
}
|
|
|
|
float BodyControl::clamp(float clampTo, float clampFrom, float clampAngle)
|
|
{
|
|
float headDiffBody = Mth::wrapDegrees(clampTo - clampFrom);
|
|
if (headDiffBody < -clampAngle) headDiffBody = -clampAngle;
|
|
if (headDiffBody >= clampAngle) headDiffBody = +clampAngle;
|
|
return clampTo - headDiffBody;
|
|
} |