desht / ModularRouters

A Forge Mod for item routers with pluggable modules
16 stars 20 forks source link

Duplication / voiding glitch #184

Closed NielsPilgaard closed 1 year ago

NielsPilgaard commented 1 year ago

Describe the bug

Taken from https://github.com/EnigmaticaModpacks/Enigmatica6/issues/5369

Routers can sometimes pull from or push to inventories that aren't there any more, duplicating or voiding items.

Example 1 (duplication): Place two routers. Put some items in Router 2. Set Router 1 to pull from Router 2, then quickly cardboard box Router 2. Router 1 will continue pulling the stack of items from the cardboard box. After it's done, you can unbox Router 2 and the items will still be in there.

image

Example 2 (duplication): Place a router and an RFTools crafter. Put some items in the output slot of the crafter, and set the router to pull from it. Then, break the crafter. The router will continue pulling the stack of items from thin air.

image

Example 3 (voiding): Place two routers. Put some items in Router 1 and set it to send the items to Router 2. Break Router 2. Router 1 will continue sending the stack of items into thin air.

image

Just breaking the router in Example 1 doesn't cause the glitch. In 2 and 3, using any old inventory like drawers or an alchemy table doesn't cause the glitch. The RFTools crafter works for 2 and both the crafter or a router work for 3. There might be more machines that act like that, I'm not sure.

How to reproduce the bug

See above

Expected behavior

No duping or voiding.

Additional details

No response

Which Minecraft version are you using?

1.16

Crash log

No response

desht commented 1 year ago

Modular Routers does cache the item (and energy) capabilities for the its module targets, for performance reasons, but it also specifically adds a listener for capability invalidation. So if the capability is properly invalidated, it will be ejected from the cache.

What appears to be happening here is the mods in question (Mekanism and RFTools) aren't properly invalidating their capabilities, so Modular Routers can't know that they're no longer present. As you can see from your testing, the caps are correctly invalidated by drawers, the alchemy table and Modular Routers itself (you are on the latest 1.16 release, right?). So this is a problem with those other mods.

desht commented 1 year ago

Update: just realised that the update for router capability invalidation didn't make it into the last 1.16.5 release (7.5.3), oops. I'll get a 7.5.4 release done, which will fix the problem for when a router is broken. The RFTools crafter and Mek cardboard box problems are on those mods, though.

NielsPilgaard commented 1 year ago

Thanks :D

desht commented 1 year ago

Fixed in 7.5.4 release (at least the part I can fix).