Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.