Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect equals/hashCode implementation for data components on gear result in gear not being extractable from Refined Storage #753

Open
raoulvdberge opened this issue Dec 7, 2024 · 1 comment
Assignees
Labels
1.21 bug Something isn't working

Comments

@raoulvdberge
Copy link

raoulvdberge commented Dec 7, 2024

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

  1. Create a Refined Storage 2 network with a creative controller, 1k storage block and grid.
  2. Place a silent gear weapon or tool in the grid
  3. The weapon or tool cannot be extracted.
@SilentChaos512
Copy link
Owner

I fixed the implementation of hashCode for PartInstance, but it doesn't seem to have fixed the issue. All of my data components seem to have correct hashCode implementations, so I'm not sure what else to look for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.21 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants