[fabric] Incompatibility with Storage Drawers mod causing lost items
swe3per opened this issue ยท 8 comments
Describe the bug

Connect the RS terminal to the drawer controller externally, place the coal block in the 2x compression drawer, connect the output cable to the furnace configuration to output the coal, and when the furnace coal is filled to 64, all items in the compression drawer will be emptied.
Storage Drawers-fabric-1.21-13.7.1/13.7.2
How can we reproduce this bug or crash?
Connect the RS terminal to the drawer controller externally, place the coal block in the 2x compression drawer, connect the output cable to the furnace configuration to output the coal, and when the furnace coal is filled to 64, all items in the compression drawer will be emptied.

Storage Drawers-fabric-1.21-13.7.1/13.7.2
What Minecraft version is this happening on?
Minecraft 1.21.1
What NeoForge or Fabric version is this happening on?
0.16.4
What Refined Storage version is this happening on?
refinedstorage-fabric-2.0.0-milestone.4.7.jar
Relevant log output
No response
This was also filed on the SD side and I'm going to look into it as a potential SD issue.
But given the complex packaging of this mod, would any RS devs offer some guidance in how I can pull this mod into my IDE environment? A modImplementation against the main fabric jar doesn't seem sufficient .. I'm not sure it handles the embedded jars correctly.
There's a discord in the readme, you're more likely to get realtime help there.
Also there's only like 1.5 RS devs, it's all raoul, and darkere helps a bit with tests and stuff
Hi @jaquadro, you can check an example of an addon mod including RS here:
You also need to add the maven repository from L6-11.
I'll also try to reproduce this on my end, because chances are high this is an RS issue.
Thanks for the tip. I'm tied up for the next week so I'll look at it after, unless you determine it to be an RS issue before then.
@jaquadro I've been debugging this, and at first sight it appears like a Storage Drawers issue.
It's fairly easy to repro like this:

Just put 1 coal in the drawer, and try to extract it from the grid. You'll see it extracts nothing and just voids the resource.
I've been debugging in FabricStorageExtractableStorage (which is the class in Refined Storage that is responsible for eventually extracting from the connected inventory) and I'm noticing the following:
- The
#extractmethod in there is called twice, once withAction.SIMULATEandAction.EXECUTE(https://github.com/refinedmods/refinedstorage2/blob/develop/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/storage/FabricStorageExtractableStorage.java#L39) - Only when it's
Action.EXECUTEdoes the transaction get committed: https://github.com/refinedmods/refinedstorage2/blob/develop/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/storage/FabricStorageExtractableStorage.java#L66 - The first time, with
Action.SIMULATEthe value ofextractis 1 (https://github.com/refinedmods/refinedstorage2/blob/develop/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/storage/FabricStorageExtractableStorage.java#L64) - The second time, with
Action.EXECUTE, the value ofextractis 0 (https://github.com/refinedmods/refinedstorage2/blob/develop/refinedstorage-fabric/src/main/java/com/refinedmods/refinedstorage/fabric/storage/FabricStorageExtractableStorage.java#L64)
I'm thinking it's not respecting the transaction rollback or something?
Hope this helps a bit with your further investigation.
(FYI You should also be able to just dump the RS2 Fabric jar in your mods/ folder in dev - I've done the same for Storage Drawers and it seemed to have worked)
A few suspicious things I've noticed in the SD code:
- https://github.com/jaquadro/StorageDrawers/blob/1.21/fabric/src/main/java/com/jaquadro/minecraft/storagedrawers/inventory/DrawerGroupStorage.java#L27
- Always creating a new
DrawerStorage? Is that allowed, will it keep track of the snapshot & transaction properly?
- Always creating a new
- https://github.com/jaquadro/StorageDrawers/blob/1.21/fabric/src/main/java/com/jaquadro/minecraft/storagedrawers/inventory/DrawerStorage.java#L26
- I don't think this is needed. Per the docs:
-
When an outer transaction is committed, readSnapshot will not be called so that the current state of this participant is retained.
-
- I don't think this is needed. Per the docs:
The fabric support is very new and only tested against hoppers so far, so not really a surprise if I've got something wrong. I'll take a closer look at your leads when I'm back in a week, thanks for providing them.
As for the FYI at the end, I did think to try this, and then I specifically didn't because I remember it used to be an issue with this mis-mapping in names. But I'm pleasantly surprised to see it's working, and it is unpacking the internal jars correctly which the flatmap repo wasn't doing.