Incorrect equals/hashCode implementation for data components on gear result in gear not being extractable from Refined Storage
raoulvdberge opened this issue ยท 3 comments
Versions
- Silent Gear: silent-gear-1.21.1-neoforge-4.0.9.jar
- Silent Lib: silent-lib-1.21-neoforge-10.3.0.jar
- Forge: 21.1.1 (Minecraft 1.21.1)
- Optifine Installed: No
Actual Behavior
In Refined Storage 2, when the player requests a resource to be extracted from the Grid, it does so by sending the item & components from client to server.
It then relies on equals
/hashCode
on the data component map to extract the exact stack being requested.
However, the example stack being sent over the wire to be extracted yields another hashCode
than the exact same stack in storage.
I have not investigated very deep - just comparing the #toString
of the stacks (which is the same) with the hashCode
result (which is different).
(After a first check I see https://github.com/SilentChaos512/Silent-Gear/blob/1.21.x/src/main/java/net/silentchaos512/gear/gear/part/PartInstance.java#L277 - which relies on hashCode
of ItemStack
- which is not implemented, that returns object identity which is unpredictable)
This results in the item not being able to be extracted, since it couldn't be found, even if the data components are the same.
Note: This causes a problem in RS, but it's not RS specific, this will/can have problems in other mods relying on stack equality too.
Person having this issue: refinedmods/refinedstorage2#735
Expected Behavior
The stack being able to be extracted.
Steps to Reproduce the Problem
- Create a Refined Storage 2 network with a creative controller, 1k storage block and grid.
- Place a silent gear weapon or tool in the grid
- The weapon or tool cannot be extracted.