Jump to content

[1.11.2] [Solved]Custom GUI error: NullPointerException


Recommended Posts

Posted (edited)

Hey, so in my custom GUI, I'm getting a NullPointerException directed at the following override: (according to the console)

@Override
		public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
			if(!worldIn.isRemote)
				playerIn.openGui(Reference.MOD_ID, GuiHandler.PESTLE_GUI, worldIn, pos.getX(), pos.getY(), pos.getZ());
			return true;
		}

I just can't figure out why I'm getting this error.

 

Crash report:

https://pastebin.com/NyFi0T5X

My GUI Handler:

https://pastebin.com/b4w8x1Zf

My Container:

https://pastebin.com/YYhks7au

 

Edited by ModMCdl
Solved

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Posted
2 minutes ago, diesieben07 said:

How is the stack "directed at the override"? There is no reference to the code you posted in the stack trace.

 

The issue is caused by a Slot having a null reference for it's inventory. In this case it can only be either the TileEntity or the player inventory. The latter is very unlikely.

Please show your whole Block class.

An error in the console was pointing at it, must have been a fluke.

 

Block Class:

https://pastebin.com/hHA0scMf 

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Posted

Or rather, show the TileEntity class

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
Just now, Draco18s said:

Or rather, show the TileEntity class

TileEntityPestle.java

https://pastebin.com/x1n5wapC

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Posted
1 minute ago, diesieben07 said:

Your block does not override hasTileEntity, as such it does not have a TileEntity.

Ah, didn't realize that was a thing I needed to do! What would I put in the override here? Would I just return the tileentity I made?

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Posted (edited)
10 minutes ago, diesieben07 said:

Please read the documentation for the method. It clearly explains what it does.

It is also f***ing self-explanatory.

Alright, no need to get all up in arms. I'm still learning here. And you going off doesn't help anyone who comes to this post in the future trying to solve the same problem.

Edited by ModMCdl

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Posted
33 minutes ago, diesieben07 said:

Your block does not override hasTileEntity, as such it does not have a TileEntity.

Would I also need to override createTileEntity and, because I'm delving into new territory here, are there any thorough examples/explanations for how this is done? (Besides the documentations which helped me very little.

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Posted
4 minutes ago, diesieben07 said:

You need to both override hasTileEntity and createTileEntity, yes.

The documentation has no information about TileEntities, I'd be curious what little help you got out of it despite that.

I went here: https://takahikokawasaki.github.io/minecraft-resources/javadoc/forge/1.8-11.14.1.1320/net/minecraft/block/Block.html#hasTileEntity(net.minecraft.block.state.IBlockState)

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Posted
Just now, diesieben07 said:

That is neither official nor up to date in any way, shape or form.

You directed to me "read the documentation for the method" and that was the only documentation I found.

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Posted
Just now, diesieben07 said:

You have an IDE, do you not?

It only gave me the standard Overrides "x" method

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Posted
Just now, diesieben07 said:

Yours must be broken then, you should look into fixing it:

idea64_2017-11-03_00-07-32.png.486d21acfbe85fddf4caef6de33b4876.png

I use eclipse. It has never done that. Hovering over the method is what brings up said explanation, and I only get "Overrides hasTileEntity" and the path.

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Posted

*Cough*

This:

javadoc.png

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Once I overrode hasTileEntity and createTileEntity, I now error in my TileEntityPestle class.

https://pastebin.com/15r7mcCS

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Posted

Your inventory is size 3.

 

        this.addSlotToContainer(new Slot(tileentity, 0, 31, 24));
        this.addSlotToContainer(new Slot(tileentity, 1, 66, 43));
        this.addSlotToContainer(new SlotPestleOutput(player.player, tileentity, 3, 119, 30));
 
0, 1, 3. Yes. That is how we count.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
1 minute ago, Draco18s said:

Your inventory is size 3.

 

        this.addSlotToContainer(new Slot(tileentity, 0, 31, 24));
        this.addSlotToContainer(new Slot(tileentity, 1, 66, 43));
        this.addSlotToContainer(new SlotPestleOutput(player.player, tileentity, 3, 119, 30));
 
0, 1, 3. Yes. That is how we count.

Hahahahahaha

NOW I feel stupid. I replaced everything that referenced the mysterious "slot 3" and reset the index to 0, 1, 2. Now the GUI works, it doesn't crash, and now I just have to figure out why the crafting recipes don't actually work!

 

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Posted (edited)

Side note, what's the updated name for transferStackInSlot. It doesn't seem to be working for me in 1.11.2

Please just ignore that, I'm an idiot.

Edited by ModMCdl

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Posted
1 minute ago, diesieben07 said:

transferStackInSlot still exists.

I am well aware. I'm just an idiot.

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Posted

Now, because I'm very needy, can you also possibly point out what's wrong here with my crafting? I don't get any errors or crashes, it just doesn't work.

Pestle Recipe class:

https://pastebin.com/15huRuYq

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

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.

Announcements



×
×
  • Create New...

Important Information

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