diff options
| author | shedaniel <daniel@shedaniel.me> | 2024-09-17 21:34:04 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2024-09-17 21:34:04 +0800 |
| commit | 3febdc4e1d6927f19d0de6fc8430765336d34d7e (patch) | |
| tree | e8cc88c46ce9b2ebf0954f94dcb56189f2fa5a1b | |
| parent | bc039e2d0a45409396c9156307d70529ccb28a3e (diff) | |
| parent | ccf3dcd60aa6c1d079dd57c59d9a89c2ca60b1e7 (diff) | |
| download | RoughlyEnoughItems-3febdc4e1d6927f19d0de6fc8430765336d34d7e.tar.gz RoughlyEnoughItems-3febdc4e1d6927f19d0de6fc8430765336d34d7e.tar.bz2 RoughlyEnoughItems-3febdc4e1d6927f19d0de6fc8430765336d34d7e.zip | |
Merge remote-tracking branch 'origin/12.x-1.20' into 13.x-1.20.2
# Conflicts:
# default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/DefaultSmithingDisplay.java
# fabric/src/main/resources/roughlyenoughitems.accessWidener
# runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayRegistryImpl.java
# runtime/src/main/java/me/shedaniel/rei/impl/common/registry/RecipeManagerContextImpl.java
27 files changed, 1114 insertions, 235 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/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultSmithingCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultSmithingCategory.java index 982221600..a7546390c 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultSmithingCategory.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultSmithingCategory.java @@ -27,15 +27,22 @@ import com.google.common.collect.Lists; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.client.gui.Renderer; +import me.shedaniel.rei.api.client.gui.widgets.Slot; import me.shedaniel.rei.api.client.gui.widgets.Widget; import me.shedaniel.rei.api.client.gui.widgets.Widgets; import me.shedaniel.rei.api.client.registry.display.DisplayCategory; import me.shedaniel.rei.api.common.category.CategoryIdentifier; +import me.shedaniel.rei.api.common.display.basic.BasicDisplay; +import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.util.EntryStacks; import me.shedaniel.rei.plugin.common.BuiltinPlugin; import me.shedaniel.rei.plugin.common.displays.DefaultSmithingDisplay; +import net.minecraft.core.RegistryAccess; import net.minecraft.network.chat.Component; import net.minecraft.world.level.block.Blocks; +import org.apache.commons.lang3.mutable.MutableBoolean; +import org.jetbrains.annotations.ApiStatus; import java.util.List; @@ -65,14 +72,23 @@ public class DefaultSmithingCategory implements DisplayCategory<DefaultSmithingD widgets.add(Widgets.createArrow(new Point(startPoint.x + 27 + offsetX, startPoint.y + 4))); widgets.add(Widgets.createResultSlotBackground(new Point(startPoint.x + 61 + offsetX, startPoint.y + 5))); if (!legacy) { - widgets.add(Widgets.createSlot(new Point(startPoint.x + 4 - 18 * 2 + offsetX, startPoint.y + 5)).entries(display.getInputEntries().get(0)).markInput()); - widgets.add(Widgets.createSlot(new Point(startPoint.x + 4 - 18 + offsetX, startPoint.y + 5)).entries(display.getInputEntries().get(1)).markInput()); - widgets.add(Widgets.createSlot(new Point(startPoint.x + 4 + offsetX, startPoint.y + 5)).entries(display.getInputEntries().get(2)).markInput()); + Slot templateSlot, baseSlot, additionSlot, resultSlot; + MutableBoolean dirty = new MutableBoolean(true); + widgets.add(templateSlot = Widgets.createSlot(new Point(startPoint.x + 4 - 18 * 2 + offsetX, startPoint.y + 5)).entries(display.getInputEntries().get(0)).withEntriesListener(slot -> dirty.setTrue()).markInput()); + widgets.add(baseSlot = Widgets.createSlot(new Point(startPoint.x + 4 - 18 + offsetX, startPoint.y + 5)).entries(display.getInputEntries().get(1)).withEntriesListener(slot -> dirty.setTrue()).markInput()); + widgets.add(additionSlot = Widgets.createSlot(new Point(startPoint.x + 4 + offsetX, startPoint.y + 5)).entries(display.getInputEntries().get(2)).withEntriesListener(slot -> dirty.setTrue()).markInput()); + widgets.add(resultSlot = Widgets.createSlot(new Point(startPoint.x + 61 + offsetX, startPoint.y + 5)).entries(display.getOutputEntries().get(0)).disableBackground().markOutput()); + widgets.add(Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> { + if (dirty.booleanValue()) { + resultSlot.clearEntries().entries(getOutput(display, BasicDisplay.registryAccess(), templateSlot.getCurrentEntry(), baseSlot.getCurrentEntry(), additionSlot.getCurrentEntry())); + dirty.setFalse(); + } + })); } else { widgets.add(Widgets.createSlot(new Point(startPoint.x + 4 - 22 + offsetX, startPoint.y + 5)).entries(display.getInputEntries().get(0)).markInput()); widgets.add(Widgets.createSlot(new Point(startPoint.x + 4 + offsetX, startPoint.y + 5)).entries(display.getInputEntries().get(1)).markInput()); + widgets.add(Widgets.createSlot(new Point(startPoint.x + 61 + offsetX, startPoint.y + 5)).entries(display.getOutputEntries().get(0)).disableBackground().markOutput()); } - widgets.add(Widgets.createSlot(new Point(startPoint.x + 61 + offsetX, startPoint.y + 5)).entries(display.getOutputEntries().get(0)).disableBackground().markOutput()); return widgets; } @@ -80,4 +96,14 @@ public class DefaultSmithingCategory implements DisplayCategory<DefaultSmithingD public int getDisplayHeight() { return 36; } + + @ApiStatus.Experimental + private static EntryIngredient getOutput(DefaultSmithingDisplay display, RegistryAccess registryAccess, EntryStack<?> template, EntryStack<?> base, EntryStack<?> addition) { + if (display.getType() == DefaultSmithingDisplay.SmithingRecipeType.TRIM) { + EntryIngredient output = DefaultSmithingDisplay.getTrimmingOutput(registryAccess, template, base, addition); + if (!output.isEmpty()) return output; + } + + return display.getOutputEntries().get(0); + } } diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/DefaultSmithingDisplay.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/DefaultSmithingDisplay.java index 4d2c0a07c..992f31d7e 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/DefaultSmithingDisplay.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/DefaultSmithingDisplay.java @@ -26,6 +26,8 @@ package me.shedaniel.rei.plugin.common.displays; import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.display.basic.BasicDisplay; import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; import me.shedaniel.rei.api.common.util.EntryIngredients; import me.shedaniel.rei.api.common.util.EntryStacks; import me.shedaniel.rei.plugin.common.BuiltinPlugin; @@ -46,6 +48,9 @@ import java.util.List; import java.util.Optional; public class DefaultSmithingDisplay extends BasicDisplay { + @Nullable + private final SmithingRecipeType type; + @ApiStatus.Experimental public static DefaultSmithingDisplay ofTransforming(RecipeHolder<SmithingTransformRecipe> recipe) { return new DefaultSmithingDisplay( @@ -86,25 +91,15 @@ public class DefaultSmithingDisplay extends BasicDisplay { .orElse(null); if (trimMaterial == null) continue; - ArmorTrim armorTrim = new ArmorTrim(trimMaterial, trimPattern); - EntryIngredient.Builder baseItems = EntryIngredient.builder(), outputItems = EntryIngredient.builder(); - for (ItemStack item : recipe.value().base.getItems()) { - Optional<ArmorTrim> trim = ArmorTrim.getTrim(registryAccess, item, true); - if (trim.isEmpty() || !trim.get().hasPatternAndMaterial(trimPattern, trimMaterial)) { - ItemStack newItem = item.copy(); - newItem.setCount(1); - if (ArmorTrim.setTrim(registryAccess, newItem, armorTrim)) { - baseItems.add(EntryStacks.of(item.copy())); - outputItems.add(EntryStacks.of(newItem)); - } - } - } + EntryIngredient baseIngredient = EntryIngredients.ofIngredient(recipe.value().base); + EntryIngredient templateOutput = baseIngredient.isEmpty() ? EntryIngredient.empty() + : getTrimmingOutput(registryAccess, EntryStacks.of(templateItem), baseIngredient.get(0), EntryStacks.of(additionStack)); + displays.add(new DefaultSmithingDisplay(List.of( EntryIngredients.of(templateItem), - baseItems.build(), + baseIngredient, EntryIngredients.of(additionStack) - ), List.of(outputItems.build()), - Optional.ofNullable(recipe.id()))); + ), List.of(templateOutput), SmithingRecipeType.TRIM, Optional.ofNullable(recipe.id()))); } } return displays; @@ -119,7 +114,13 @@ public class DefaultSmithingDisplay extends BasicDisplay { } public DefaultSmithingDisplay(List<EntryIngredient> inputs, List<EntryIngredient> outputs, Optional<ResourceLocation> location) { + this(inputs, outputs, null, location); + } + + @ApiStatus.Experimental + public DefaultSmithingDisplay(List<EntryIngredient> inputs, List<EntryIngredient> outputs, @Nullable SmithingRecipeType type, Optional<ResourceLocation> location) { super(inputs, outputs, location); + this.type = type; } @Override @@ -127,7 +128,47 @@ public class DefaultSmithingDisplay extends BasicDisplay { return BuiltinPlugin.SMITHING; } + @ApiStatus.Experimental + @Nullable + public SmithingRecipeType getType() { + return type; + } + public static BasicDisplay.Serializer<DefaultSmithingDisplay> serializer() { - return BasicDisplay.Serializer.ofSimple(DefaultSmithingDisplay::new); + return BasicDisplay.Serializer.of((input, output, id, tag) -> { + SmithingRecipeType type = tag.contains("Type") ? SmithingRecipeType.valueOf(tag.getString("Type")) : null; + return new DefaultSmithingDisplay(input, output, type, id); + }, (display, tag) -> { + if (display.type != null) tag.putString("Type", display.type.name()); + }); + } + + @ApiStatus.Experimental + public enum SmithingRecipeType { + TRIM, + TRANSFORM + } + + @ApiStatus.Experimental + @ApiStatus.Internal + public static EntryIngredient getTrimmingOutput(RegistryAccess registryAccess, EntryStack<?> template, EntryStack<?> base, EntryStack<?> addition) { + if (template.getType() != VanillaEntryTypes.ITEM || base.getType() != VanillaEntryTypes.ITEM || addition.getType() != VanillaEntryTypes.ITEM) return EntryIngredient.empty(); + ItemStack templateItem = template.castValue(); + ItemStack baseItem = base.castValue(); + ItemStack additionItem = addition.castValue(); + Holder.Reference<TrimPattern> trimPattern = TrimPatterns.getFromTemplate(registryAccess, templateItem) + .orElse(null); + if (trimPattern == null) return EntryIngredient.empty(); + Holder.Reference<TrimMaterial> trimMaterial = TrimMaterials.getFromIngredient(registryAccess, additionItem) + .orElse(null); + if (trimMaterial == null) return EntryIngredient.empty(); + ArmorTrim armorTrim = new ArmorTrim(trimMaterial, trimPattern); + Optional<ArmorTrim> trim = ArmorTrim.getTrim(registryAccess, baseItem); + if (trim.isPresent() && trim.get().hasPatternAndMaterial(trimPattern, trimMaterial)) return EntryIngredient.empty(); + ItemStack newItem = baseItem.copy(); + newItem.setCount(1); + if (ArmorTrim.setTrim(registryAccess, newItem, armorTrim)) { + return EntryIngredients.of(newItem); + } else return EntryIngredient.empty(); } } diff --git a/fabric/src/main/resources/roughlyenoughitems.accessWidener b/fabric/src/main/resources/roughlyenoughitems.accessWidener index ed35f78e8..7c7945f6d 100644 --- a/fabric/src/main/resources/roughlyenoughitems.accessWidener +++ b/fabric/src/main/resources/roughlyenoughitems.accessWidener @@ -42,3 +42,5 @@ accessible field net/minecraft/world/item/crafting/SmithingTrimRecipe base Lnet/ accessible field net/minecraft/world/item/crafting/SmithingTrimRecipe addition Lnet/minecraft/world/item/crafting/Ingredient; accessible field net/minecraft/world/item/CreativeModeTab displayItemsGenerator Lnet/minecraft/world/item/CreativeModeTab$DisplayItemsGenerator; accessible class net/minecraft/world/item/CreativeModeTab$ItemDisplayBuilder +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 082c7dea2..6eb5af3b2 100644 --- a/forge/src/main/resources/META-INF/accesstransformer.cfg +++ b/forge/src/main/resources/META-INF/accesstransformer.cfg @@ -48,3 +48,5 @@ public-f net.minecraft.client.gui.font.CodepointMap f_283938_ # blockMap public-f net.minecraft.client.gui.font.CodepointMap f_283773_ # blockConstructor public net.minecraft.world.item.CreativeModeTab f_256824_ # displayItemsGenerator public net.minecraft.world.item.CreativeModeTab$ItemDisplayBuilder +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 408227e16..a04b44849 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; |
