Mekanism Tools

Mekanism Tools

87M Downloads

Mekanism Logistical Sorter does not respect Storage Drawers Stack Downgrade

Paul-Moura opened this issue · 5 comments

commented

Issue description

Affected Mods:

  • Storage Drawers (by Texelsaur / jaquadro)
  • Mekanism (by bradyaidanc)
  • Techopolis 3 (modpack integration issue)

⚠️ Observed Behavior

When the downgraded drawer has less than 1 stack, the Logistical Sorter attempts to send 32 stacks, not 1.
The downgraded drawer accepts only the first stack.
The remaining 31 stacks are rejected and sent back, causing:

  • Pipeline congestion
  • Possible looped routing behavior
  • TPS or performance hits under high traffic

✅ Expected Behavior
The Logistical Sorter should respect the actual item capacity of the target inventory (in this case, 1 stack).
It should only send up to the remaining available amount (e.g., a partial stack or none if full).
This is critical when Storage Drawers are used as filters or gates.

📋 Additional Context
This interaction may be affected by how Mekanism queries inventory capabilities (IItemHandler or ISidedInventory).
Storage Drawers handle capacity constraints at the drawer logic level, not necessarily at the reported interface level — this may be why Mekanism sees the default 32 stack capacity instead of the downgraded limit.
Downgrades modify behavior server-side, not via metadata that other mods can always read correctly.

💡 Suggested Fix (Developer-side)
Either:
Storage Drawers should expose downgrade-altered capacity via standard inventory APIs
Or Mekanism should attempt to insert a test item before queuing bulk transfers, or limit transfer size to simulateInsert() results

Steps to reproduce

  1. Place a Storage Drawer with a Stack Downgrade to limit the drawer to 1 stack.
  2. Insert a single item into the downgraded drawer and lock the drawer.
  3. Place a second drawer with an Iron Upgrade to hold 128 stacks.
  4. Fill the upgraded drawer with the same item and lock the drawer.
  5. Connect a Mekanism Logistical Sorter to the upgraded drawer:
  6. Set a filter to match the item.
  7. Set the destination color to red.
  8. Enable Size Mode.
  9. Set the Min/Max to 64.
  10. Connect Logistical Transport Pipes from the Logistical Sorter to the downgraded drawer.
  11. Color the connection red at the downgraded drawer

Minecraft version

1.21.1 (Latest)

NeoForge version

47.4.0

Mekanism version

10.7.14 (Latest)

Other relevant versions

No response

If a (crash)log is relevant for this issue, link it here: (It's almost always relevant)

No response

commented

This is likely on storage drawers' side, as any transfers are simulated first, and it sounds like sd is reporting that it would accept the full amount.

commented

I think you're right but opened a ticket for both mods, just in case. Thanks for the hasty response.

commented

@thiakil
To ensure this is in fact StorageDrawers' bug, I'm trying to identify it myself, but I need to know how your code is trying to interact and I'm having trouble finding the code that simulates the transfer. Can you reference that here?

commented

I meant to leave this open until I do a double check of our code, seems I left that out of my comment somehow