Jump to content

[1.14.4] Trouble with Scrolling inventory


Cerandior

Recommended Posts

I am trying to make a multiblock in which you connect inventories together to a controller block through pipes. Then from that controller block you can manipulate all of those inventories.
Now obviously, for big structures, I would need to have a scroller to be able to go through each of the slots that the inventories connected have, however I am having some nasty problems with it.

 

I don't have problems when connecting two single chests or a double chest, however when I connect another one (when I have to use the scrollbar), various problems arise.

1 - It seems like my "mapping" function is not accurate and I can't pinpoint why. I am taking the scrollbar position and mapping it between 0 and inventory size in this function and I use that value to update the slots of the container. The problem is that I can keep scrolling even when my inventory has ran out of slots, even though it shouldn't do that, so it doesn't seem like it is working properly. I feel like the math is correct. I am taking a percentage value to show at which % of the full scroll range my scrollbar currently is and I am then multiplying that value with the number of slots in the inventory (inventory size). And that's the value I return. Can't really spot the problem here.


2 - When connecting 3 single chests, initially, the empty slots of the new chest show up when you scroll at that position, however I can't update these slots. I put items in it, they show up in the gui, but not at the chest itself. I think they become duplicate slots of the currently existing slots of the double chest, and again I am not sure why.

3 - The last problem I have is purely visual. I can't seem to find the scrollbar GUI component and I made mine out of a button. It looks really ugly. Does anyone know what GUI component vanilla uses for the creative screen scrollbar?

A short gif explaining the problem:
giphy.gif


Related classes (If you wish to check another thing, please ask or simply navigate in the repository)

1) StorageBlock Class: https://github.com/arjolpanci/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/blocks/StorageBlock.java


2) CollectiveStorageContainer Class: https://github.com/arjolpanci/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/container/CollectiveStorageContainer.java


3) CollectiveStorageScreen Class: https://github.com/arjolpanci/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/client/gui/CollectiveStorageScreen.java

 

Thank you in advance!
 

Edited by Cerandior
Link to comment
Share on other sites

Okay the scrolling is smoother now, I changed the "mapping" function a bit, so problem 1 is solved.
I tried looking at widgets of Minecraft GUI, and could only find the sliders they use for the options so I don't think I can use those in this gui. So problem 3 remains yet.

And the biggest problem is problem 2, because this is not functional in this state. I did some experimenting and it seems like the slots appear empty in the gui, you can put items in it, but then they become duplicate slots of already existing item slots. You can take these out and it will update everything next time you open the gui again (so you can't duplicate items), however the empty slots of the inventories that are outside of the gui viewing range are purely visual since they are not really the actual slots. Updating them doesn't update the contents of the chest because as I said, as soon as you put an item in them they turn into duplicate slots of already existing slots. So whatever item you put in them, even if they appear as a different item, as soon as you force an update they turn into whatever item was stored in those slots.

Why is this happening? Does it have to do with the way I am handling the scrolling, or is the problem related to the way I assign these slots in StorageBlock Class.

Link to comment
Share on other sites

5 minutes ago, DragonITA said:

Why you not try to see a Java classic scrolling Gui script?

It's not about the concept of scrolling, it's about making it happen with slots in an inventory on minecraft. To make it visually appealing, you have to make it so when you scroll, you scroll row by row. I did that, however I am having trouble with the handling of those inventories. Because my tile doesn't have its own inventory, it actually has to work with the inventories that are connected to it through a multi-block. Now I am not having any trouble with with the slots that fit within the gui initially, I can manipulate those slots fine. I am having problems with the slots that appear after you scroll.

Edited by Cerandior
  • Like 1
Link to comment
Share on other sites

Ok, i see your problem. Sorry but i dont have work with Gui, but i think it is a problem with your slots skript. I think the skript insert the Blocks in the Chest that have loser or the same amount of slots as two chest (a combinated chest), but if you complete the first range of slots (the same amount a a combinated chest) and will add more Gui, then the skript …. I dont think i cant help you, but the problem is in the class that manipulate this gui transportion. Hope it help you and i hope you will resolve this problem.

  • Thanks 1

New in Modding? == Still learning!

Link to comment
Share on other sites

The whole thing is a mess really. The more I play around with it the more things I find that are wrong. I think the problem is at the part I get the item and empty slots of the inventories connected to it. I checked and the multi-block recognizes the inventories connected to it properly. Checked with various inventory blocks like a shulker box, chest, double chest. Doesn't matter, it always finds the correct inventories / tiles connected to it.

 

Is there anything blatantly wrong in this code? (getInventories() returns an arraylist of the connected inventories in the multiblock. As I mentioned before it is accurate and I don't think the problem is there)

for(IInventory i : getInventories()){
    for(int j=0; j<i.getSizeInventory(); j++){
        Slot slot = new Slot(i, j, 0, 0);
        if(slot.getStack().isEmpty()){
            emptySlots.add(slot);
            continue;
        }
        itemSlots.add(slot);
    }
}
Edited by Cerandior
  • Like 1
Link to comment
Share on other sites

@Cerandior I think I got it, when your block drops the items in the inventory it checks if there is enough space left, if not then it doesn't add the blocks, for example: A chest has 8 empty slots (I repeat, it's just an example, a chest has more slots) while your block has 10 full slots. If you then try to transfer these 10 slots of items into the chest only 8 slots will be filled and the too many items will be dropped on the floor

New in Modding? == Still learning!

Link to comment
Share on other sites

16 hours ago, Cerandior said:

3 - The last problem I have is purely visual. I can't seem to find the scrollbar GUI component and I made mine out of a button. It looks really ugly. Does anyone know what GUI component vanilla uses for the creative screen scrollbar?

Read the Vanilla code and use the Vanilla Scrollbar texture.

Edited by DragonITA

New in Modding? == Still learning!

Link to comment
Share on other sites

1 hour ago, DragonITA said:

@Cerandior I think I got it, when your block drops the items in the inventory it checks if there is enough space left, if not then it doesn't add the blocks, for example: A chest has 8 empty slots (I repeat, it's just an example, a chest has more slots) while your block has 10 full slots. If you then try to transfer these 10 slots of items into the chest only 8 slots will be filled and the too many items will be dropped on the floor

I don't think that is the case because as I mentioned before, all of those empty slots are non-functional. It's not about 1 or 2.

  • Like 1
Link to comment
Share on other sites

So after more experimenting I noticed that the server has the right information about the empty slots in the inventories connected in the multi-block, however the client does not. I simply filled up the chests manually, and I noticed that the value of the empty slots did not change in the client.

 

https://prnt.sc/r48reg

The numbers in the image represent the number of empty slots available in the multi-block, and as you can see the client and the server have different values on that. How can I update the client data?

  • Like 1
Link to comment
Share on other sites

Please show your full code. Especially your container and tile entity

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

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.

Announcements



×
×
  • Create New...

Important Information

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