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/impl/common/category/CategoryIdentifierImpl.java | 2 +- .../common/entry/comparison/NbtHasherProviderImpl.java | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'runtime/src') diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/common/category/CategoryIdentifierImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/common/category/CategoryIdentifierImpl.java index c23ebee80..2b9ed42ed 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/common/category/CategoryIdentifierImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/common/category/CategoryIdentifierImpl.java @@ -32,7 +32,7 @@ import java.util.Objects; import java.util.function.Function; public class CategoryIdentifierImpl implements CategoryIdentifier { - private ResourceLocation location; + private final ResourceLocation location; public CategoryIdentifierImpl(ResourceLocation location) { this.location = Objects.requireNonNull(location); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/comparison/NbtHasherProviderImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/comparison/NbtHasherProviderImpl.java index a3bedba31..17f8bd517 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/comparison/NbtHasherProviderImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/comparison/NbtHasherProviderImpl.java @@ -24,6 +24,8 @@ package me.shedaniel.rei.impl.common.entry.comparison; import com.google.common.base.Predicates; +import me.shedaniel.rei.api.common.entry.comparison.ComparisonContext; +import me.shedaniel.rei.api.common.entry.comparison.EntryComparator; import me.shedaniel.rei.impl.Internals; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; @@ -32,23 +34,21 @@ import org.jetbrains.annotations.Nullable; import java.util.*; import java.util.function.Predicate; -import java.util.function.ToLongFunction; public class NbtHasherProviderImpl implements Internals.NbtHasherProvider { - private final ToLongFunction defaultHasher = _provide(); + private final EntryComparator defaultHasher = _provide(); @Override - public ToLongFunction provide(String... ignoredKeys) { + public EntryComparator provide(String... ignoredKeys) { if (ignoredKeys == null || ignoredKeys.length == 0) return defaultHasher; return _provide(ignoredKeys); } - private ToLongFunction _provide(String... ignoredKeys) { + private EntryComparator _provide(String... ignoredKeys) { return new Hasher(ignoredKeys); } - private static class Hasher implements ToLongFunction { - @Nullable + private static class Hasher implements EntryComparator { private final Predicate filter; private Hasher(@Nullable String[] ignoredKeys) { @@ -66,9 +66,9 @@ public class NbtHasherProviderImpl implements Internals.NbtHasherProvider { private boolean shouldHash(String key) { return filter.test(key); } - + @Override - public long applyAsLong(Tag value) { + public long hash(ComparisonContext context, Tag value) { return hashTag(value); } -- cgit