Andrews54757/itemscroller-crafting-fix

Scrolling matching items to other inventory is unusably slow and sometimes runs out of memory

vlad2305m opened this issue · 0 comments

(relay up the fork network if applicable)
For certain items (like shulkers), isEqual check is VERY expensive, and this code uses it like it's the cheapest thing in the world.

// Failed to shift-click items, try a manual method

Reproduction:

  1. Have ~20 shulker boxes of pistons in your inventory
  2. Open a double chest with ~40 of the same boxes in it
  3. Try to alt scroll (possibly multiple times at once by accident) and observe extreme lag and possibly a crash.

Suggestion:
For starters you could just check that the reference item is unstackable, so there is no point in many of those checks. Futher, you could check that the destination slot is full to skip[checks. Shift click checks and manual move checks are so expensive with shulkers that I can literally see them being performed at ~50/second, so it is a bad idea to do them if something easier can fail earlier.