diff options
Diffstat (limited to 'api/src/main/java')
5 files changed, 42 insertions, 18 deletions
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 f51361164..650877ce3 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 @@ -51,7 +51,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; public class SimpleDisplayRenderer extends DisplayRenderer implements WidgetHolder { - protected static final Comparator<EntryStack<?>> ENTRY_COMPARATOR = Comparator.comparingLong(EntryStacks::hashExact); protected static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/recipecontainer.png"); protected List<Slot> inputWidgets; protected List<Slot> outputWidgets; diff --git a/api/src/main/java/me/shedaniel/rei/api/client/registry/entry/EntryRegistry.java b/api/src/main/java/me/shedaniel/rei/api/client/registry/entry/EntryRegistry.java index 6c439a43c..b4d206910 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/registry/entry/EntryRegistry.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/registry/entry/EntryRegistry.java @@ -183,4 +183,14 @@ public interface EntryRegistry extends Reloadable<REIClientPlugin> { * @return whether it was successful to remove any entry */ boolean removeEntryExactHashIf(LongPredicate predicate); + + /** + * Removes entries from the entry list, if it matches the predicate. + * This method is usually faster than {@link #removeEntryIf(Predicate)} + * due to its fast comparison. + * + * @param predicate a predicate which returns {@code true} for the entries to be removed + * @return whether it was successful to remove any entry + */ + boolean removeEntryFuzzyHashIf(LongPredicate predicate); } diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/ComparisonContext.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/ComparisonContext.java index 8e2917dbc..1094a88e3 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/ComparisonContext.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/ComparisonContext.java @@ -25,11 +25,21 @@ package me.shedaniel.rei.api.common.entry.comparison; public enum ComparisonContext { /** - * Should only compare the type of the object, normalized stacks may still not be the same. + * Should only compare the type of the object. + * <p> + * The fuzzy context type denotes that the equivalent stacks should be <b>primarily</b> the same. + * <p> + * For example, enchantment books of different enchantments should be different within this context, + * while tools with different damage values and different enchantments should be treated as the same within this context. + * Skulker boxes with different content should be different within this context. */ FUZZY(false), /** - * Should compare the nbt and the type of the object, normalized stacks should be exactly the same. + * Should compare the nbt and the type of the object. + * <p> + * The exact context type denotes that the equivalent stacks should be <b>functionally</b> the same. + * <p> + * For example, tools with different damage values and different enchantments should be treated as different within this context. */ EXACT(true); diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/EntryComparatorRegistry.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/EntryComparatorRegistry.java index 7c051bac1..fecdabacf 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/EntryComparatorRegistry.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/EntryComparatorRegistry.java @@ -30,9 +30,6 @@ import me.shedaniel.rei.api.common.registry.Reloadable; * Registry for registering custom methods for identifying variants of {@link T}. * The default comparator is {@link EntryComparator#noop()} when fuzzy, which does not compare the NBT of the entries; * and nbt when exact. - * - * <p> - * This comparator is used when the comparison context is {@link ComparisonContext#EXACT}. */ public interface EntryComparatorRegistry<T, S> extends Reloadable<REIPlugin<?>> { void register(EntryComparator<T> comparator, S entry); 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 8f74960d7..672a39b47 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 @@ -116,10 +116,11 @@ public final class EntryStacks { } /** - * Compares equality for the {@link ComparisonContext#EXACT} context, stacks that equal should share the same normalized stack. + * Compares equality for the {@link ComparisonContext#EXACT} context. * <p> - * For example, enchantment books of different enchantments will not be equal under this context. - * However, difference between the amount of objects in a stack will not affect the result. + * The exact context type denotes that the equivalent stacks should be <b>functionally</b> the same. + * <p> + * For example, tools with different damage values and different enchantments should be treated as different within this context. * * @param left the first stack to compare * @param right the second stack to compare @@ -130,10 +131,13 @@ public final class EntryStacks { } /** - * Compares equality for the {@link ComparisonContext#FUZZY} context, stacks that equal may not share the same normalized stack. - * This result is less specific, mainly used for fuzzy matching between different stacks. + * Compares equality for the {@link ComparisonContext#FUZZY} context. + * <p> + * The fuzzy context type denotes that the equivalent stacks should be <b>primarily</b> the same. * <p> - * For example, enchantment books of different enchantments should still be equal under this context. + * For example, enchantment books of different enchantments should be different within this context, + * while tools with different damage values and different enchantments should be treated as the same within this context. + * Skulker boxes with different content should be different within this context. * * @param left the first stack to compare * @param right the second stack to compare @@ -156,10 +160,11 @@ public final class EntryStacks { } /** - * Hash Code of the {@link ComparisonContext#EXACT} context, stacks with the same hash code should share the same normalized stack. + * Hash Code of the {@link ComparisonContext#EXACT} context. * <p> - * For example, enchantment books of different enchantments will not receive the same hash code under this context. - * However, difference between the amount of objects in a stack will not affect the hash code. + * The exact context type denotes that the equivalent stacks should be <b>functionally</b> the same. + * <p> + * For example, tools with different damage values and different enchantments should be treated as different within this context. * * @param stack the stack to hash code * @param <T> the type of the stack @@ -171,10 +176,13 @@ public final class EntryStacks { } /** - * Hash Code of the {@link ComparisonContext#FUZZY} context, stacks with the same hash code may not share the same normalized stack. - * This hash is less specific, mainly used for fuzzy matching between different stacks. + * Hash Code of the {@link ComparisonContext#FUZZY} context. + * <p> + * The fuzzy context type denotes that the equivalent stacks should be <b>primarily</b> the same. * <p> - * For example, enchantment books of different enchantments should still receive the same hash code under this context. + * For example, enchantment books of different enchantments should be different within this context, + * while tools with different damage values and different enchantments should be treated as the same within this context. + * Skulker boxes with different content should be different within this context. * * @param stack the stack to hash code * @param <T> the type of the stack |
