fix: horse rendering (#3)

Reviewed-on: https://git.neolegacy.dev/pieeebot/mc_pieLCE/pulls/3
This commit was merged in pull request #3.
This commit is contained in:
pieeebot
2026-07-14 21:05:11 +01:00
2 changed files with 34 additions and 4 deletions
+29 -3
View File
@@ -46,9 +46,35 @@ void HorseRenderer::renderModel(shared_ptr<LivingEntity> mob, float wp, float ws
}
else
{
EntityRenderer::bindTexture(mob);
model->render(mob, wp, ws, bob, headRotMinusBodyRot, headRotx, scale, true);
// Ensure that any extra layers of texturing are disabled after rendering this horse
shared_ptr<EntityHorse> horse = dynamic_pointer_cast<EntityHorse>(mob);
ResourceLocation *location = getTextureLocation(mob);
// Pass 1: Bind only the coat texture (first valid layer) and render opaque
int coatTex = location->getTexture(0);
if( coatTex != -1 )
{
RenderManager.TextureBind(entityRenderDispatcher->textures->loadTexture(coatTex));
}
model->render(mob, wp, ws, bob, headRotMinusBodyRot, headRotx, scale, true);
// Pass 2: If horse has armor, find the armor texture in the layers and render with blending
int armorType = horse->getArmorType();
if( armorType > 0 )
{
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
for( int i = 1; i < location->getTextureCount(); i++ )
{
int texId = location->getTexture(i);
if( texId != -1 )
{
RenderManager.TextureBind(entityRenderDispatcher->textures->loadTexture(texId));
model->render(mob, wp, ws, bob, headRotMinusBodyRot, headRotx, scale, true);
}
}
glDisable(GL_BLEND);
}
RenderManager.TextureBind(-1);
}
}
+5 -1
View File
@@ -434,7 +434,11 @@ void Textures::bindTextureLayers(ResourceLocation *resource)
for( int i = 0; i < layers; i++ )
{
RenderManager.TextureBind(loadTexture(resource->getTexture(i)));
int texId = resource->getTexture(i);
if( texId != -1 )
{
RenderManager.TextureBind(loadTexture(texId));
}
}
}