aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2024-09-17 13:47:41 +0800
committershedaniel <daniel@shedaniel.me>2024-09-17 13:50:51 +0800
commit27e06fad89867281ef7d7bcebff194633812c9da (patch)
tree03d1830628e7b46b7f94e01ce72cf954e2a2722f
parent7b5ed400a9bb5a26013441a7ca5589ca30803abd (diff)
parentb8d0975527d86b79a1f9c160415baf8a6e6cf5cb (diff)
downloadRoughlyEnoughItems-27e06fad89867281ef7d7bcebff194633812c9da.tar.gz
RoughlyEnoughItems-27e06fad89867281ef7d7bcebff194633812c9da.tar.bz2
RoughlyEnoughItems-27e06fad89867281ef7d7bcebff194633812c9da.zip
Merge remote-tracking branch 'origin/9.x-1.19' into 11.x-1.19.4
# Conflicts: # fabric/src/main/resources/roughlyenoughitems.accessWidener # forge/src/main/resources/META-INF/accesstransformer.cfg
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Slot.java6
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/plugins/PluginView.java21
-rw-r--r--api/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginReloadContext.java48
-rw-r--r--api/src/main/java/me/shedaniel/rei/impl/common/plugins/ReloadInterruptionContext.java63
-rw-r--r--fabric/src/main/resources/roughlyenoughitems.accessWidener4
-rw-r--r--forge/src/main/resources/META-INF/accesstransformer.cfg4
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java32
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java50
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigGroups.java3
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigOptions.java6
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/DisplayRegistryInfoScreen.java174
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/PerformanceScreen.java38
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/entry/SubCategoryListEntry.java4
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/ScreenWithMenu.java89
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryWidget.java7
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayCache.java4
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayCacheImpl.java16
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayRegistryImpl.java78
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/util/OriginalRetainingCyclingList.java42
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/view/ViewsImpl.java8
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginManagerImpl.java187
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/plugins/ReloadManagerImpl.java211
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/registry/RecipeManagerContextImpl.java17
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/util/InstanceHelper.java125
-rwxr-xr-xruntime/src/main/resources/assets/roughlyenoughitems/lang/en_us.json6
25 files changed, 1026 insertions, 217 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Slot.java b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Slot.java
index 02527dafd..c968e685f 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Slot.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/gui/widgets/Slot.java
@@ -25,10 +25,12 @@ package me.shedaniel.rei.api.client.gui.widgets;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.common.entry.EntryStack;
+import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.List;
+import java.util.function.Consumer;
public abstract class Slot extends WidgetWithBounds {
public static final byte UN_MARKED = 0;
@@ -133,6 +135,10 @@ public abstract class Slot extends WidgetWithBounds {
public abstract Slot entries(Collection<? extends EntryStack<?>> stacks);
+ @ApiStatus.Experimental
+ @ApiStatus.Internal
+ public abstract Slot withEntriesListener(Consumer<Slot> listener);
+
public abstract EntryStack<?> getCurrentEntry();
public abstract List<EntryStack<?>> getEntries();
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/plugins/PluginView.java b/api/src/main/java/me/shedaniel/rei/api/common/plugins/PluginView.java
index b1072cb21..0e9918c66 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/plugins/PluginView.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/plugins/PluginView.java
@@ -24,9 +24,9 @@
package me.shedaniel.rei.api.common.plugins;
import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
-import me.shedaniel.rei.api.common.registry.ReloadStage;
import me.shedaniel.rei.impl.ClientInternals;
import me.shedaniel.rei.impl.Internals;
+import me.shedaniel.rei.impl.common.plugins.PluginReloadContext;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.jetbrains.annotations.ApiStatus;
@@ -62,18 +62,25 @@ public interface PluginView<P extends REIPlugin<?>> {
}
@Override
- public void pre(ReloadStage stage) {
- PluginView.this.pre(stage);
+ public void pre(PluginReloadContext context) throws InterruptedException {
+ PluginView.this.pre(context);
}
@Override
- public void post(ReloadStage stage) {
- PluginView.this.post(stage);
+ public void reload(PluginReloadContext context) throws InterruptedException {
+ PluginView.this.reload(context);
+ }
+
+ @Override
+ public void post(PluginReloadContext context) throws InterruptedException {
+ PluginView.this.post(context);
}
};
}
- void pre(ReloadStage stage);
+ void pre(PluginReloadContext context) throws InterruptedException;
+
+ void reload(PluginReloadContext context) throws InterruptedException;
- void post(ReloadStage stage);
+ void post(PluginReloadContext context) throws InterruptedException;
}
diff --git a/api/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginReloadContext.java b/api/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginReloadContext.java
new file mode 100644
index 000000000..0481b38d0
--- /dev/null
+++ b/api/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginReloadContext.java
@@ -0,0 +1,48 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023 shedaniel
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.shedaniel.rei.impl.common.plugins;
+
+import me.shedaniel.rei.api.common.registry.ReloadStage;
+import org.jetbrains.annotations.ApiStatus;
+
+@ApiStatus.Internal
+public interface PluginReloadContext {
+ ReloadStage stage();
+
+ ReloadInterruptionContext interruptionContext();
+
+ static PluginReloadContext of(ReloadStage stage, ReloadInterruptionContext interruptionContext) {
+ return new PluginReloadContext() {
+ @Override
+ public ReloadStage stage() {
+ return stage;
+ }
+
+ @Override
+ public ReloadInterruptionContext interruptionContext() {
+ return interruptionContext;
+ }
+ };
+ }
+}
diff --git a/api/src/main/java/me/shedaniel/rei/impl/common/plugins/ReloadInterruptionContext.java b/api/src/main/java/me/shedaniel/rei/impl/common/plugins/ReloadInterruptionContext.java
new file mode 100644
index 000000000..19201b20b
--- /dev/null
+++ b/api/src/main/java/me/shedaniel/rei/impl/common/plugins/ReloadInterruptionContext.java
@@ -0,0 +1,63 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023 shedaniel
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.shedaniel.rei.impl.common.plugins;
+
+import me.shedaniel.rei.impl.common.InternalLogger;
+import org.jetbrains.annotations.ApiStatus;
+
+@FunctionalInterface
+@ApiStatus.Internal
+public interface ReloadInterruptionContext {
+ boolean isInterrupted();
+
+ default void checkInterrupted() throws InterruptedException {
+ if (isInterrupted()) {
+ InternalLogger.getInstance().debug("Plugin reload interrupted!");
+ throw new InterruptedException();
+ }
+ }
+
+ default ReloadInterruptionContext withJob(Runnable ifInterrupted) {
+ return new ReloadInterruptionContext() {
+ @Override
+ public boolean isInterrupted() {
+ return ReloadInterruptionContext.this.isInterrupted();
+ }
+
+ @Override
+ public void checkInterrupted() throws InterruptedException {
+ try {
+ ReloadInterruptionContext.this.checkInterrupted();
+ } catch (InterruptedException e) {
+ ifInterrupted.run();
+ throw e;
+ }
+ }
+ };
+ }
+
+ static ReloadInterruptionContext ofNever() {
+ return () -> false;
+ }
+}
diff --git a/fabric/src/main/resources/roughlyenoughitems.accessWidener b/fabric/src/main/resources/roughlyenoughitems.accessWidener
index 22dc526c1..04096fc65 100644
--- a/fabric/src/main/resources/roughlyenoughitems.accessWidener
+++ b/fabric/src/main/resources/roughlyenoughitems.accessWidener
@@ -42,4 +42,6 @@ accessible field net/minecraft/world/item/crafting/SmithingTransformRecipe base
accessible field net/minecraft/world/item/crafting/SmithingTransformRecipe addition Lnet/minecraft/world/item/crafting/Ingredient;
accessible field net/minecraft/world/item/crafting/SmithingTrimRecipe template Lnet/minecraft/world/item/crafting/Ingredient;
accessible field net/minecraft/world/item/crafting/SmithingTrimRecipe base Lnet/minecraft/world/item/crafting/Ingredient;
-accessible field net/minecraft/world/item/crafting/SmithingTrimRecipe addition Lnet/minecraft/world/item/crafting/Ingredient; \ No newline at end of file
+accessible field net/minecraft/world/item/crafting/SmithingTrimRecipe addition Lnet/minecraft/world/item/crafting/Ingredient;
+accessible field net/minecraft/client/multiplayer/ClientLevel connection Lnet/minecraft/client/multiplayer/ClientPacketListener;
+accessible field net/minecraft/client/multiplayer/MultiPlayerGameMode connection Lnet/minecraft/client/multiplayer/ClientPacketListener; \ No newline at end of file
diff --git a/forge/src/main/resources/META-INF/accesstransformer.cfg b/forge/src/main/resources/META-INF/accesstransformer.cfg
index cd8fd6891..a974e1d09 100644
--- a/forge/src/main/resources/META-INF/accesstransformer.cfg
+++ b/forge/src/main/resources/META-INF/accesstransformer.cfg
@@ -43,4 +43,6 @@ public net.minecraft.world.item.crafting.SmithingTransformRecipe f_265888_ # bas
public net.minecraft.world.item.crafting.SmithingTransformRecipe f_265907_ # addition
public net.minecraft.world.item.crafting.SmithingTrimRecipe f_265958_ # template
public net.minecraft.world.item.crafting.SmithingTrimRecipe f_266040_ # base
-public net.minecraft.world.item.crafting.SmithingTrimRecipe f_266053_ # addition \ No newline at end of file
+public net.minecraft.world.item.crafting.SmithingTrimRecipe f_266053_ # addition
+public net.minecraft.client.multiplayer.ClientLevel f_104561_ # connection
+public net.minecraft.client.multiplayer.MultiPlayerGameMode f_105190_ # connection \ No newline at end of file
diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java
index 732ca00cd..3f99fa7cb 100644
--- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java
+++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java
@@ -29,13 +29,10 @@ import dev.architectury.platform.Platform;
import dev.architectury.registry.ReloadListenerRegistry;
import dev.architectury.utils.Env;
import dev.architectury.utils.EnvExecutor;
-import me.shedaniel.cloth.clothconfig.shadowed.blue.endless.jankson.annotation.Nullable;
import me.shedaniel.rei.api.common.entry.type.EntryType;
-import me.shedaniel.rei.api.common.plugins.PluginManager;
import me.shedaniel.rei.api.common.plugins.PluginView;
import me.shedaniel.rei.api.common.plugins.REIPlugin;
import me.shedaniel.rei.api.common.plugins.REIServerPlugin;
-import me.shedaniel.rei.api.common.registry.ReloadStage;
import me.shedaniel.rei.impl.Internals;
import me.shedaniel.rei.impl.common.InternalLogger;
import me.shedaniel.rei.impl.common.category.CategoryIdentifierImpl;
@@ -53,6 +50,8 @@ import me.shedaniel.rei.impl.common.logging.*;
import me.shedaniel.rei.impl.common.logging.performance.PerformanceLogger;
import me.shedaniel.rei.impl.common.logging.performance.PerformanceLoggerImpl;
import me.shedaniel.rei.impl.common.plugins.PluginManagerImpl;
+import me.shedaniel.rei.impl.common.plugins.ReloadInterruptionContext;
+import me.shedaniel.rei.impl.common.plugins.ReloadManagerImpl;
import me.shedaniel.rei.impl.common.registry.RecipeManagerContextImpl;
import me.shedaniel.rei.impl.common.transfer.MenuInfoRegistryImpl;
import me.shedaniel.rei.impl.common.transfer.SlotAccessorRegistryImpl;
@@ -135,7 +134,7 @@ public class RoughlyEnoughItemsCore {
UnaryOperator.identity(),
new EntryTypeRegistryImpl(),
new EntrySettingsAdapterRegistryImpl(),
- new RecipeManagerContextImpl<>(RecipeManagerContextImpl.supplier()),
+ new RecipeManagerContextImpl<>(),
new ItemComparatorRegistryImpl(),
new FluidComparatorRegistryImpl(),
new DisplaySerializerRegistryImpl(),
@@ -147,28 +146,6 @@ public class RoughlyEnoughItemsCore {
new SlotAccessorRegistryImpl()), "serverPluginManager");
}
- public static void _reloadPlugins(@Nullable ReloadStage stage) {
- if (stage == null) {
- for (ReloadStage reloadStage : ReloadStage.values()) {
- _reloadPlugins(reloadStage);
- }
- return;
- }
- try {
- for (PluginManager<? extends REIPlugin<?>> instance : PluginManager.getActiveInstances()) {
- instance.view().pre(stage);
- }
- for (PluginManager<? extends REIPlugin<?>> instance : PluginManager.getActiveInstances()) {
- instance.startReload(stage);
- }
- for (PluginManager<? extends REIPlugin<?>> instance : PluginManager.getActiveInstances()) {
- instance.view().post(stage);
- }
- } catch (Throwable throwable) {
- throwable.printStackTrace();
- }
- }
-
public void onInitialize() {
PluginDetector detector = getPluginDetector();
detector.detectCommonPlugins();
@@ -179,8 +156,7 @@ public class RoughlyEnoughItemsCore {
MutableLong lastReload = new MutableLong(-1);
ReloadListenerRegistry.register(PackType.SERVER_DATA, (preparationBarrier, resourceManager, profilerFiller, profilerFiller2, executor, executor2) -> {
return preparationBarrier.wait(Unit.INSTANCE).thenRunAsync(() -> {
- PERFORMANCE_LOGGER.clear();
- RoughlyEnoughItemsCore._reloadPlugins(null);
+ ReloadManagerImpl.reloadPlugins(null, ReloadInterruptionContext.ofNever());
}, executor2);
});
}
diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java
index de49c9a29..576193baf 100644
--- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java
+++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java
@@ -24,13 +24,12 @@
package me.shedaniel.rei;
import com.google.common.collect.Lists;
-import com.mojang.blaze3d.systems.RenderSystem;
-import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.serialization.DataResult;
import dev.architectury.event.Event;
import dev.architectury.event.EventFactory;
import dev.architectury.event.EventResult;
import dev.architectury.event.events.client.ClientGuiEvent;
+import dev.architectury.event.events.client.ClientPlayerEvent;
import dev.architectury.event.events.client.ClientRecipeUpdateEvent;
import dev.architectury.event.events.client.ClientScreenInputEvent;
import dev.architectury.networking.NetworkManager;
@@ -67,7 +66,6 @@ import me.shedaniel.rei.impl.client.entry.filtering.rules.FilteringRuleTypeRegis
import me.shedaniel.rei.impl.client.entry.renderer.EntryRendererRegistryImpl;
import me.shedaniel.rei.impl.client.favorites.DelegatingFavoriteEntryProviderImpl;
import me.shedaniel.rei.impl.client.favorites.FavoriteEntryTypeRegistryImpl;
-import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl;
import me.shedaniel.rei.impl.client.gui.modules.entries.SubMenuEntry;
import me.shedaniel.rei.impl.client.gui.modules.entries.ToggleMenuEntry;
import me.shedaniel.rei.impl.client.gui.widget.InternalWidgets;
@@ -89,6 +87,8 @@ import me.shedaniel.rei.impl.common.entry.type.EntryRegistryImpl;
import me.shedaniel.rei.impl.common.entry.type.collapsed.CollapsibleEntryRegistryImpl;
import me.shedaniel.rei.impl.common.entry.type.types.EmptyEntryDefinition;
import me.shedaniel.rei.impl.common.plugins.PluginManagerImpl;
+import me.shedaniel.rei.impl.common.plugins.ReloadManagerImpl;
+import me.shedaniel.rei.impl.common.util.InstanceHelper;
import me.shedaniel.rei.impl.common.util.IssuesDetector;
import me.shedaniel.rei.plugin.test.REITestPlugin;
import net.fabricmc.api.EnvType;
@@ -121,7 +121,6 @@ import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.List;
-import java.util.concurrent.*;
import java.util.function.BiFunction;
import java.util.function.BooleanSupplier;
import java.util.function.Function;
@@ -133,15 +132,6 @@ public class RoughlyEnoughItemsCoreClient {
public static final Event<ClientRecipeUpdateEvent> PRE_UPDATE_RECIPES = EventFactory.createLoop();
public static final Event<Runnable> POST_UPDATE_TAGS = EventFactory.createLoop();
public static boolean isLeftMousePressed = false;
- private static final ExecutorService RELOAD_PLUGINS = Executors.newSingleThreadScheduledExecutor(task -> {
- Thread thread = new Thread(task, "REI-ReloadPlugins");
- thread.setDaemon(true);
- thread.setUncaughtExceptionHandler(($, exception) -> {
- InternalLogger.getInstance().throwException(exception);
- });
- return thread;
- });
- private static final List<Future<?>> RELOAD_TASKS = new CopyOnWriteArrayList<>();
public static void attachClientInternals() {
InternalWidgets.attach();
@@ -317,24 +307,25 @@ public class RoughlyEnoughItemsCoreClient {
private void registerEvents() {
Minecraft client = Minecraft.getInstance();
final ResourceLocation recipeButtonTex = new ResourceLocation("textures/gui/recipe_button.png");
- MutableLong startReload = new MutableLong(-1);
MutableLong endReload = new MutableLong(-1);
PRE_UPDATE_RECIPES.register(recipeManager -> {
- RoughlyEnoughItemsCore.PERFORMANCE_LOGGER.clear();
- reloadPlugins(startReload, ReloadStage.START);
+ reloadPlugins(null, ReloadStage.START);
});
ClientRecipeUpdateEvent.EVENT.register(recipeManager -> {
reloadPlugins(endReload, ReloadStage.END);
});
+ ClientPlayerEvent.CLIENT_PLAYER_QUIT.register(player -> {
+ InternalLogger.getInstance().debug("Player quit, clearing reload tasks!");
+ endReload.setValue(-1);
+ ReloadManagerImpl.terminateReloadTasks();
+ });
ClientGuiEvent.INIT_PRE.register((screen, access) -> {
List<ReloadStage> stages = ((PluginManagerImpl<REIPlugin<?>>) PluginManager.getInstance()).getObservedStages();
if (Minecraft.getInstance().level != null && Minecraft.getInstance().player != null && stages.contains(ReloadStage.START)
&& !stages.contains(ReloadStage.END) && !PluginManager.areAnyReloading() && screen instanceof AbstractContainerScreen) {
- for (Future<?> task : RELOAD_TASKS) {
- if (!task.isDone()) {
- return EventResult.pass();
- }
+ if (ReloadManagerImpl.countRunningReloadTasks() > 0) {
+ return EventResult.pass();
}
InternalLogger.getInstance().error("Detected missing stage: END! This is possibly due to issues during client recipe reload! REI will force a reload of the recipes now!");
@@ -473,27 +464,12 @@ public class RoughlyEnoughItemsCoreClient {
public static void reloadPlugins(MutableLong lastReload, @Nullable ReloadStage start) {
if (Minecraft.getInstance().level == null) return;
if (lastReload != null) {
- if (lastReload.getValue() > 0 && System.currentTimeMillis() - lastReload.getValue() <= 5000) {
+ if (lastReload.getValue() > 0 && System.currentTimeMillis() - lastReload.getValue() <= 1000) {
InternalLogger.getInstance().warn("Suppressing Reload Plugins of stage " + start);
return;
}
lastReload.setValue(System.currentTimeMillis());
}
- InternalLogger.getInstance().debug("Starting Reload Plugins of stage " + start, new Throwable());
- if (ConfigObject.getInstance().doesRegisterRecipesInAnotherThread()) {
- Future<?>[] futures = new Future<?>[1];
- CompletableFuture<Void> future = CompletableFuture.runAsync(() -> RoughlyEnoughItemsCore._reloadPlugins(start), RELOAD_PLUGINS)
- .whenComplete((unused, throwable) -> {
- // Remove the future from the list of futures
- if (futures[0] != null) {
- RELOAD_TASKS.remove(futures[0]);
- futures[0] = null;
- }
- });
- futures[0] = future;
- RELOAD_TASKS.add(future);
- } else {
- RoughlyEnoughItemsCore._reloadPlugins(start);
- }
+ ReloadManagerImpl.reloadPlugins(start, () -> InstanceHelper.connectionFromClient() == null);
}
}
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigGroups.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigGroups.java
index 28b83e639..b206fd6e5 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigGroups.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigGroups.java
@@ -116,7 +116,8 @@ public interface AllREIConfigGroups {
OptionGroup DEBUG_PERFORMANCE = make("debug.performance")
.add(PLUGINS_PERFORMANCE)
.add(SEARCH_PERFORMANCE)
- .add(ENTRY_LIST_PERFORMANCE);
+ .add(ENTRY_LIST_PERFORMANCE)
+ .add(DISPLAY_REGISTRY_ANALYSIS);
OptionGroup RESET_RELOAD = make("reset.reload")
.add(RELOAD_PLUGINS)
.add(RELOAD_SEARCH);
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigOptions.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigOptions.java
index 30340bfba..97119df2e 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigOptions.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/config/options/AllREIConfigOptions.java
@@ -24,7 +24,6 @@
package me.shedaniel.rei.impl.client.gui.config.options;
import me.shedaniel.clothconfig2.api.ModifierKeyCode;
-import me.shedaniel.rei.RoughlyEnoughItemsCore;
import me.shedaniel.rei.RoughlyEnoughItemsCoreClient;
import me.shedaniel.rei.api.client.config.entry.EntryStackProvider;
import me.shedaniel.rei.api.client.gui.config.*;
@@ -37,6 +36,7 @@ import me.shedaniel.rei.impl.client.config.entries.ConfigureCategoriesScreen;
import me.shedaniel.rei.impl.client.config.entries.FilteringEntry;
import me.shedaniel.rei.impl.client.gui.config.REIConfigScreen;
import me.shedaniel.rei.impl.client.gui.config.options.configure.PanelBoundariesConfiguration;
+import me.shedaniel.rei.impl.client.gui.performance.DisplayRegistryInfoScreen;
import me.shedaniel.rei.impl.client.gui.performance.PerformanceScreen;
import me.shedaniel.rei.impl.client.gui.screen.ConfigReloadingScreen;
import me.shedaniel.rei.impl.client.gui.screen.collapsible.CollapsibleEntriesScreen;
@@ -246,9 +246,11 @@ public interface AllREIConfigOptions {
.enabledDisabled();
CompositeOption<Boolean> ENTRY_LIST_PERFORMANCE = make("debug.entry_list_performance", i -> i.advanced.layout.debugRenderTimeRequired, (i, v) -> i.advanced.layout.debugRenderTimeRequired = v)
.enabledDisabled();
+ CompositeOption<Object> DISPLAY_REGISTRY_ANALYSIS = make("debug.display_registry_analysis", i -> null, (i, v) -> new Object())
+ .details((access, option, onClose) -> Minecraft.getInstance().setScreen(new DisplayRegistryInfoScreen(onClose)))
+ .requiresLevel();
CompositeOption<Object> RELOAD_PLUGINS = make("reset.reload_plugins", i -> null, (i, v) -> new Object())
.reload((access, option, onClose) -> {
- RoughlyEnoughItemsCore.PERFORMANCE_LOGGER.clear();
RoughlyEnoughItemsCoreClient.reloadPlugins(null, null);
while (!PluginManager.areAnyReloading()) {
try {
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/DisplayRegistryInfoScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/DisplayRegistryInfoScreen.java
new file mode 100644
index 000000000..fd4422232
--- /dev/null
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/performance/DisplayRegistryInfoScreen.java
@@ -0,0 +1,174 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023 shedaniel
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.shedaniel.rei.impl.client.gui.performance;
+
+import com.mojang.blaze3d.systems.RenderSystem;
+import com.mojang.blaze3d.vertex.PoseStack;
+import me.shedaniel.clothconfig2.gui.widget.DynamicElementListWidget;
+import me.shedaniel.math.Rectangle;
+import me.shedaniel.rei.api.client.registry.display.DisplayRegistry;
+import me.shedaniel.rei.api.common.category.CategoryIdentifier;
+import me.shedaniel.rei.api.common.display.Display;
+import me.shedaniel.rei.api.common.util.CollectionUtils;
+import me.shedaniel.rei.impl.client.gui.modules.Menu;
+import me.shedaniel.rei.impl.client.gui.modules.entries.ToggleMenuEntry;
+import me.shedaniel.rei.impl.client.gui.screen.ScreenWithMenu;
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiComponent;
+import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+import net.minecraft.client.gui.narration.NarratableEntry;
+import net.minecraft.network.chat.Component;
+import net.minecraft.util.FormattedCharSequence;
+
+import java.util.*;
+import java.util.function.Supplier;
+import java.util.stream.Stream;
+
+@Environment(EnvType.CLIENT)
+public class DisplayRegistryInfoScreen extends ScreenWithMenu {
+ private Runnable onClose;
+
+ public DisplayRegistryInfoScreen(Runnable onClose) {
+ super(Component.translatable("text.rei.display_registry_analysis"));
+ this.onClose = onClose;
+ }
+
+ private ListWidget list;
+ private SortType sortType = SortType.ID;
+
+ @Override
+ public void init() {
+ {
+ Component backText = Component.literal("↩ ").append(Component.translatable("gui.back"));
+ addRenderableWidget(new Button(4, 4, Minecraft.getInstance().font.width(backText) + 10, 20, backText, button