Same items are not merged correctly in the storage when storing items
hyodocraft opened this issue ยท 1 comments
Describe the bug
When attempting to store item(s) into the storage, completely ignore the same item in the storage and store the item in the youngest numbered available slot.
As a result, less than 1024(controllerStackSize) items are stored across multiple slots.
To Reproduce
Steps to reproduce the behavior:
-
Place empty Dimensional Storage
-
Store item A in the storage
-
Store item B
-
Remove all items A
-
Store item B further (The slot where item A was stored is used.)
-
There are only small amount of item B, but two slots are occupied.
Expected behavior
When attempting to store item(s) into the storage, the system searches for the same item in the storage, and stores the item preferentially in the slot with the largest stack size among the slots that match.
Screenshots
MC1.16.5-1.28.0 https://streamable.com/icp8ty
MC1.18.2-1.35.5 https://streamable.com/h0pj1x
System (please complete the following information):
- Occultism Version: occultism-1.16.5-1.28.0 / occultism-1.18.2-1.35.5
- OS: Windows 10
- Minecraft Version: 1.16.5 / 1.18.2
- Modpack Link and Version, or list of mods: Enigmatica 6 Expert v1.3.0 (1.16.5) / none (1.18.2)
Additional context
none
This issue is caused by the vanilla item handler helper. It will insert into the first available slot, which is reasonable for performance reasons (if every insert started with a search over every slot hat wouldn't be great).
This can be fixed by implementing our own item handling, but in order to compensate the (high) performance cost of that we'd also need a cache map to quickly find the right slot to insert.
I do not have the time to implement it in an efficient and secure manner (relying on vanilla code has the advantage of having no dupe bugs or quick official fixes for them). At the same time, the urgency seems rather low considering the total amount of storage available and the option to change this via config.
I am going to close this as "wontfix", however I am still open to discuss this further (please ping me so I get a notification), and if someone wants to PR a change I'd also be open to merging that, under the condition that it has been thoroughly vetted in regards to dupe or vanishing bugs.