From 096a01c606f491f2bb7a07c3df8ac83f6d313086 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Mon, 29 Mar 2021 00:29:50 +0800 Subject: Use long for hashing the EntryStack Signed-off-by: shedaniel --- .../java/me/shedaniel/rei/api/client/favorites/FavoriteEntry.java | 4 ++-- .../me/shedaniel/rei/api/client/gui/SimpleDisplayRenderer.java | 8 ++++---- .../me/shedaniel/rei/api/common/entry/type/EntryDefinition.java | 2 +- .../main/java/me/shedaniel/rei/api/common/util/EntryStacks.java | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'api/src/main/java/me') diff --git a/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntry.java b/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntry.java index 9ca3b960e..662338b0c 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntry.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/favorites/FavoriteEntry.java @@ -76,7 +76,7 @@ public abstract class FavoriteEntry { return Optional.empty(); } - public abstract int hashIgnoreAmount(); + public abstract long hashIgnoreAmount(); public abstract FavoriteEntry copy(); @@ -96,7 +96,7 @@ public abstract class FavoriteEntry { public int hashCode() { int result = 1; result = 31 * result + getType().hashCode(); - result = 31 * result + hashIgnoreAmount(); + result = 31 * result + Long.hashCode(hashIgnoreAmount()); return result; } diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/SimpleDisplayRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/SimpleDisplayRenderer.java index 9765edb99..c4b2205ae 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/gui/SimpleDisplayRenderer.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/SimpleDisplayRenderer.java @@ -24,8 +24,8 @@ package me.shedaniel.rei.api.client.gui; import com.mojang.blaze3d.vertex.PoseStack; -import it.unimi.dsi.fastutil.ints.IntOpenHashSet; -import it.unimi.dsi.fastutil.ints.IntSet; +import it.unimi.dsi.fastutil.longs.LongOpenHashSet; +import it.unimi.dsi.fastutil.longs.LongSet; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.widgets.Slot; @@ -84,12 +84,12 @@ public class SimpleDisplayRenderer extends DisplayRenderer implements WidgetHold } public static boolean equalsList(EntryIngredient left, EntryIngredient right) { - IntSet leftBytes = new IntOpenHashSet(left.size()); + LongSet leftBytes = new LongOpenHashSet(left.size()); for (EntryStack entryStack : left) { leftBytes.add(EntryStacks.hashExact(entryStack)); } if (leftBytes.size() > right.size()) return false; - IntSet rightBytes = new IntOpenHashSet(right.size()); + LongSet rightBytes = new LongOpenHashSet(right.size()); for (EntryStack entryStack : right) { rightBytes.add(EntryStacks.hashExact(entryStack)); diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryDefinition.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryDefinition.java index 04ea05d7f..2b41f0cd7 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryDefinition.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/type/EntryDefinition.java @@ -59,7 +59,7 @@ public interface EntryDefinition { T normalize(EntryStack entry, T value); - int hash(EntryStack entry, T value, ComparisonContext context); + long hash(EntryStack entry, T value, ComparisonContext context); boolean equals(T o1, T o2, ComparisonContext context); diff --git a/api/src/main/java/me/shedaniel/rei/api/common/util/EntryStacks.java b/api/src/main/java/me/shedaniel/rei/api/common/util/EntryStacks.java index 58cf1ada5..c8b1b86e9 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/util/EntryStacks.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/util/EntryStacks.java @@ -157,7 +157,7 @@ public final class EntryStacks { * @param the type of the stack * @return the hash code of the {@link ComparisonContext#EXACT} context */ - public static int hashExact(EntryStack stack) { + public static long hashExact(EntryStack stack) { return stack.getDefinition().hash(stack, stack.getValue(), ComparisonContext.EXACT); } @@ -171,7 +171,7 @@ public final class EntryStacks { * @param the type of the stack * @return the hash code of the {@link ComparisonContext#FUZZY} context */ - public static int hashFuzzy(EntryStack stack) { + public static long hashFuzzy(EntryStack stack) { return stack.getDefinition().hash(stack, stack.getValue(), ComparisonContext.FUZZY); } -- cgit