TU24: Name of mobs, which are renamed using a name tag is now always visible, even when not looking at it up close.

This commit is contained in:
GabsPuNs
2026-06-03 23:40:43 -04:00
parent b0b83f6b63
commit 77ad7e0e90
2 changed files with 12 additions and 46 deletions

View File

@@ -458,7 +458,7 @@ void LivingEntityRenderer::renderName(shared_ptr<LivingEntity> mob, double x, do
bool LivingEntityRenderer::shouldShowName(shared_ptr<LivingEntity> mob)
{
return Minecraft::renderNames() && mob != entityRenderDispatcher->cameraEntity && !mob->isInvisibleTo(Minecraft::GetInstance()->player) && mob->rider.lock() == nullptr;
return Minecraft::renderNames() && !mob->isInvisibleTo(Minecraft::GetInstance()->player) && mob->rider.lock() == nullptr; //TU24: Removed && mob != entityRenderDispatcher->cameraEntity
}
void LivingEntityRenderer::renderNameTags(shared_ptr<LivingEntity> mob, double x, double y, double z, const wstring &msg, float scale, double dist)
@@ -488,12 +488,10 @@ void LivingEntityRenderer::renderNameTag(shared_ptr<LivingEntity> mob, const wst
return;
}
float dist = mob->distanceTo(entityRenderDispatcher->cameraEntity);
float dist = mob->distanceToSqr(entityRenderDispatcher->cameraEntity); //TU24 replaced distanceTo with distanceToSqr
if (dist > maxDist )
{
if (dist > ( maxDist * 6 ) ) //TU24: x6
return;
}
Font *font = getFont();
@@ -510,18 +508,18 @@ void LivingEntityRenderer::renderNameTag(shared_ptr<LivingEntity> mob, const wst
glScalef(-s, -s, s);
glDisable(GL_LIGHTING);
// TU24: Disable readableDist
/*
// 4J Stu - If it's beyond readable distance, then just render a coloured box
int readableDist = PLAYER_NAME_READABLE_FULLSCREEN;
if( !RenderManager.IsHiDef() )
{
readableDist = PLAYER_NAME_READABLE_DISTANCE_SD;
}
else if ( app.GetLocalPlayerCount() > 2 )
{
readableDist = PLAYER_NAME_READABLE_DISTANCE_SPLITSCREEN;
}
*/
float textOpacity = 1.0f;
/*
if( dist >= readableDist )
{
int diff = dist - readableDist;
@@ -533,6 +531,7 @@ void LivingEntityRenderer::renderNameTag(shared_ptr<LivingEntity> mob, const wst
if( textOpacity < 0.0f ) textOpacity = 0.0f;
if( textOpacity > 1.0f ) textOpacity = 1.0f;
*/
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -547,43 +546,13 @@ void LivingEntityRenderer::renderNameTag(shared_ptr<LivingEntity> mob, const wst
{
shared_ptr<Player> player = dynamic_pointer_cast<Player>(mob);
if(app.isXuidDeadmau5( player->getXuid() ) ) offs = -10;
if(app.isXuidDeadmau5( player->getXuid() ) )
offs = -10;
#if defined(__PS3__) || defined(__ORBIS__)
// Check we have all the font characters for this player name
switch(player->GetPlayerNameValidState())
{
case Player::ePlayerNameValid_NotSet:
if(font->AllCharactersValid(name))
{
playerName=name;
player->SetPlayerNameValidState(true);
}
else
{
memset(wchName,0,sizeof(WCHAR)*2);
swprintf(wchName, 2, L"%d",player->getPlayerIndex()+1);
playerName=wchName;
player->SetPlayerNameValidState(false);
}
break;
case Player::ePlayerNameValid_True:
playerName=name;
break;
case Player::ePlayerNameValid_False:
memset(wchName,0,sizeof(WCHAR)*2);
swprintf(wchName, 2, L"%d",player->getPlayerIndex()+1);
playerName=wchName;
break;
}
#else
playerName = name;
#endif
}
else
{
playerName = name;
}
if( textOpacity > 0.0f )
{
@@ -598,13 +567,10 @@ void LivingEntityRenderer::renderNameTag(shared_ptr<LivingEntity> mob, const wst
int w = font->width(playerName) / 2;
if( textOpacity < 1.0f )
{
t->color(color, 255 * textOpacity);
}
else
{
t->color(0.0f, 0.0f, 0.0f, 0.25f);
}
t->vertex(static_cast<float>(-w - 1), static_cast<float>(-1 + offs), static_cast<float>(0));
t->vertex(static_cast<float>(-w - 1), static_cast<float>(+8 + offs + 1), static_cast<float>(0));
t->vertex(static_cast<float>(+w + 1), static_cast<float>(+8 + offs + 1), static_cast<float>(0));

View File

@@ -33,7 +33,7 @@ void MobRenderer::render(shared_ptr<Entity> _mob, double x, double y, double z,
bool MobRenderer::shouldShowName(shared_ptr<LivingEntity> mob)
{
return LivingEntityRenderer::shouldShowName(mob) && (mob->shouldShowName() || dynamic_pointer_cast<Mob>(mob)->hasCustomName() && mob == entityRenderDispatcher->crosshairPickMob);
return LivingEntityRenderer::shouldShowName(mob) && (mob->shouldShowName() || dynamic_pointer_cast<Mob>(mob)->hasCustomName()); //TU24: Removed && mob == entityRenderDispatcher->crosshairPickMob
}
void MobRenderer::renderLeash(shared_ptr<Mob> entity, double x, double y, double z, float rot, float a)