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 just spent hours tracking down a weird bug in a custom Container and eventually realised it was to do with retrySlotClick. (I have a set of slots which automatically sort themselves when items are added or removed, and shift-clicking resulted in the whole set of slots being transferred if the items were the same, because retrySlotClick was called after the sorting). I've experimentally overridden retrySlotClick to do nothing, and it seems to have fixed the problem. So what is the point of that method in the first place? It seems to be only called in one place in vanilla and I don't really understand why. Except for an unusual modded case (like my self-sorting Container), when will a slot click fail the first time but succeed the second time? Doesn't the method just introduce a big risk of stack overflow if the slot click fails repeatedly?

Edited by Jay Avery

Inside Container#slotClick, if it's called with ClickType.QUICK_MOVE (shift-click), it calls Container#transferStackIntoSlot. This will try to move the ItemStack to other stacks in the inventory. If the stack after the move isn't empty, it retries to combine the ItemStack into other stacks by calling Container#retrySlotClick, which in turn calls Container#slotClick with the ClickType always being ClickType.QUICK_MOVE until the clicked Slot is empty.

 

It is basically a "brute-force" way of shift-clicking an ItemStack to other stacks the inventory.

Edited by larsgerrits

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

  • Author
18 minutes ago, larsgerrits said:

Inside Container#slotClick, if it's called with ClickType.QUICK_MOVE (shift-click), it calls Container#transferStackIntoSlot. This will try to move the ItemStack to other stacks in the inventory. If the stack after the move isn't empty, it retries to combine the ItemStack into other stacks by calling Container#retrySlotClick, which in turn calls Container#slotClick with the ClickType always being ClickType.QUICK_MOVE until the clicked Slot is empty.

 

It is basically a "brute-force" way of shift-clicking an ItemStack to other stacks the inventory.

Hmm, I see. It seems strange because mergeItemStack (as called by most transferStackInSlot implementations) has a loop in itself, and keeps trying until the stack is empty.

 

Is it probably safe to override it to do nothing, as long as I'm aware of that? It seems that the worst possible outcome is that a stack might sometimes not fully merge when shift-clicked, if it needs to spread between multiple slots in order to transfer - unless I'm missing some other worse implication/s?

Edited by Jay Avery
formatting

I'm pretty sure it's safe to override it to do nothing, as I can't see any other issues which may be caused by overriding it.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

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.