Working on some naive lectern slot caching that should fix some server killing cases when automating in/out of the lectern. Not everything can be optimized as neoforge doesn't provide common mod interfaces to fully solve it, but improvements for insertions can easily be optimized completely away.
Current changes:
- Caches the list of slots for an item/empty slot when an item is inserted
- Uses the list of slots on subsequent inserts, checks that the item in that slot is still the same item, then fills those slots with that item until there are no more stacks left, or there is no more room.
- If there is still part of an item remaining, it falls back to the empty slot list and inserts there.
- If there are no empty slots remaining/in the cache, it falls back to the current behavior of iterating across the inventory looking for valid spots to insert the item.
The pros:
- Inserting an item a second time is immediate as long as there is room or an empty slot is available
- Inter-mod export can also be optimized, wixies and starbuncles benefit, but other modded extractions would not.
Cons:
- Items will insert at 'random' places in the chest if it falls back to an empty slot, not consistent with expected behavior like how it works today.
- If inventory is completely full, the fallback behavior of checking everything all the time comes back.
- Manipulation of the inventory outside of the lectern will exacterbate the randomness problem as there is no way to know that the inventories of a monitored inventory have changed without other performance costs.