Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.15.2] How to update a container's slots?


TurtyWurty
 Share

Recommended Posts

So I have a tile entity which has several 'pages' of slots, and you move to the next page using the forward page and back page buttons. This mostly works apart from the fact that slots seem to only be created when the container is opened. So this means when I press the button, I have to close and re-open the container in order for the container to show the next page of slots. So I was wondering how I would go about causing it to show the next page of slots and hide the current page when I press the button without having to close and re-open the container. I have been trying to look at the Creative Inventory code as well as the Stone-cutter code, but sadly I haven't managed to find anything that works. Thanks in advance.

Link to comment
Share on other sites

31 minutes ago, diesieben07 said:

When you change slots you have to do it on client and server (as the server needs the correct positions of the slots as well).

So you'll have to send a packet to the server when changing pages and shuffle the slots around there as well.

But how do I actually change the slots? Currently what I am doing to make it page dependent is just (page number * number of slots per page) + index.

Edited by TurtyWurty
Link to comment
Share on other sites

You can either change the slots themselves (i.e. make them point at a different inventory slot), but I am not sure how feasible it is.

You can also just add all slots and just move them around, i.e. move the ones that are not on the current page off-screen (i.e. negative x/y positions). This one might not be viable if you have a lot of slots.

Link to comment
Share on other sites

12 minutes ago, diesieben07 said:

You can either change the slots themselves (i.e. make them point at a different inventory slot), but I am not sure how feasible it is.

You can also just add all slots and just move them around, i.e. move the ones that are not on the current page off-screen (i.e. negative x/y positions). This one might not be viable if you have a lot of slots.

Yea, I have 104 slots per page, so I don't imagine the second option would be a great idea. But by the first option, do you mean to just change the slots index? If so, how would I even go about doing that?

Edited by TurtyWurty
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
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.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.