This commit is contained in:
Tyler Reese 2026-04-22 06:00:45 +03:00 committed by GitHub
commit 1040dd5951
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 15 additions and 4 deletions

View file

@ -465,11 +465,11 @@ void LivingEntityRenderer::renderNameTags(shared_ptr<LivingEntity> mob, double x
{ {
if (mob->isSleeping()) if (mob->isSleeping())
{ {
renderNameTag(mob, msg, x, y - 1.5f, z, 64); renderNameTag(mob, msg, x, y - 1.5f, z, 64, mob->nametagColor);
} }
else else
{ {
renderNameTag(mob, msg, x, y, z, 64); renderNameTag(mob, msg, x, y, z, 64, mob->nametagColor);
} }
} }

View file

@ -485,7 +485,7 @@ void PlayerRenderer::additionalRendering(shared_ptr<LivingEntity> _mob, float a)
} }
} }
void PlayerRenderer::renderNameTags(shared_ptr<LivingEntity> player, double x, double y, double z, wstring msg, float scale, double dist) void PlayerRenderer::renderNameTags(shared_ptr<LivingEntity> player, double x, double y, double z, const wstring& msg, float scale, double dist)
{ {
#if 0 #if 0
if (dist < 10 * 10) if (dist < 10 * 10)
@ -511,6 +511,13 @@ void PlayerRenderer::renderNameTags(shared_ptr<LivingEntity> player, double x, d
} }
#endif #endif
if (player->instanceof(eTYPE_PLAYER)) {
shared_ptr<Player> p = dynamic_pointer_cast<Player>(player);
p->nametagColor = getNametagColour(p->getPlayerIndex());
}
else {
player->nametagColor = 0xFF000000;
}
LivingEntityRenderer::renderNameTags(player, x, y, z, msg, scale, dist); LivingEntityRenderer::renderNameTags(player, x, y, z, msg, scale, dist);
} }

View file

@ -34,7 +34,7 @@ public:
protected: protected:
virtual void additionalRendering(shared_ptr<LivingEntity> _mob, float a); virtual void additionalRendering(shared_ptr<LivingEntity> _mob, float a);
void renderNameTags(shared_ptr<LivingEntity> player, double x, double y, double z, wstring msg, float scale, double dist); virtual void renderNameTags(shared_ptr<LivingEntity> player, double x, double y, double z, const wstring& msg, float scale, double dist) override;
virtual void scale(shared_ptr<LivingEntity> _player, float a); virtual void scale(shared_ptr<LivingEntity> _player, float a);
public: public:

View file

@ -93,6 +93,8 @@ void LivingEntity::_init()
speed = 0.0f; speed = 0.0f;
noJumpDelay = 0; noJumpDelay = 0;
absorptionAmount = 0.0f; absorptionAmount = 0.0f;
nametagColor = 0xFF000000; //default to black. Overridden by stuff
} }
LivingEntity::LivingEntity( Level* level) : Entity(level) LivingEntity::LivingEntity( Level* level) : Entity(level)

View file

@ -80,6 +80,8 @@ public:
float yHeadRot, yHeadRotO; float yHeadRot, yHeadRotO;
float flyingSpeed; float flyingSpeed;
int nametagColor;
protected: protected:
shared_ptr<Player> lastHurtByPlayer; shared_ptr<Player> lastHurtByPlayer;
int lastHurtByPlayerTime; int lastHurtByPlayerTime;