I have multiple items that open a gui. Previously I've opened them like so:
FMLClientHandler.instance().displayGuiScreen(player, new GuiCardEditor(player, heldItem));
. However, I later realised that this was not compatible on servers, as it would make them crash. So I later added a gui handler and opened a gui like so;
, but this doesn't open the gui at all. What am I doing wrong?
EDIT: Also, the guis require an itemstack parameter in their constructor, otherwise they will not function properly.
EDIT 2: I also just now realised that the gui handler has a possibility to open the edit for the wrong item. Quick fix, but it doesn't explain why any gui will not open.
When you call EntityPlayer#openGui on the server, it only sends a packet telling the client to open the GUI if IGuiHandler#getServerGuiElement returns a non-nullContainer.
Since you don't have a Container, you need to call EntityPlayer#openGui on the client, either directly or via a server-to-client packet.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Caused by: java.lang.NullPointerException
at net.minecraftforge.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:277) ~[NetworkRegistry.class:?]
at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:110) ~[FMLNetworkHandler.class:?]
at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2776) ~[EntityPlayer.class:?]
at thatmartinguy.jeopardy.network.OpenGuiMessage$Handler.lambda$onMessage$0(OpenGuiMessage.java:43) ~[OpenGuiMessage$Handler.class:?]
FML couldn't find an IGuiHandler for the mod instance you passed to EntityPlayer#openGUI.
This could mean one of two things:
You haven't registered your IGuiHandler at all or haven't registered it on the physical client.
The mod instance you passed to the method was null or otherwise invalid.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I have multiple items that open a gui. Previously I've opened them like so:
. However, I later realised that this was not compatible on servers, as it would make them crash. So I later added a gui handler and opened a gui like so;
, but this doesn't open the gui at all. What am I doing wrong?
EDIT: Also, the guis require an itemstack parameter in their constructor, otherwise they will not function properly.
EDIT 2: I also just now realised that the gui handler has a possibility to open the edit for the wrong item. Quick fix, but it doesn't explain why any gui will not open.
Teleporting XP, for when you want to improve performance with XP farms
When you call EntityPlayer#openGui on the server, it only sends a packet telling the client to open the GUI if IGuiHandler#getServerGuiElement returns a non-null Container.
Since you don't have a Container, you need to call EntityPlayer#openGui on the client, either directly or via a server-to-client packet.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I tried creating a packet for it, but it causes a NullPointerException. It doesn't crash, it just prints this in the log.
Packet
Item that opens gui
Main mod file
Teleporting XP, for when you want to improve performance with XP farms
FML couldn't find an IGuiHandler for the mod instance you passed to EntityPlayer#openGUI.
This could mean one of two things:
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Ah, I didn't know you had to register it. Works now!
Added this to my init method if anyone is curious:
Teleporting XP, for when you want to improve performance with XP farms