This commit is contained in:
GabsPuNs
2026-05-14 21:52:21 -04:00
parent 1b2f5c6fe8
commit f8a2d644f5
291 changed files with 7363 additions and 18368 deletions

View File

@@ -41,8 +41,9 @@ float Bat::getVoicePitch()
int Bat::getAmbientSound()
{
if (isResting() && random->nextInt(4) != 0)
{
return -1;
}
return eSoundType_MOB_BAT_IDLE; //"mob.bat.idle";
}
@@ -88,9 +89,13 @@ void Bat::setResting(bool value)
{
char current = entityData->getByte(DATA_ID_FLAGS);
if (value)
{
entityData->set(DATA_ID_FLAGS, static_cast<char>(current | FLAG_RESTING));
}
else
{
entityData->set(DATA_ID_FLAGS, static_cast<char>(current & ~FLAG_RESTING));
}
}
bool Bat::useNewAi()
@@ -100,6 +105,7 @@ bool Bat::useNewAi()
void Bat::tick()
{
AmbientCreature::tick();
if (isResting())
@@ -108,7 +114,10 @@ void Bat::tick()
y = Mth::floor(y) + 1.0 - bbHeight;
}
else
{
yd *= .6f;
}
}
inline int signum(double x) { return (x > 0) - (x < 0); }
@@ -126,8 +135,11 @@ void Bat::newServerAiStep()
}
else
{
if (random->nextInt(200) == 0)
{
yHeadRot = random->nextInt(360);
}
if (level->getNearestPlayer(shared_from_this(), 4.0f) != nullptr)
{
@@ -164,7 +176,10 @@ void Bat::newServerAiStep()
yRot += rotDiff;
if (random->nextInt(100) == 0 && level->isSolidBlockingTile(Mth::floor(x), static_cast<int>(y) + 1, Mth::floor(z)))
{
setResting(true);
}
}
}
@@ -173,7 +188,9 @@ bool Bat::makeStepSound()
return false;
}
void Bat::causeFallDamage(float distance) {}
void Bat::causeFallDamage(float distance)
{
}
void Bat::checkFallDamage(double ya, bool onGround)
{
@@ -188,13 +205,13 @@ bool Bat::isIgnoringTileTriggers()
bool Bat::hurt(DamageSource *source, float dmg)
{
if (isInvulnerable())
return false;
if (isInvulnerable()) return false;
if (!level->isClientSide)
{
if (isResting())
{
setResting(false);
}
}
return AmbientCreature::hurt(source, dmg);
@@ -214,11 +231,11 @@ void Bat::addAdditonalSaveData(CompoundTag *entityTag)
entityTag->putByte(L"BatFlags", entityData->getByte(DATA_ID_FLAGS));
}
bool Bat::canSpawn()
{
int yt = Mth::floor(bb->y0);
if (yt >= level->seaLevel)
return false;
if (yt >= level->seaLevel) return false;
int xt = Mth::floor(x);
int zt = Mth::floor(z);
@@ -227,18 +244,15 @@ bool Bat::canSpawn()
int maxLight = 4;
if ((Calendar::GetDayOfMonth() + 1 == 10 && Calendar::GetDayOfMonth() >= 20) || (Calendar::GetMonth() + 1 == 11 && Calendar::GetMonth() <= 3))
{
maxLight = 7;
}
else if (random->nextBoolean())
{
return false;
}
if (br > random->nextInt(maxLight))
return false;
if (br > random->nextInt(maxLight)) return false;
return AmbientCreature::canSpawn();
}
// TU25 Addition
float Bat::getEyeHeight()
{
return bbHeight * 0.5f;
}