Added capes (needs improvement)

This commit is contained in:
mschiller890
2026-03-13 23:56:49 +01:00
parent 0db3a547c7
commit 97daa795fb
5 changed files with 277 additions and 21 deletions

View File

@@ -29,6 +29,7 @@ Mob::Mob(Level* level)
invulnerableDuration(20),
//hasHair(false),
textureName("mob/char.png"),
capeTextureName(""),
allowAlpha(true),
modelName(""),
bobStrength(1),
@@ -82,6 +83,15 @@ Mob::Mob(Level* level)
yRot = (float) (Mth::random() * Mth::PI * 2);
this->footSize = 0.5f;
// Initialize cape inertia positions
xCape = x;
yCape = y;
zCape = z;
xc = xCape;
yc = yCape;
zc = zCape;
}
Mob::~Mob() {
@@ -115,6 +125,16 @@ void Mob::setTextureName(const std::string& name)
textureName = name;
}
std::string Mob::getCapeTexture()
{
return capeTextureName;
}
void Mob::setCapeTextureName(const std::string& name)
{
capeTextureName = name;
}
bool Mob::isPickable()
{
return !removed;
@@ -274,6 +294,10 @@ void Mob::superTick()
void Mob::tick()
{
xc = xCape;
yc = yCape;
zc = zCape;
super::tick();
if (arrowCount > 0) {
@@ -378,6 +402,18 @@ void Mob::tick()
while (xRot - xRotO >= 180)
xRotO += 360;
animStep += walkSpeed;
// Reduce jitter by using a smaller interpolation factor (more lag, smoother motion)
double dxCape = x - xCape;
double dyCape = y - yCape;
double dzCape = z - zCape;
const double interp = 0.15; // small value for smoother cape motion
const double interpY = 0.12; // extra smoothing on vertical movement
xCape += dxCape * interp;
yCape += dyCape * interpY;
zCape += dzCape * interp;
}
void Mob::setSize( float w, float h )

View File

@@ -44,9 +44,14 @@ public:
virtual std::string getTexture();
virtual void setTextureName(const std::string& name);
virtual bool isAlive();
// Optional player cape texture (non-null on clients when available)
virtual std::string getCapeTexture();
virtual void setCapeTextureName(const std::string& name);
virtual bool isAlive();
virtual bool isPickable();
virtual bool isPushable();
virtual bool isShootable();
MoveControl* getMoveControl();
@@ -213,7 +218,22 @@ protected:
float walkingSpeed;
float flyingSpeed;
// Cape inertia positions
double xCape, yCape, zCape;
double xc, yc, zc;
public:
// Cape position accessors (for renderers)
double getCapeX() const { return xCape; }
double getCapeY() const { return yCape; }
double getCapeZ() const { return zCape; }
double getCapePrevX() const { return xc; }
double getCapePrevY() const { return yc; }
double getCapePrevZ() const { return zc; }
std::string textureName;
std::string capeTextureName;
std::string modelName;
int deathScore;
float oRun, run;