Posted October 8, 20187 yr I'm working on a chest with a scrollbar and visually it work's fine, but after i scroll the inventory, all slots have the index 0 if clicked. I think my idea of how to update the inventory is wrong or i am missing something. I update the slots of my container, based on a rowOffset for the inventory. This is the function of the container: private void updateSlots() { if(this.te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) { IItemHandler inventory = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); int slotOffsetPlayer = 4 * 9; // Update own slots for (int row = 0; row < CHEST_ROWS; ++row) { for (int col = 0; col < CHEST_COLUMNS; ++col) { int x = CHEST_OFFSET_X + col * 18; int y = CHEST_OFFSET_Y + row * 18; this.inventorySlots.set(slotOffsetPlayer + (col + row * CHEST_COLUMNS), new SlotItemHandler(inventory, col + (row + rowOffset) * CHEST_COLUMNS, x, y)); } } } } Like i said the content get's displayed correctly, but whichever slot i click, i always interact with the slot with index 0. I changed the order in which the slots are added to the container from Chest, Player, Hotbar to Hotbar, Player, Chest and now i can still interact with the player's inventory and hotbar. But all slots i changed are inaccessible. In my first attempt i used a second inventory, which held the visible inventory and synced it back and forth with the whole inventory. But i didn't use capabilities for this, and switched after i read that by using the ItemHandlerCapability i do not have to sync the client manually with the server via packets. Because of that i rewrote the whole container and tried it first without the second inventory. Am i just missing something after i update the slots or do i still need the second temporary inventory? Edited October 8, 20187 yr by Keitaro
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.