Vanhal / ProgressiveAutomation

Progressive Automation
Other
49 stars 31 forks source link

Attempt to solve issue #222 #243

Closed dshadowwolf closed 8 years ago

dshadowwolf commented 8 years ago

Somewhere along the way it seems the Item backing the ItemStack being handed to the code in the ThaumCraft helper is disappearing. This seems to happen between the test (at line 22) of the ItemStack not being null and the attempt to compare the result of ItemStack.getUnlocalizedName() to check for the leaf on line 23 of the existing source.

That this is happening at all indicates a bug in either Thaumcraft (I suspect this is true, as I'm getting other bugs from it or one of the integration mods that I have alongside it) or in the base Minecraft code. This attempts to patch the issue by wrapping the call to ItemStack.getUnlocalizedName() in a try-catch designed to catch the null-pointer deref exception.

dshadowwolf commented 8 years ago

Change this as I had stated I would in the issue thread.

Instead of calling ItemStack.getUnlocalizedName() directly - which seems to have a failure point in that its item field (ItemStack.field_15002_e) might be null - use the Forge/FML ItemStack.getItem() call to go through the item delegate system. While that can also return null, there is an easy guard against that and the final call should not (not will not, but should not) fail.