Hello everyone,
Recently I have encoutered a problem with my mod (or maybe the way minecraft work), and after searching for days without any solution, I post here in case any of you can help me.
My goal : Change the color of a mob depending on a custom tag.
What I have done : Within a function that I have register to the RenderLivingEvent#Pre event, I checked the entity tag and change the value of the corresponding shader's(rendertype_entity_cutout_no_cull) Uniform that I have added (specific value = appeared in flat color). Then in another one registered to RenderLivingEvent#Post, I set back the Uniform to the base value (base value = appeared black and white).
The result : it worked, kind of...
Case 1 : This is the basic result.
Case 1bis : This is the same iteration but I have cleared the zombie item.
Case 2 : This is the result when I don't reset the Unifom in the RenderLivingEvent#Post event.
Case 3 : This is the base result when I am 16 block away from entities.
Case 4 : This is the result when I am 16 block away from entities and I don't reset the Unifom in the RenderLivingEvent#Post event.
Some explanation :
I spawned the mobs in a specific order so they render in that order (Stray->Skeleton->Zombie->Witch->Blaze).
As showed in case 1 and 3, simple entities (without object or layers) are rendered after the RenderLivingEvent#Post event (since I call the uniform in there to make them black and white). If the entity has objects or layers, then the base model is rendered before the Post event and the layers are rendered after (look at the stray an zombie in case 1).
From case 2, I assumed that the entity is complitely rendered (base and layers/objects) before the next RenderLivingEvent#Pre.
From case 3 and 4, I assumed that rendering change when entities are 16 block away from the player. Here you can see that the entity will finish rendering after the next RenderLivingEvent#Pre. The base model is still rendered before the Post event.
My conclusion :
The rendering of entities are slightly delayed, permitting the CPU to modified the Uniform before the GPU has finished rendering it. From what I have tested it's not a problem with my code.
I don't know if there is a solution to my problem.
Thanks in advance for any help !
PS : English is not my mother tongue, so excuse my writing.