Posted January 8, 20196 yr So I have a custom GUI with one row of 9 slots, and then a single slot above them all (which is supposed to act just like all the others, it's not an output). I loop through the row of 9 slots and add them to the container, which works fine. Then I add just the top slot and it's coordinates to the container. However, everytime I put an item in the top slot, it duplicates into the corresponding slot in the for loop. I know it's a logical error, but I'm not able to figure out how to fix it.
January 8, 20196 yr We can't help you if you don't provide us with code. Saying it's a logical error doesn't tell us or show us anything. Currently developing: https://github.com/unassignedxd/Dynamic-Quarries
January 8, 20196 yr Author Sorry. public CustomContainer(InventoryPlayer player, TestTileEntity tileEntity) { this.tileEntity = tileEntity; // single slot this.addSlotToContainer(new Slot(tileEntity, 0, 80, 32)); // row of 9 for (int i = 0; i < 9; i++) { this.addSlotToContainer(new Slot(tileEntity, i, 8 + i * 18, 53)); } /* Player Inventory and Hotbar */ for (int y = 0; y < 3; y++) { for (int x = 0; x < 9; x++) { this.addSlotToContainer(new Slot(player, x + y * 9 + 9, 8 + x * 18, 84 + y * 18)); } } for (int x = 0; x < 9; x++) { this.addSlotToContainer(new Slot(player, x, 8 + x * 18, 142)); } } Edited January 8, 20196 yr by Siqhter
January 8, 20196 yr Author 14 minutes ago, diesieben07 said: You tell the "single slot" to use inventory index 0. You also tell the first slot in the loop to use inventory index 0. I know, that's why it duplicates the item because it's essentially the same slot. I don't know how to give it it's own index after looping through the first row. It's crashes the game with an out of bounds exception.
January 8, 20196 yr Author Thanks for the explanation. I got it working, but I don't quite understand what I did: Spoiler /* Single Slot */ this.addSlotToContainer(new Slot(tileEntity, 9, 80, 32)); /* Container Slots */ for (int i = 0; i < 9; i++) { this.addSlotToContainer(new Slot(tileEntity, i, 8 + i * 18, 53)); } The "single slot" index is 9. How does the "index" relate to the "actual" slot in which an item can be placed? Edited January 8, 20196 yr by Siqhter
January 8, 20196 yr You have an arbitrary number of slots, you were assigning: slot 0 to single slot slot 0 to container slot 0 slot 1 to container slot 1 slot 2 to container slot 2 ... slot 8 to container slot 8 now you are assigning slot 9 to single slot slot 0 to container slot 0 slot 1 to container slot 1 slot 2 to container slot 2 ... slot 8 to container slot 8 Previously you were assigning to slots to the same slot ID index, hence the duplicate slots Edited January 8, 20196 yr by Cadiboo About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.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)
January 8, 20196 yr 13 minutes ago, Siqhter said: /* Container Slots */ ID -> slotIndex, pretty much the same thing tho About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.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)
January 8, 20196 yr In this (specific) case both need to be unique, which is what I meant About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.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)
January 8, 20196 yr Author Now when you told me to get rid of IInventory and use IItemHandler, is that because I'm using InventoryPlayer? How do switch it?
January 8, 20196 yr IInventory is legacy vanilla code, IItemHandler is forge’s intercompatible replacement About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.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)
January 8, 20196 yr Author I guess I'm just unclear as to what I am supposed to replace with IItemHandler. Edited January 9, 20196 yr by Siqhter
January 9, 20196 yr Author Edit: I've done some research on IItemHandler and Capabilites, so rather, where am I supposed to implement using capabilities. The tileentity? And what needs to change in my container class so that I'm not implementing IInventory.
January 10, 20196 yr The tile entity should override the has/getCapability methods appropriately replace everything from IInventory with the tile entities ItemstackHandler You can see an example at https://github.com/Cadiboo/WIPTech/blob/fb5883e9d76ef0361ec1ebbcb9c508611dd2ef6b/src/main/java/cadiboo/wiptech/tileentity/TileEntityModFurnace.java#L300-L340 and https://github.com/Cadiboo/WIPTech/blob/fb5883e9d76ef0361ec1ebbcb9c508611dd2ef6b/src/main/java/cadiboo/wiptech/inventory/ContainerModFurnace.java About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.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)
January 10, 20196 yr Author Thank you, I'm taking a look at that. I'm wondering in your example, where do you set a display name for the container? Originally I had something like "container.name" after the createContainer method. But I believe that's from IInventory.
January 11, 20196 yr It gets drawn in drawGuiContainerForegroundLayer. You can draw it yourself About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.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)
January 11, 20196 yr Author 9 hours ago, Cadiboo said: It gets drawn in drawGuiContainerForegroundLayer. You can draw it yourself Ok, I didn't think of that. There's also a method called getDisplayName that works in the tileentity. Last question, I don't understand what's going on in your read and write to NBT methods. Mine aren't saving any items after quitting, but that's obvious because there's nothing in them. Not sure if I use set integer?
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.