AE2-UEL / Applied-Energistics-2

AE2UEL, a Fork of a Minecraft Mod about Matter, Energy and using them to conquer the world.
https://legacy.curseforge.com/minecraft/mc-mods/ae2-extended-life
Other
74 stars 71 forks source link

Interfaces can pull unpartitioned items through storage busses #408

Closed SocksGalore closed 3 months ago

SocksGalore commented 6 months ago

Describe the bug

It is possible for an interface to pull items through a storage bus that is partitioned against it if another source of that item is on the network, even when that other source is consumed, it seems that once an interface starts pulling the disallowed items, it can continue until it runs out of items to pull. I first noticed this happening with one of my subnetworks, but it seems to be able to happen with any ME storage bus. I haven't tested fluid or ore dict buses.

To Reproduce

Make a network with a storage bus filtered for item A, connected to storage containing items A and B. if you add an interface and request item B, it will not pull it in, however, if you place another storage bus, and add some of item B to its storage, the interface will start pulling item B from both locations, until both run out. See video in additional context.

Expected behavior

Storage buses should only be able to import/export their partitioned items, regardless of what else is on the network.

Additional context

Video demonstration:

https://github.com/AE2-UEL/Applied-Energistics-2/assets/37392824/43996a4e-fbc6-471f-8f8d-8284c2e27c04

Environment

SocksGalore commented 6 months ago

Well I really didn't feel like redoing my subnets, so I dug around and found a dirty fix for this. In MEInventoryHandler#extractItems I replaced canExtract() with shouldItemBeAvailable() which does the same thing but also checks the whitelist. As so,

public T extractItems(final T request, final Actionable type, final IActionSource src) {
    if (!this.shouldItemBeAvailable(request)) {
        return null;
    }
   ...

Didn't put in a PR, I've never touched mod dev before so I'm sure there's probably a better solution, might help someone as a starting point though. I'll leave the issue open so it can get a proper fix.