diff options
| author | shedaniel <daniel@shedaniel.me> | 2020-07-15 22:27:07 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2020-07-15 22:27:07 +0800 |
| commit | cd57003454840efd74ef072072402ea3822ab2ba (patch) | |
| tree | 481af32e3a330d48eba88e1fa4c4fa5a976f5377 /src/main/java/me/shedaniel/rei/impl | |
| parent | 7d1e39007a1e7de6fd0381fa1e21cf9b6e927f97 (diff) | |
| download | RoughlyEnoughItems-cd57003454840efd74ef072072402ea3822ab2ba.tar.gz RoughlyEnoughItems-cd57003454840efd74ef072072402ea3822ab2ba.tar.bz2 RoughlyEnoughItems-cd57003454840efd74ef072072402ea3822ab2ba.zip | |
Close #322
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'src/main/java/me/shedaniel/rei/impl')
4 files changed, 44 insertions, 7 deletions
diff --git a/src/main/java/me/shedaniel/rei/impl/DisplayHelperImpl.java b/src/main/java/me/shedaniel/rei/impl/DisplayHelperImpl.java index a4132e043..99411bb34 100644 --- a/src/main/java/me/shedaniel/rei/impl/DisplayHelperImpl.java +++ b/src/main/java/me/shedaniel/rei/impl/DisplayHelperImpl.java @@ -159,9 +159,11 @@ public class DisplayHelperImpl implements DisplayHelper { screenDisplayBoundsHandlers.clear(); } - @ApiStatus.Internal + @ApiStatus.Experimental + @Override public void resetCache() { handlerCache.clear(); + deciderSortedCache.clear(); handlerSortedCache.clear(); } diff --git a/src/main/java/me/shedaniel/rei/impl/EntryRegistryImpl.java b/src/main/java/me/shedaniel/rei/impl/EntryRegistryImpl.java index fcc62fe23..b4849b4e9 100644 --- a/src/main/java/me/shedaniel/rei/impl/EntryRegistryImpl.java +++ b/src/main/java/me/shedaniel/rei/impl/EntryRegistryImpl.java @@ -42,6 +42,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.*; +import java.util.function.Predicate; import java.util.stream.Stream; @ApiStatus.Internal @@ -82,6 +83,8 @@ public class EntryRegistryImpl implements EntryRegistry { return preFilteredList; } + @Override + @ApiStatus.Experimental public void refilter() { long started = System.currentTimeMillis(); @@ -155,4 +158,30 @@ public class EntryRegistryImpl implements EntryRegistry { } else entries.addAll(stacks); } } + + @Override + public boolean alreadyContain(EntryStack stack) { + if (reloading) { + return reloadingRegistry.parallelStream().anyMatch(s -> s.unwrap().equalsAll(stack)); + } + return entries.parallelStream().anyMatch(s -> s.equalsAll(stack)); + } + + @Override + public void removeEntry(EntryStack stack) { + if (reloading) { + reloadingRegistry.remove(new AmountIgnoredEntryStackWrapper(stack)); + } else { + entries.remove(stack); + } + } + + @Override + public void removeEntryIf(Predicate<EntryStack> stackPredicate) { + if (reloading) { + reloadingRegistry.removeIf(wrapper -> stackPredicate.test(wrapper.unwrap())); + } else { + entries.removeIf(stackPredicate); + } + } } diff --git a/src/main/java/me/shedaniel/rei/impl/RecipeHelperImpl.java b/src/main/java/me/shedaniel/rei/impl/RecipeHelperImpl.java index 60f01a738..b9d23b679 100644 --- a/src/main/java/me/shedaniel/rei/impl/RecipeHelperImpl.java +++ b/src/main/java/me/shedaniel/rei/impl/RecipeHelperImpl.java @@ -365,7 +365,7 @@ public class RecipeHelperImpl implements RecipeHelper { ((SubsetsRegistryImpl) SubsetsRegistry.INSTANCE).reset(); ((FluidSupportProviderImpl) FluidSupportProvider.INSTANCE).reset(); ((DisplayHelperImpl) DisplayHelper.getInstance()).resetData(); - ((DisplayHelperImpl) DisplayHelper.getInstance()).resetCache(); + DisplayHelper.getInstance().resetCache(); BaseBoundsHandler baseBoundsHandler = new BaseBoundsHandlerImpl(); DisplayHelper.getInstance().registerHandler(baseBoundsHandler); ((DisplayHelperImpl) DisplayHelper.getInstance()).setBaseBoundsHandler(baseBoundsHandler); @@ -443,8 +443,8 @@ public class RecipeHelperImpl implements RecipeHelper { endSection(sectionData); // Clear Cache - ((DisplayHelperImpl) DisplayHelper.getInstance()).resetCache(); - ScreenHelper.getOptionalOverlay().ifPresent(overlay -> overlay.shouldReInit = true); + DisplayHelper.getInstance().resetCache(); + REIHelper.getInstance().getOverlay().ifPresent(REIOverlay::queueReloadOverlay); startSection(sectionData, "entry-registry-finalise"); @@ -455,14 +455,14 @@ public class RecipeHelperImpl implements RecipeHelper { startSection(sectionData, "entry-registry-refilter"); arePluginsLoading = false; - ((EntryRegistryImpl) EntryRegistry.getInstance()).refilter(); + EntryRegistry.getInstance().refilter(); endSection(sectionData); startSection(sectionData, "finalizing"); // Clear Cache Again! - ((DisplayHelperImpl) DisplayHelper.getInstance()).resetCache(); - ScreenHelper.getOptionalOverlay().ifPresent(overlay -> overlay.shouldReInit = true); + DisplayHelper.getInstance().resetCache(); + REIHelper.getInstance().getOverlay().ifPresent(REIOverlay::queueReloadOverlay); displayVisibilityHandlers.sort(VISIBILITY_HANDLER_COMPARATOR); endSection(sectionData); diff --git a/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java b/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java index 7068e15ce..e1c4da05c 100644 --- a/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java +++ b/src/main/java/me/shedaniel/rei/impl/ScreenHelper.java @@ -34,6 +34,7 @@ import me.shedaniel.rei.RoughlyEnoughItemsState; import me.shedaniel.rei.api.ConfigManager; import me.shedaniel.rei.api.ConfigObject; import me.shedaniel.rei.api.REIHelper; +import me.shedaniel.rei.api.REIOverlay; import me.shedaniel.rei.api.widgets.Tooltip; import me.shedaniel.rei.gui.ContainerScreenOverlay; import me.shedaniel.rei.gui.OverlaySearchField; @@ -143,6 +144,11 @@ public class ScreenHelper implements ClientModInitializer, REIHelper { return Optional.ofNullable(overlay); } + @Override + public Optional<REIOverlay> getOverlay() { + return Optional.ofNullable(overlay); + } + public static ContainerScreenOverlay getLastOverlay(boolean reset, boolean setPage) { if (overlay == null || reset) { overlay = new ContainerScreenOverlay(); |
