[1.10.2] Crash when holding shift with a pattern in inventory
codewarrior0 opened this issue ยท 5 comments
... when the pattern's output is an item that is rendered via CodeChickenLib's revived IItemHandler.
refinedstorage-1.2.17.jar
CodeChickenLib-1.10.2-2.5.2.203-universal.jar
gregtech-5.10.35-HOMEBAKED.8.jar (my own build, but I didn't touch the item rendering)
forge-1.10.2-12.18.3.2215-universal.jar
You're gonna love this.
Steps to reproduce:
- Program a pattern with a GT cell of some kind as the output.
- Hold shift.
- Client crash.
Stack trace goes like this:
java.lang.ClassCastException: com.raoulvdberge.refinedstorage.item.ItemPattern cannot be cast to gregtech.api.items.GT_Generic_Item
at gregtech.common.render.ItemRenderer.renderItem(ItemRenderer.java:300)
at gregtech.common.render.ItemRenderer$BakedModelItemRendererWrapper.renderItem(ItemRenderer.java:317)
at codechicken.lib.render.item.CCRenderItem.func_180454_a(CCRenderItem.java:84)
at codechicken.lib.render.item.CCRenderItem.func_184390_a(CCRenderItem.java:164)
at codechicken.lib.render.item.CCRenderItem.func_184391_a(CCRenderItem.java:224)
at net.minecraft.client.gui.inventory.GuiContainer.func_146977_a(GuiContainer.java:266)
at net.minecraft.client.gui.inventory.GuiContainer.func_73863_a(GuiContainer.java:96)
at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:382)
RefinedStorage isn't mentioned in the trace except as the item type. But let's take a closer look. In BakedModelPattern.java, we have an override set whenever a pattern is rendered with the Shift key held down. This shows the pattern's output instead of the generic pattern icon for the pattern item. This is done by returning whatever IBakedModel is associated with the pattern's single output. This usually works because IBakedModel doesn't care about which itemstack is being rendered.
But with CodeChickenLib in play, that IBakedModel isn't necessarily a model at all! CCL revives the old IItemRenderer which happens to inherit from IBakedModel. And an implementation of IItemRenderer (such as GregTech's) will of course need the actual item stack to do the rendering. (Stack is passed to renderer here.)
So even though you return the correct IBakedModel for the pattern's output, that object might actually be an IItemRenderer which will insist on receiving the correct item, where it currently receives a item.ItemPattern instead.
--
I don't expect a fix for this. Mostly, I'm posting it to publically document the issue for anyone else trying to use GT and RS together.
Managed to fix this on GregTech's side (not really fixed, because now the pattern is just blank when you hold shift), but I expect it will come up with other mods that use CodeChickenLib for its IItemRenderer.
Related to #609. The issue that we can change the actual model being rendered, but not the ItemStack passed along for models using a builtin renderer.