Jump to content

[1.8][SOLVED] StackSize on ItemStack turning to 0


Recommended Posts

Hello, I'm making a furnace style tileEntity which takes the input of an item and then turns it into another or several other items, all inside a GUI.


Everything works perfectly, the input gets consumed and then the outputs are placed on the output slots. But the problem comes along when the user clicks on a empty output slot, somehow making the some of the size of the ItemStacks inside the output itemstacks list become of amount 0 (ItemStack.stackSize becomes 0). I've been looking around the code and can't figure out how is this happening. Even made the output list final and also made a copy of it which is never used and they all turn 0... Here's the relevant part of the code of my tileEntity


That the item.uraniumpowder2 turned into a stack size of 0 (0xitem.uraniumpowder2..) in BOTH the listOut and the aux lists! I even checked and the outputList[][] is also changed!


So how the heck is this happening?

Link to comment
Share on other sites

Well, if you directly take the ItemStack out of the list and pass it around, that ItemStack is still in your List! And if someone modifies it, it will be modified in your List as well, since it's the same ItemStack! Whenever you pass one of them out, copy it (ItemStack has a copy method).


Wow it actually was that, using the copy() on the moment I place the item fixed it >.<. Didn't know that the setInventorySlotContents placed the actual stack and not simply its information! Thank you!

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.

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.