Jump to content

Recommended Posts

Posted (edited)

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
Posted

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.

Posted (edited)
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
Posted

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!

Posted (edited)

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
Posted

@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!

Posted (edited)
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!

Posted
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
Posted

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
Posted

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)

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hi, I've been having trouble trying to use forge as it shows a black screen when I open the game, but I can still interact with it and hear the music.  I've done all of the step by steps and most common fixes like updating drivers, keeping up to date with Java, deleting and reinstalling minecraft, restarting my computer MANY times, even smaller things like splash.properties (I didn't have that file so I added it and set it to false thinking it would do something, definitely not) and making sure to prioritize my rtx 3070 in the settings but with no luck. Minecraft works as intended when I uninstall forge and I also don't have any mods currently, it just gives me this issue when I install forge. I also increased the ram usage, made sure my hardware isn't full or anything, and even changed the resolution in hopes it would fix things. I checked my antivirus and firewall but that isn't the issue either. Trust me, I've done everything I can think of. For some reason the black screen does flicker a little into the main menu, but obviously unplayable. I couldn't even make my way to the settings with how little it flickered. I'm not sure if it flickered randomly or if it was because I was messing around moving and clicking a bunch, I didn't really test it that much.  
    • I've had a really weird issue recently,  I wanted to add the Depper and Darker mod on my dedicated server (MC 1.21 with Fabric 0.16.9, hosted on nitroserv.com) but whenever I do add the mod the sever stops doing anything after listing the mods, and I get no crash or error or anything, just a stuck server. Here's a normal log of the server booting up: https://pastebin.com/JipFF2Eh and here's the log of the server doing the weird thing: https://pastebin.com/W4JBh3eX I just don't understand it. I've tried removing other mods (somewhat randomly) but deeper and darker still breaks my server whenever I add it. NitroServ support staff is about as confused as I am and I've had no response from the Deeper and Darker support staff... Now I know this is the Forge support not the Fabric support but I'm just trying to know if anyone has any kind of idea to fix this (aside from not using the mod obviously) Also I still have a bunch of errors and warnings whenever the server does start properly, are there any of them I should be worried about?
    • Delete the config of RandomTweaker (config folder) If there is no change, remove this mod
    • Hello! So i have been trying to make a mod that adds plant fiber to minecraft 1.16.5 (i believe there are mods that add plant fiber but not for 1.16.5) but the problem is that i want to modify the loot table of grass to always drop plant fiber but also keep the vanilla drops. Most common answer i have seen is GlobalLootModifiers. But my tiny brain cant understand any tutorials. So any help is appreciated.
  • Topics

×
×
  • Create New...

Important Information

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