aboutsummaryrefslogtreecommitdiff
path: root/runtime/src/main/java/me/shedaniel/rei/impl/EntryRegistryImpl.java
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2021-02-21 22:33:45 +0800
committershedaniel <daniel@shedaniel.me>2021-02-21 22:33:45 +0800
commita56baa875630ffac06e421a7389854b5301ed7f0 (patch)
tree9469ff3f61f2aca622d6f86dbe8044769198e639 /runtime/src/main/java/me/shedaniel/rei/impl/EntryRegistryImpl.java
parent5eae235995583e378a884a14118095c1fda08fab (diff)
downloadRoughlyEnoughItems-a56baa875630ffac06e421a7389854b5301ed7f0.tar.gz
RoughlyEnoughItems-a56baa875630ffac06e421a7389854b5301ed7f0.tar.bz2
RoughlyEnoughItems-a56baa875630ffac06e421a7389854b5301ed7f0.zip
More
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'runtime/src/main/java/me/shedaniel/rei/impl/EntryRegistryImpl.java')
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/EntryRegistryImpl.java31
1 files changed, 12 insertions, 19 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/EntryRegistryImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/EntryRegistryImpl.java
index d5ff03c28..387f29d82 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/EntryRegistryImpl.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/EntryRegistryImpl.java
@@ -27,13 +27,13 @@ import com.google.common.base.Stopwatch;
import com.google.common.collect.Lists;
import me.shedaniel.rei.RoughlyEnoughItemsCore;
import me.shedaniel.rei.api.ConfigObject;
-import me.shedaniel.rei.api.EntryRegistry;
+import me.shedaniel.rei.api.registry.EntryRegistry;
import me.shedaniel.rei.api.ingredient.EntryStack;
import me.shedaniel.rei.api.ingredient.util.EntryStacks;
+import me.shedaniel.rei.api.util.CollectionUtils;
import me.shedaniel.rei.impl.filtering.FilteringContextImpl;
import me.shedaniel.rei.impl.filtering.FilteringContextType;
import me.shedaniel.rei.impl.filtering.FilteringRule;
-import me.shedaniel.rei.api.util.CollectionUtils;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.core.NonNullList;
@@ -76,11 +76,10 @@ public class EntryRegistryImpl implements EntryRegistry {
@Override
@NotNull
public List<EntryStack<?>> getPreFilteredList() {
- return preFilteredList;
+ return Collections.unmodifiableList(preFilteredList);
}
@Override
- @ApiStatus.Experimental
public void refilter() {
Stopwatch stopwatch = Stopwatch.createStarted();
@@ -124,6 +123,8 @@ public class EntryRegistryImpl implements EntryRegistry {
reloading = true;
}
+ private static final Comparator<ItemStack> STACK_COMPARATOR = (a, b) -> ItemStack.matches(a, b) ? 0 : 1;
+
@NotNull
@Override
public List<ItemStack> appendStacksForItem(@NotNull Item item) {
@@ -131,18 +132,10 @@ public class EntryRegistryImpl implements EntryRegistry {
item.fillItemCategory(item.getItemCategory(), list);
if (list.isEmpty())
return Collections.singletonList(item.getDefaultInstance());
+ list.sort(STACK_COMPARATOR);
return list;
}
- @NotNull
- @Override
- public ItemStack[] getAllStacksFromItem(@NotNull Item item) {
- List<ItemStack> list = appendStacksForItem(item);
- ItemStack[] array = list.toArray(new ItemStack[0]);
- Arrays.sort(array, (a, b) -> ItemStack.matches(a, b) ? 0 : 1);
- return array;
- }
-
@Override
public void registerEntryAfter(@Nullable EntryStack<?> afterEntry, @NotNull EntryStack<?> stack) {
if (reloading) {
@@ -182,20 +175,20 @@ public class EntryRegistryImpl implements EntryRegistry {
}
@Override
- public void removeEntry(EntryStack<?> stack) {
+ public boolean removeEntry(EntryStack<?> stack) {
if (reloading) {
- reloadingRegistry.remove(new AmountIgnoredEntryStackWrapper(stack));
+ return reloadingRegistry.remove(new AmountIgnoredEntryStackWrapper(stack));
} else {
- entries.remove(stack);
+ return entries.remove(stack);
}
}
@Override
- public void removeEntryIf(Predicate<EntryStack<?>> stackPredicate) {
+ public boolean removeEntryIf(Predicate<? extends EntryStack<?>> predicate) {
if (reloading) {
- reloadingRegistry.removeIf(wrapper -> stackPredicate.test(wrapper.unwrap()));
+ return reloadingRegistry.removeIf(wrapper -> ((Predicate<EntryStack<?>>) predicate).test(wrapper.unwrap()));
} else {
- entries.removeIf(stackPredicate);
+ return entries.removeIf((Predicate<EntryStack<?>>) predicate);
}
}
}