Jump to content

[1.16.5] simple way to merge ItemStacks?


Recommended Posts

As already stated in the title, I would like to know if there is an easy way to combine ItemStacks?

My problem at the moment is that I have a list with ItemStacks and want to combine them,
which means if the list contains 10 times of stone with a count of 10.
form that I want to make a list with 2 times of stone from it which means the count of the items in total are the same so i have two stack with the count 64 and 36.
is this possible/ is there a simple way to do that?

Link to comment
Share on other sites

1 hour ago, kiou.23 said:

there isn't a function that does that already.

however writing your own helper function shouldn't be that hard

don't forget to handle the case when the ItemStacks contain different Items, or Items with non-64 maximum stack sizes

38 minutes ago, diesieben07 said:

Look at ItemStackHandler#insertItem for an example of how to do this.

thanks for the good ideas


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.