-
-
Notifications
You must be signed in to change notification settings - Fork 542
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix usage of FluidStack as keys in maps or sets not properly comparing
- Loading branch information
1 parent
dd10f08
commit 9ea3942
Showing
4 changed files
with
36 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/mekanism/common/lib/collection/FluidHashStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package mekanism.common.lib.collection; | ||
|
||
import it.unimi.dsi.fastutil.Hash.Strategy; | ||
import net.neoforged.neoforge.fluids.FluidStack; | ||
|
||
public class FluidHashStrategy implements Strategy<FluidStack> { | ||
|
||
public static final FluidHashStrategy INSTANCE = new FluidHashStrategy(); | ||
|
||
private FluidHashStrategy() { | ||
} | ||
|
||
@Override | ||
public int hashCode(FluidStack stack) { | ||
return FluidStack.hashFluidAndComponents(stack); | ||
} | ||
|
||
@Override | ||
public boolean equals(FluidStack a, FluidStack b) { | ||
return FluidStack.isSameFluidSameComponents(a, b); | ||
} | ||
} |