From 542eb5154ebce387312ca3691f743b89e4aef99e Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 27 Feb 2021 17:14:08 +0800 Subject: Remove depending on Cloth API, switching to architectury Signed-off-by: shedaniel --- .../me/shedaniel/rei/impl/EntryRegistryImpl.java | 35 +++++++++++++++------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'runtime/src/main/java/me/shedaniel/rei/impl/EntryRegistryImpl.java') 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 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); @@ -67,6 +84,11 @@ public class EntryRegistryImpl implements EntryRegistry { reloadingRegistry = null; } + @Override + public int size() { + return reloading ? reloadingRegistry.size() : entries.size(); + } + @Override @NotNull public Stream> getEntryStacks() { @@ -114,15 +136,6 @@ public class EntryRegistryImpl implements EntryRegistry { return (Predicate) 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 STACK_COMPARATOR = (a, b) -> ItemStack.matches(a, b) ? 0 : 1; @NotNull -- cgit