Jump to content

java.lang.NullPointerException when trying to create gui


zombiekiller222

Recommended Posts

Java throws a java.lang.NullPointerException when I try to use

player.openGui(LotrCraft.Instance, 1, world, x, y, z);

Doing a little stack-following I found it happens when this code is ran:

 

FMLCommonHandler.instance().showGuiScreen(handler.getClientGuiElement(modGuiId, player, world, x, y, z));

 

So, presumably, my gui handler is returning null? Here is it's code:

 

package mymod.common;

import cpw.mods.fml.common.network.IGuiHandler;
import net.minecraft.src.*;

public class GuiHandler implements IGuiHandler {
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world,
int x, int y, int z) {
switch (ID) {
case 1:
return new ContainerSmelter(player.inventory, world, x, y, z);
}
return null;
}

@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world,
int x, int y, int z) {
switch (ID) {
case 1:
return new GuiSmelter(player.inventory, world, x, y, z);
}
return null;
}
}

 

If you need the code for the container and gui, i'll post it.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.