From 784f6680c19a708485f49a82b7dffdbdda2607fa Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 22 May 2021 02:49:01 +0800 Subject: Simplify code in DefaultCraftingDisplay and NbtHasherProviderImpl --- .../rei/api/common/entry/comparison/EntryComparator.java | 10 +++++----- api/src/main/java/me/shedaniel/rei/impl/Internals.java | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'api/src') diff --git a/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/EntryComparator.java b/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/EntryComparator.java index c40966887..5f491021a 100644 --- a/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/EntryComparator.java +++ b/api/src/main/java/me/shedaniel/rei/api/common/entry/comparison/EntryComparator.java @@ -42,22 +42,22 @@ public interface EntryComparator { } static EntryComparator itemNbt() { - ToLongFunction nbtHasher = nbtHasher("Count"); + EntryComparator nbtHasher = nbt("Count"); return (context, stack) -> { CompoundTag tag = stack.getTag(); - return tag == null ? 0L : nbtHasher.applyAsLong(tag); + return tag == null ? 0L : nbtHasher.hash(context, tag); }; } static EntryComparator fluidNbt() { - ToLongFunction nbtHasher = nbtHasher("Amount"); + EntryComparator nbtHasher = nbt("Amount"); return (context, stack) -> { CompoundTag tag = stack.getTag(); - return tag == null ? 0L : nbtHasher.applyAsLong(tag); + return tag == null ? 0L : nbtHasher.hash(context, tag); }; } - static ToLongFunction nbtHasher(String... ignoredKeys) { + static EntryComparator nbt(String... ignoredKeys) { return Internals.getNbtHasher(ignoredKeys); } diff --git a/api/src/main/java/me/shedaniel/rei/impl/Internals.java b/api/src/main/java/me/shedaniel/rei/impl/Internals.java index c3f131dc6..90e4a03e7 100644 --- a/api/src/main/java/me/shedaniel/rei/impl/Internals.java +++ b/api/src/main/java/me/shedaniel/rei/impl/Internals.java @@ -27,6 +27,7 @@ import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.display.Display; import me.shedaniel.rei.api.common.entry.EntryIngredient; import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.api.common.entry.comparison.EntryComparator; import me.shedaniel.rei.api.common.entry.type.EntryDefinition; import me.shedaniel.rei.api.common.entry.type.EntryType; import me.shedaniel.rei.api.common.plugins.PluginManager; @@ -40,7 +41,6 @@ import org.jetbrains.annotations.ApiStatus; import java.lang.reflect.Field; import java.util.function.Function; import java.util.function.Supplier; -import java.util.function.ToLongFunction; @ApiStatus.Internal public final class Internals { @@ -101,7 +101,7 @@ public final class Internals { return serverPluginManager.get(); } - public static ToLongFunction getNbtHasher(String[] ignoredKeys) { + public static EntryComparator getNbtHasher(String[] ignoredKeys) { return nbtHasherProvider.get().provide(ignoredKeys); } @@ -130,6 +130,6 @@ public final class Internals { } public interface NbtHasherProvider { - ToLongFunction provide(String... ignoredKeys); + EntryComparator provide(String... ignoredKeys); } } -- cgit