Elyon Posted July 1, 2014 Posted July 1, 2014 I have a barebones descendant of BlockOldLeaf . As with my descendant of BlockFurnace , I have left the icon registry (and much everything else) up to the parent class. This does not work for BlockOldLeaf , however. While the block works well within the game world, as soon as I try rendering it as an item (by opening the Decorations Creative tab or "picking" the leaves), the game crashes from a NullPointerException : BlockChocolateOldLeaf.java package net.elyon.chocolate; import net.minecraft.block.BlockOldLeaf; public class BlockChocolateOldLeaf extends BlockOldLeaf { public BlockChocolateOldLeaf() { super(); } } Relevant stacktrace [07:53:09] [Client thread/FATAL]: Reported exception thrown! net.minecraft.util.ReportedException: Rendering item at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:624) ~[RenderItem.class:?] at net.minecraft.client.gui.GuiIngame.renderInventorySlot(GuiIngame.java:973) ~[GuiIngame.class:?] at net.minecraftforge.client.GuiIngameForge.renderHotbar(GuiIngameForge.java:209) ~[GuiIngameForge.class:?] at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:144) ~[GuiIngameForge.class:?] at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1122) ~[EntityRenderer.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1066) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:961) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_60] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_60] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_60] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_60] at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) [launchwrapper-1.9.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.9.jar:?] Caused by: java.lang.NullPointerException at net.minecraft.block.BlockOldLeaf.getIcon(BlockOldLeaf.java:68) ~[blockOldLeaf.class:?] at net.minecraft.item.ItemLeaves.getIconFromDamage(ItemLeaves.java:51) ~[itemLeaves.class:?] at net.minecraft.item.Item.getIconIndex(Item.java:457) ~[item.class:?] at net.minecraft.item.ItemStack.getIconIndex(ItemStack.java:134) ~[itemStack.class:?] at net.minecraft.client.renderer.entity.RenderItem.renderItemIntoGUI(RenderItem.java:420) ~[RenderItem.class:?] at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:585) ~[RenderItem.class:?] Digging through BlockOldLeaf.java, specifically the getIcon method, I see it relies on the static field field_150130_N , which is declared and initialised in the same class. I cannot figure out why my barebones BlockOldLeaf replacement throws a NullReferenceException in the getIcon method. Quote
Kwibble Posted July 1, 2014 Posted July 1, 2014 I am having a hard time replicating your problem. Is there anything else that you can tell us that may lead us to your problem? Quote We all stuff up sometimes... But I seem to be at the bottom of that pot.
Elyon Posted July 1, 2014 Author Posted July 1, 2014 I replace Blocks.leaves through reflection. When simply registering the block through the GameRegistry , it works - I guess there is an issue with the way I reflect, then? The very same approach worked for the furnace, though, so I don't know. I initialise the new block statically in my main mod class, but perhaps the registerBlockIcons method of BlockOldLeaf is called after the replacement has taken place? This still doesn't explain why it would work with the furnace ... but they are very different blocks indeed. Quote
Kwibble Posted July 1, 2014 Posted July 1, 2014 Going off that, I would assume that something is going wrong with your reflection yes... Could you please post all the relevant code? My Magical Code Viewing Device (or MCVD) is kinda broken permanently. Sorry. Quote We all stuff up sometimes... But I seem to be at the bottom of that pot.
Elyon Posted July 1, 2014 Author Posted July 1, 2014 This should be the mod code in its entirety. BlockReplaceHelper (using ReflectionHelper ) is what I am currently doing to replace Blocks.leaves . Quote
Kwibble Posted July 1, 2014 Posted July 1, 2014 After quickly browsing your code... I can only think of one thing that could be causing problems. Are you registering the block with a special ItemBlock class? (Is that even needed?? Could be worth looking into). That's all I got, sorry. Quote We all stuff up sometimes... But I seem to be at the bottom of that pot.
Elyon Posted July 1, 2014 Author Posted July 1, 2014 I am not registering the block, just replacing the vanilla block. I figure I need to call setBlockTextureName("minecraft:leaves") , but doing so yields exactly the same result. Quote
Kwibble Posted July 1, 2014 Posted July 1, 2014 Maybe if you copied all the chained methods that the leaves block uses normally? (the ones used when Minecraft first registers it in the Block class?) I am not sure if you have already done so, but it could be worth a try. Quote We all stuff up sometimes... But I seem to be at the bottom of that pot.
Elyon Posted July 2, 2014 Author Posted July 2, 2014 I did that. This is my new initialisation: public static Block chocolateOldLeafBlock = new BlockChocolateOldLeaf().setBlockName("leaves").setBlockTextureName("minecraft:leaves"); Thank you for the input, though Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.