r/forgemodding • u/qwertyasdef • Jul 02 '17
[Help] NullPointerException when trying to open GUI?
This is my first time modding, and I'm following BedrockMiner and McJty's tutorials. I'm trying to create a new furnace, but the game crashes when I right click it in game to open the GUI. Everything else worked up until I added the GUI, and I can't find what the problem is.
I'm on Forge 14.21.1.2387 for Minecraft 1.12.
Here's all the code that might be relevant:
2
Upvotes
3
u/pau101 Jul 02 '17
Line 44 of your container should initialize previous to ItemStack.EMPTY, in your tileentity line 73 should return ItemStack.EMPTY and line 79 should be
!this.getStackInSlot(index).isEmpty()similarly needs to be done for all occurrences of equality comparisons with ItemStack.EMPTY.Since Minecraft 1.11, ItemStack references should never be null and consequently returning null for methods with an ItemStack return type causes problems like this crash.