aboutsummaryrefslogtreecommitdiff
path: root/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/FluidEntryStack.java
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2020-08-05 17:14:07 +0800
committershedaniel <daniel@shedaniel.me>2020-08-05 17:14:07 +0800
commit8a2df51193fd3db145f3b1ace974e9e0a0bc09a5 (patch)
tree894244ea7e84d9bd78748e4e295e528cfc9e7979 /RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/FluidEntryStack.java
parent1ce5ca77bc2f98df6cc370c96547c2c39c1fd897 (diff)
downloadRoughlyEnoughItems-8a2df51193fd3db145f3b1ace974e9e0a0bc09a5.tar.gz
RoughlyEnoughItems-8a2df51193fd3db145f3b1ace974e9e0a0bc09a5.tar.bz2
RoughlyEnoughItems-8a2df51193fd3db145f3b1ace974e9e0a0bc09a5.zip
REI 5.1.0:
- Improve auto crafting, now able to detect things on the grid - Introduce getResultingEntries as a replacement for getOutputEntries, it can now handle lists of lists of stacks - Caching for fluid hashing - Full fractions support for simple recipe display - Made searchFavorites defaulted false Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/FluidEntryStack.java')
-rw-r--r--RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/FluidEntryStack.java26
1 files changed, 17 insertions, 9 deletions
diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/FluidEntryStack.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/FluidEntryStack.java
index 8a7c395dd..d75deeda5 100644
--- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/FluidEntryStack.java
+++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/FluidEntryStack.java
@@ -65,6 +65,8 @@ public class FluidEntryStack extends AbstractEntryStack {
private static final Fraction IGNORE_AMOUNT = Fraction.of(ThreadLocalRandom.current().nextLong(), ThreadLocalRandom.current().nextLong(Long.MAX_VALUE)).simplify();
private Fluid fluid;
private Fraction amount;
+ private int hashIgnoreAmount;
+ private int hash;
public FluidEntryStack(Fluid fluid) {
this(fluid, IGNORE_AMOUNT);
@@ -73,6 +75,15 @@ public class FluidEntryStack extends AbstractEntryStack {
public FluidEntryStack(Fluid fluid, Fraction amount) {
this.fluid = fluid;
this.amount = amount;
+
+ rehash();
+ }
+
+ private void rehash() {
+ hashIgnoreAmount = 31 + getType().ordinal();
+ hashIgnoreAmount = 31 * hashIgnoreAmount + fluid.hashCode();
+
+ hash = 31 * hashIgnoreAmount + amount.hashCode();
}
@Override
@@ -96,6 +107,8 @@ public class FluidEntryStack extends AbstractEntryStack {
if (isEmpty()) {
fluid = Fluids.EMPTY;
}
+
+ rehash();
}
private <T extends Comparable<T>> T max(T o1, T o2) {
@@ -157,27 +170,22 @@ public class FluidEntryStack extends AbstractEntryStack {
@Override
public int hashOfAll() {
- int result = hashIgnoreAmountAndTags();
- result = 31 * result + amount.hashCode();
- return result;
+ return hash;
}
@Override
public int hashIgnoreAmountAndTags() {
- int result = 1;
- result = 31 * result + getType().ordinal();
- result = 31 * result + fluid.hashCode();
- return result;
+ return hashIgnoreAmount;
}
@Override
public int hashIgnoreTags() {
- return hashOfAll();
+ return hash;
}
@Override
public int hashIgnoreAmount() {
- return hashIgnoreAmountAndTags();
+ return hashIgnoreAmount;
}
@Nullable