Block Armor

Block Armor

4M Downloads

Minecraft 1.12.2 - JEI and Block Armor Rendering Issue! (Debugging)

P3rf3ctXZer0 opened this issue ยท 7 comments

commented

System Specs and Mods and forge version
https://gist.github.com/P3rf3ctXZer0/f470a73d8048e2bf58f12b2a3363f9d2

Basically the last highlighted block armor item becomes all of the block armors in the JEI gui.
as seen here.
2017-09-25_15 39 49

commented

I added a rendering optimization in the latest versions of JEI, so I'll look into it first and let you know what I find.

commented

One of my attempted optimizations is storing the IBakedModel for each item instead of querying it each time.
So I call this just once:

bakedModel = itemModelMesher.getItemModel(itemStack);
bakedModel = bakedModel.getOverrides().handleItemState(bakedModel, itemStack, null, null);

It looks like you use a shared baked model for all your items and override the quads in ModelDynBlockArmor.BakedDynBlockArmorOverrideHandler#handleItemState which is not something I anticipated. That's why they all look the same in JEI.

/**Called every tick - sets inventory icon (via quads) from map*/
@Override
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) {
ImmutableList<BakedQuad> quads = itemQuadsMap.get(stack.getItem());
((BakedDynBlockArmor)originalModel).quads = quads;
return originalModel;
}

Is there a reason to do it that way? It seems to me like you could just have different baked models for each item instead of storing it in a map and altering one shared model.
I would just eliminate that optimization on my side since it is causing this issue, but it actually doubles the fps when rendering certain pages of modded items and doesn't seem to cause issues with other mods.

commented

Not to mention that baked models are immutable by their nature. handleItemState is meant to return a new, modified instance.

commented

If I try and cheat one it all renders change but it does give me the correct item. That is how I got the gold helmet and diamond boots. Currently this bug is clearly JEI cosmetic. JEI last Updated 6 hours from this post.

mezz/JustEnoughItems#1001

The ID for the item rendering appears random with each reboot of client.

commented

That is.. very interesting. We do use some unique rendering to create the inventory icons dynamically from block textures, so it is very possible that our code is making it difficult for JEI to find the correct icon. I can try to look into this and see what's going on. If mezz or someone else finds a solution before me, I will do what I can to help!

commented

You're right mezz, I didn't have any reason to just use one shared model. This was my first attempt at working with baked models and I didn't entirely know what I was doing (I still am not an expert). I fixed this issue by creating different baked models for each item, as mezz suggested, and assigning the quads to the baked model in ModelDynBlockArmor.BakedDynBlockArmorOverrideHandler#handleItemState the first time that it is called (quads can't be assigned in ModelDynBlockArmor#bake because they rely on other block's quads to be baked first).

This fix is in v2.4.9: BlockArmor-1.12.2-2.4.9.jar.zip

Thank you very much mezz for taking the time to look through my code and figure out what's wrong! And thank you P3rf3ctXZer0 for reporting this issue.

commented

@Furgl always glad to help a modder since I found sadly I am not able to code. (Ironically despite being good at analytics I hyper focus on singular variables so coding can and would take me more than 7 years to could a single html because I also have a bad memory.)