Jump to content

[1.15.1] addItemStackToInventory, special case doesn't work


Kander16

Recommended Posts

Hi,

 

I'm currently creating a 'containerItem', an item which has a specified containerItem set and if used (eaten, for example) it returns this containerItem into the inventory of the player. I made this class to get arbitrary items to work like a SoupItem (so that it can return an arbitrary item back in inventory. Everything seems to work fine except for one special case, and I don't know where to look. My code: https://pastebin.com/gwX2yDiJ

 

The different possible cases:

 

  • If the item you were eating is gone:
    • If the containerItem is stackable and the player has the containerItemStack in its inventory, use player.addItemStackToInventory to add the containerItem to the current stack
      • This is the one case that doesn't work sometimes. If I am eating an item with a count of 1, and had a containerItem already in my inventory with the maxStackSize reached (in my case, 64), the item completely vanishes. Any idea of what I'm doing wrong here? 
    • In any other case, just return the containerItemStack to get the containerItem
  • If the item you were eating isn't gone:
    • player.addItemStackToInventory (to not replace the item you were eating)

 

Thanks in advance,

 

Kander16

 

Creator of the Master Chef Mod and many more to come.

 

If I helped you, please click the 'thank you' button.

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.