2026-03-01 12:16:08 +08:00
# include "stdafx.h"
# include "SheepRenderer.h"
# include "MultiPlayerLocalPlayer.h"
2026-04-14 16:47:37 -05:00
# include "../Minecraft.World/net.minecraft.world.entity.animal.h"
2026-03-01 12:16:08 +08:00
2026-03-03 03:04:10 +08:00
ResourceLocation SheepRenderer : : SHEEP_LOCATION = ResourceLocation ( TN_MOB_SHEEP ) ;
ResourceLocation SheepRenderer : : SHEEP_FUR_LOCATION = ResourceLocation ( TN_MOB_SHEEP_FUR ) ;
2026-03-01 12:16:08 +08:00
SheepRenderer : : SheepRenderer ( Model * model , Model * armor , float shadow ) : MobRenderer ( model , shadow )
{
setArmor ( armor ) ;
}
2026-03-03 03:04:10 +08:00
int SheepRenderer : : prepareArmor ( shared_ptr < LivingEntity > _sheep , int layer , float a )
2026-03-01 12:16:08 +08:00
{
// 4J - dynamic cast required because we aren't using templates/generics in our version
2026-03-02 17:37:16 +07:00
shared_ptr < Sheep > sheep = dynamic_pointer_cast < Sheep > ( _sheep ) ;
2026-03-01 12:16:08 +08:00
if ( layer = = 0 & & ! sheep - > isSheared ( ) & &
! sheep - > isInvisibleTo ( Minecraft : : GetInstance ( ) - > player ) ) // 4J-JEV: Todo, merge with java fix (for invisible sheep armour) in '1.7.5'.
{
MemSect ( 31 ) ;
2026-03-03 03:04:10 +08:00
bindTexture ( & SHEEP_FUR_LOCATION ) ;
2026-03-01 12:16:08 +08:00
MemSect ( 0 ) ;
2026-03-03 03:04:10 +08:00
if ( sheep - > hasCustomName ( ) & & sheep - > getCustomName ( ) . compare ( L " jeb_ " ) = = 0 )
{
// easter egg...
int colorDuration = 25 ;
int value = ( sheep - > tickCount / colorDuration ) + sheep - > entityId ;
int c1 = value % Sheep : : COLOR_LENGTH ;
int c2 = ( value + 1 ) % Sheep : : COLOR_LENGTH ;
2026-03-08 19:08:36 -04:00
float subStep = ( ( sheep - > tickCount % colorDuration ) + a ) / static_cast < float > ( colorDuration ) ;
2026-03-03 03:04:10 +08:00
2026-04-08 20:34:48 -07:00
glColor3f (
Sheep : : COLOR [ c1 ] [ 0 ] * ( 1.0f - subStep ) + Sheep : : COLOR [ c2 ] [ 0 ] * subStep ,
Sheep : : COLOR [ c1 ] [ 1 ] * ( 1.0f - subStep ) + Sheep : : COLOR [ c2 ] [ 1 ] * subStep ,
Sheep : : COLOR [ c1 ] [ 2 ] * ( 1.0f - subStep ) + Sheep : : COLOR [ c2 ] [ 2 ] * subStep ) ;
2026-03-03 03:04:10 +08:00
}
else
{
2026-04-08 20:34:48 -07:00
float brightness = SharedConstants : : TEXTURE_LIGHTING ? 1.0f : sheep - > getBrightness ( a ) ;
int color = sheep - > getColor ( ) ;
glColor3f ( brightness * Sheep : : COLOR [ color ] [ 0 ] , brightness * Sheep : : COLOR [ color ] [ 1 ] , brightness * Sheep : : COLOR [ color ] [ 2 ] ) ;
2026-03-03 03:04:10 +08:00
}
2026-03-01 12:16:08 +08:00
// 4J - change brought forward from 1.8.2
2026-04-08 20:34:48 -07:00
/* Fix; this code originally completely overrided the _jeb and normal textures so i just commented it out and updated the part that should have worked.
float brightness = SharedConstants : : TEXTURE_LIGHTING ? 1.0f : sheep - > getBrightness ( a ) ;
int color = sheep - > getColor ( ) ;
glColor3f ( brightness * Sheep : : COLOR [ color ] [ 0 ] , brightness * Sheep : : COLOR [ color ] [ 1 ] , brightness * Sheep : : COLOR [ color ] [ 2 ] ) ; */
2026-03-01 12:16:08 +08:00
return 1 ;
}
return - 1 ;
}
2026-03-02 17:37:16 +07:00
void SheepRenderer : : render ( shared_ptr < Entity > mob , double x , double y , double z , float rot , float a )
2026-03-01 12:16:08 +08:00
{
MobRenderer : : render ( mob , x , y , z , rot , a ) ;
2026-03-02 17:37:16 +07:00
}
2026-03-03 03:04:10 +08:00
ResourceLocation * SheepRenderer : : getTextureLocation ( shared_ptr < Entity > mob )
{
return & SHEEP_LOCATION ;
}