Applied Energistics 2

Applied Energistics 2

137M Downloads

Reconsider order of extraction from inventories

yueh opened this issue ยท 3 comments

commented

Currently insert and extract both begin with the first slot of any inventory.

In case of inserting items, this is actually beneficial as it will fill existing stacks before using a free slot. With the assumption that the inventory is not manually sorted and free/used slots are scatter all over it.
So it will at least try to avoid some fragementation.

For extracting items it has pretty much to opposite effect. It will cause the inventory to slowly defrag over time, if it is not in massive use. So it can cause it to keep a few small stacks at the end, which are never freed as long as it never extracts every stack of the same item.

This also extends to other machines. Quarries usually fill a buffer chest beginning at the start. Thus it is quite common to have the the start be used for common blocks like stone/cobble and place the more rare materials at the end with a small stacksize and cause the the inventory to slowly fill up, should the extraction speed not be way faster than something inserting new items.

Reversing the order for extracting items, would cause the system to prefer the smaller stacks at the end of an inventory, thus keeping more free slots around. Of course only as long as most machines will insert at the front. If not it would make it obsolete. So it would add a form of defrag to a single inventory similar to how AE already defrags at a network level by prefering inventories with a lower priority for extraction (and the opposite for insertion).

Further it would also keep manually sorted inventories a bit more clean as it would basically extract the stacks created by overflow over the ones placed manually at the start. Which of course only applies to inventories being sorting from left to right and top to bottom usually. Others would certainly be already scattered like now. But the main idea is about the automatic part. Of manually sorted chest might see a potential QoL improvement, it would certainly be nice, but not the major idea behind it.

commented

Not going to implement this. With bulk extraction methods, the inventory itself decides where to extract from.

commented

maybe as an idea, you could stick to the last imported item, and try to find similar items (check the function with fuzzy upgrade) to import first before picking a new slot just by stacksize

commented

Not in terms of stacksize. That would be way too expensive. Just the question about start at with the first or last slot when extracting. Based on my own experience, most inventories tend to simply have smaller stacks located at the end.

Some fuzzy approach with similar items would be way worse. It would mean to scan over every single slot of an inventory to find a similar item and then backtrack. A single storage drawer controller can for example provide up to 15625 slots, which we have to completely scan for every single itemstack being inserted or extracted.
It might still be half ok, would ItemStack.clone() not suck so much thanks to caps. But for now it is simply server destroying.