aboutsummaryrefslogtreecommitdiff
path: root/runtime/src/main/java/me/shedaniel/rei/impl/EntryRegistryImpl.java
diff options
context:
space:
mode:
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.java35
1 files changed, 24 insertions, 11 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 387f29d82..354e253f0 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/EntryRegistryImpl.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/EntryRegistryImpl.java
@@ -27,7 +27,8 @@ 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.registry.EntryRegistry;
+import me.shedaniel.rei.api.plugins.REIPlugin;
+import me.shedaniel.rei.api.registry.entry.EntryRegistry;
import me.shedaniel.rei.api.ingredient.EntryStack;
import me.shedaniel.rei.api.ingredient.util.EntryStacks;
import me.shedaniel.rei.api.util.CollectionUtils;
@@ -58,7 +59,23 @@ public class EntryRegistryImpl implements EntryRegistry {
private List<AmountIgnoredEntryStackWrapper> reloadingRegistry;
private boolean reloading;
- public void finishReload() {
+ @Override
+ public void acceptPlugin(REIPlugin plugin) {
+ plugin.registerEntries(this);
+ }
+
+ @Override
+ public void startReload() {
+ entries.clear();
+ if (reloadingRegistry != null)
+ reloadingRegistry.clear();
+ reloadingRegistry = Lists.newArrayListWithCapacity(Registry.ITEM.keySet().size() + 100);
+ preFilteredList.clear();
+ reloading = true;
+ }
+
+ @Override
+ public void endReload() {
reloading = false;
preFilteredList.clear();
reloadingRegistry.removeIf(AmountIgnoredEntryStackWrapper::isEmpty);
@@ -68,6 +85,11 @@ public class EntryRegistryImpl implements EntryRegistry {
}
@Override
+ public int size() {
+ return reloading ? reloadingRegistry.size() : entries.size();
+ }
+
+ @Override
@NotNull
public Stream<EntryStack<?>> getEntryStacks() {
return reloading ? reloadingRegistry.stream().map(AmountIgnoredEntryStackWrapper::unwrap) : entries.stream();
@@ -114,15 +136,6 @@ public class EntryRegistryImpl implements EntryRegistry {
return (Predicate<T>) target.negate();
}
- public void resetToReloadStart() {
- entries.clear();
- if (reloadingRegistry != null)
- reloadingRegistry.clear();
- reloadingRegistry = Lists.newArrayListWithCapacity(Registry.ITEM.keySet().size() + 100);
- preFilteredList.clear();
- reloading = true;
- }
-
private static final Comparator<ItemStack> STACK_COMPARATOR = (a, b) -> ItemStack.matches(a, b) ? 0 : 1;
@NotNull