From 9796ed33a2616dd4bca6b0158e329c2191a76685 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sun, 16 May 2021 21:43:35 +0800 Subject: Add "jei" stub, and made JEI compat defaulted enable --- forge/build.gradle | 2 ++ .../main/java/me/shedaniel/rei/forge/JEIStub.java | 31 ++++++++++++++++++++++ .../forge/RoughlyEnoughItemsInitializerImpl.java | 3 --- forge/src/main/resources/META-INF/mods.toml | 9 +++++++ .../rei/impl/client/config/ConfigObjectImpl.java | 6 ++--- .../rei/impl/common/entry/AbstractEntryStack.java | 2 +- 6 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 forge/src/main/java/me/shedaniel/rei/forge/JEIStub.java diff --git a/forge/build.gradle b/forge/build.gradle index c7ccec31c..dd119678f 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -57,6 +57,8 @@ dependencies { modRuntime("appeng:appliedenergistics2:8.2.0") modRuntime("curse.maven:tcon-74072:3273213") modRuntime("curse.maven:mantle-74924:3273201") + modRuntime("curse.maven:jer-240630:3066754") + modRuntime("curse.maven:jep-417645:3198370") } shadowJar { diff --git a/forge/src/main/java/me/shedaniel/rei/forge/JEIStub.java b/forge/src/main/java/me/shedaniel/rei/forge/JEIStub.java new file mode 100644 index 000000000..de0c34314 --- /dev/null +++ b/forge/src/main/java/me/shedaniel/rei/forge/JEIStub.java @@ -0,0 +1,31 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021 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.forge; + +import net.minecraftforge.fml.common.Mod; + +// Hello mods, JEI is present!! Please give in and trust me! +@Mod("jei") +public class JEIStub { +} diff --git a/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsInitializerImpl.java b/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsInitializerImpl.java index 45b4e39a7..fa282697a 100644 --- a/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsInitializerImpl.java +++ b/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsInitializerImpl.java @@ -34,9 +34,6 @@ public class RoughlyEnoughItemsInitializerImpl { } public static void checkMods() { - if (ModList.get().isLoaded("jei")) { - RoughlyEnoughItemsState.error("JEI is installed! REI is an replacement of JEI, we can't co-exist!"); - } if (isClient()) { if (!ModList.get().isLoaded("cloth-config")) { RoughlyEnoughItemsState.error("Cloth Config is not installed!", "https://www.curseforge.com/minecraft/mc-mods/cloth-config/files/all"); diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index 74fa66012..30ac8e0af 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -4,6 +4,7 @@ issueTrackerURL = "https://github.com/shedaniel/RoughlyEnoughItems/issues" logoFile = "icon.png" authors = "shedaniel" license = "MIT" + [[mods]] modId = "roughlyenoughitems" version = "${version}" @@ -12,6 +13,14 @@ description = ''' To allow players to view items and recipes. ''' +[[mods]] +modId = "jei" +version = "7.9999" +displayName = "Roughly Enough Items (JEI Stub)" +description = ''' +To allow players to view items and recipes. +''' + [[dependencies.roughlyenoughitems]] modId = "architectury" mandatory = true diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java index ac2156026..f5b637ba4 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java @@ -383,11 +383,11 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { @Override public boolean isJEICompatibilityLayerEnabled() { - return Platform.isForge() && advanced.jeiCompatibilityLayer; + return Platform.isForge() && advanced.enableJeiCompatibilityLayer; } public void setJEICompatibilityLayerEnabled(boolean value) { - advanced.jeiCompatibilityLayer = value; + advanced.enableJeiCompatibilityLayer = value; } @Retention(RetentionPolicy.RUNTIME) @@ -493,7 +493,7 @@ public class ConfigObjectImpl implements ConfigObject, ConfigData { @ConfigEntry.Gui.CollapsibleObject(startExpanded = true) public Filtering filtering = new Filtering(); @ConfigEntry.Gui.Excluded - public boolean jeiCompatibilityLayer = false; + public boolean enableJeiCompatibilityLayer = true; public static class Tooltips { @Comment("Declares whether REI should append mod names to entries.") private boolean appendModNames = true; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/AbstractEntryStack.java b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/AbstractEntryStack.java index 0a1c57a9a..8c52a7614 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/AbstractEntryStack.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/AbstractEntryStack.java @@ -156,7 +156,7 @@ public abstract class AbstractEntryStack extends AbstractRenderer implements public Tooltip getTooltip(Point mouse, boolean appendModName) { Mutable tooltip = new MutableObject<>(getRenderer().cast().getTooltip(this, mouse)); if (tooltip.getValue() == null) return null; - tooltip.getValue().getText().addAll(get(EntryStack.Settings.TOOLTIP_APPEND_EXTRA).apply(this)); + tooltip.getValue().getText().addAll(get(Settings.TOOLTIP_APPEND_EXTRA).apply(this)); tooltip.setValue(get(Settings.TOOLTIP_PROCESSOR).apply(this, tooltip.getValue())); if (tooltip.getValue() == null) return null; if (appendModName) { -- cgit From 1e8f7022d4a82a6210c9d4080f3bc49d8129d20a Mon Sep 17 00:00:00 2001 From: shedaniel Date: Mon, 17 May 2021 00:29:35 +0800 Subject: Add stub AnvilRecipe and implement recipe hiding --- .../plugin/common/displays/anvil/AnvilRecipe.java | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/anvil/AnvilRecipe.java diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/anvil/AnvilRecipe.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/anvil/AnvilRecipe.java new file mode 100644 index 000000000..550199a62 --- /dev/null +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/anvil/AnvilRecipe.java @@ -0,0 +1,40 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021 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.plugin.common.displays.anvil; + +import net.minecraft.world.item.ItemStack; + +import java.util.List; + +public class AnvilRecipe { + private final List leftInput; + private final List rightInputs; + private final List outputs; + + public AnvilRecipe(List leftInput, List rightInputs, List outputs) { + this.leftInput = leftInput; + this.rightInputs = rightInputs; + this.outputs = outputs; + } +} -- cgit From 745f78a4aa7d23fe03e7420eb3fe06b8c418db35 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Mon, 17 May 2021 21:41:03 +0800 Subject: Implement ErrorDisplayer on Fabric properly --- api/build.gradle | 2 + default-plugin/build.gradle | 2 + .../fabric/RoughlyEnoughItemsInitializerImpl.java | 7 ++++ .../rei/impl/client/fabric/ErrorDisplayerImpl.java | 38 +++++++++++++++++++ .../me/shedaniel/rei/mixin/fabric/MixinScreen.java | 44 ++++++++++++++++++++++ fabric/src/main/resources/fabric.mod.json | 3 ++ fabric/src/main/resources/rei.mixins.json | 14 +++++++ .../forge/RoughlyEnoughItemsInitializerImpl.java | 12 +++--- .../rei/impl/client/forge/ErrorDisplayerImpl.java | 33 ++++++++++++++++ forge/src/main/resources/META-INF/mods.toml | 7 ++++ runtime/build.gradle | 2 + .../rei/RoughlyEnoughItemsInitializer.java | 8 ++++ .../me/shedaniel/rei/RoughlyEnoughItemsState.java | 9 +++-- .../shedaniel/rei/impl/client/ErrorDisplayer.java | 12 +++++- 14 files changed, 180 insertions(+), 13 deletions(-) create mode 100644 fabric/src/main/java/me/shedaniel/rei/impl/client/fabric/ErrorDisplayerImpl.java create mode 100644 fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinScreen.java create mode 100644 fabric/src/main/resources/rei.mixins.json create mode 100644 forge/src/main/java/me/shedaniel/rei/impl/client/forge/ErrorDisplayerImpl.java diff --git a/api/build.gradle b/api/build.gradle index 44fe15010..40ea8f83d 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -1,3 +1,5 @@ +archivesBaseName = rootProject.name + "-" + project.name + dependencies { modCompileOnly("net.fabricmc:fabric-loader:${project.fabricloader_version}") modCompileOnly("me.shedaniel.cloth:cloth-config:${cloth_config_version}") diff --git a/default-plugin/build.gradle b/default-plugin/build.gradle index 88bf7f1f4..1f0d45a41 100644 --- a/default-plugin/build.gradle +++ b/default-plugin/build.gradle @@ -1,3 +1,5 @@ +archivesBaseName = rootProject.name + "-" + project.name + loom { accessWidener = gradle.rootProject.project("fabric").file("src/main/resources/roughlyenoughitems.accessWidener") } diff --git a/fabric/src/main/java/me/shedaniel/rei/fabric/RoughlyEnoughItemsInitializerImpl.java b/fabric/src/main/java/me/shedaniel/rei/fabric/RoughlyEnoughItemsInitializerImpl.java index d7200f47c..47f671dc0 100644 --- a/fabric/src/main/java/me/shedaniel/rei/fabric/RoughlyEnoughItemsInitializerImpl.java +++ b/fabric/src/main/java/me/shedaniel/rei/fabric/RoughlyEnoughItemsInitializerImpl.java @@ -57,6 +57,9 @@ public class RoughlyEnoughItemsInitializerImpl { break; } } + if (!FabricLoader.getInstance().isModLoaded("architectury")) { + RoughlyEnoughItemsState.error("Architectury API is not installed!", "https://www.curseforge.com/minecraft/mc-mods/architectury-fabric/files/all"); + } if (isClient()) { try { if (!FabricLoader.getInstance().isModLoaded("cloth-config2")) { @@ -69,4 +72,8 @@ public class RoughlyEnoughItemsInitializerImpl { } } } + + public static boolean isDev() { + return FabricLoader.getInstance().isDevelopmentEnvironment(); + } } diff --git a/fabric/src/main/java/me/shedaniel/rei/impl/client/fabric/ErrorDisplayerImpl.java b/fabric/src/main/java/me/shedaniel/rei/impl/client/fabric/ErrorDisplayerImpl.java new file mode 100644 index 000000000..ae6a0f9f3 --- /dev/null +++ b/fabric/src/main/java/me/shedaniel/rei/impl/client/fabric/ErrorDisplayerImpl.java @@ -0,0 +1,38 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021 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.fabric; + +import net.minecraft.client.gui.screens.Screen; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; + +public class ErrorDisplayerImpl { + public static List> consumerList = new ArrayList<>(); + + public static void registerGuiInit(Consumer consumer) { + consumerList.add(consumer); + } +} diff --git a/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinScreen.java b/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinScreen.java new file mode 100644 index 000000000..a14577a7f --- /dev/null +++ b/fabric/src/main/java/me/shedaniel/rei/mixin/fabric/MixinScreen.java @@ -0,0 +1,44 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021 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.mixin.fabric; + +import me.shedaniel.rei.impl.client.fabric.ErrorDisplayerImpl; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.Screen; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.function.Consumer; + +@Mixin(Screen.class) +public class MixinScreen { + @Inject(method = "init(Lnet/minecraft/client/Minecraft;II)V", at = @At("HEAD")) + private void init(Minecraft minecraft, int i, int j, CallbackInfo ci) { + for (Consumer consumer : ErrorDisplayerImpl.consumerList) { + consumer.accept((Screen) (Object) this); + } + } +} diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index bf7bf3d6b..3f1c179a0 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -29,6 +29,9 @@ ] }, "accessWidener": "roughlyenoughitems.accessWidener", + "mixins": [ + "rei.mixins.json" + ], "custom": { "rei:translators": { "English": ["shedaniel"], diff --git a/fabric/src/main/resources/rei.mixins.json b/fabric/src/main/resources/rei.mixins.json new file mode 100644 index 000000000..b7d1e7c81 --- /dev/null +++ b/fabric/src/main/resources/rei.mixins.json @@ -0,0 +1,14 @@ +{ + "required": true, + "package": "me.shedaniel.rei.mixin.fabric", + "compatibilityLevel": "JAVA_8", + "client": [ + "MixinScreen" + ], + "mixins": [ + ], + "injectors": { + "maxShiftBy": 5, + "defaultRequire": 1 + } +} diff --git a/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsInitializerImpl.java b/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsInitializerImpl.java index fa282697a..6baa7fd5c 100644 --- a/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsInitializerImpl.java +++ b/forge/src/main/java/me/shedaniel/rei/forge/RoughlyEnoughItemsInitializerImpl.java @@ -23,10 +23,9 @@ package me.shedaniel.rei.forge; -import me.shedaniel.rei.RoughlyEnoughItemsState; import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.loading.FMLEnvironment; +import net.minecraftforge.fml.loading.FMLLoader; public class RoughlyEnoughItemsInitializerImpl { public static boolean isClient() { @@ -34,10 +33,9 @@ public class RoughlyEnoughItemsInitializerImpl { } public static void checkMods() { - if (isClient()) { - if (!ModList.get().isLoaded("cloth-config")) { - RoughlyEnoughItemsState.error("Cloth Config is not installed!", "https://www.curseforge.com/minecraft/mc-mods/cloth-config/files/all"); - } - } + } + + public static boolean isDev() { + return !FMLLoader.isProduction(); } } diff --git a/forge/src/main/java/me/shedaniel/rei/impl/client/forge/ErrorDisplayerImpl.java b/forge/src/main/java/me/shedaniel/rei/impl/client/forge/ErrorDisplayerImpl.java new file mode 100644 index 000000000..5186c7884 --- /dev/null +++ b/forge/src/main/java/me/shedaniel/rei/impl/client/forge/ErrorDisplayerImpl.java @@ -0,0 +1,33 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021 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.forge; + +import net.minecraft.client.gui.screens.Screen; + +import java.util.function.Consumer; + +public class ErrorDisplayerImpl { + public static void registerGuiInit(Consumer consumer) { + } +} diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index 30ac8e0af..6aebf09b4 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -27,3 +27,10 @@ mandatory = true versionRange = "[1.10.139,)" ordering = "NONE" side = "BOTH" + +[[dependencies.roughlyenoughitems]] +modId = "cloth-config" +mandatory = true +versionRange = "[4.11.18,)" +ordering = "NONE" +side = "BOTH" diff --git a/runtime/build.gradle b/runtime/build.gradle index 3048fb3b7..4d7034ed3 100644 --- a/runtime/build.gradle +++ b/runtime/build.gradle @@ -1,3 +1,5 @@ +archivesBaseName = rootProject.name + "-" + project.name + architectury { common(forgeEnabled.toBoolean()) } diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsInitializer.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsInitializer.java index 8ba328334..78f118501 100644 --- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsInitializer.java +++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsInitializer.java @@ -24,12 +24,15 @@ package me.shedaniel.rei; import me.shedaniel.architectury.annotations.ExpectPlatform; +import net.fabricmc.api.EnvType; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public class RoughlyEnoughItemsInitializer { public static void onInitialize() { + RoughlyEnoughItemsState.env = isClient() ? EnvType.CLIENT : EnvType.SERVER; + RoughlyEnoughItemsState.isDev = isDev(); checkMods(); if (RoughlyEnoughItemsState.getErrors().isEmpty()) { @@ -82,6 +85,11 @@ public class RoughlyEnoughItemsInitializer { throw new AssertionError(); } + @ExpectPlatform + public static boolean isDev() { + throw new AssertionError(); + } + @ExpectPlatform public static void checkMods() { throw new AssertionError(); diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsState.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsState.java index 468ac0988..7ca37778f 100644 --- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsState.java +++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsState.java @@ -23,8 +23,7 @@ package me.shedaniel.rei; -import me.shedaniel.architectury.platform.Platform; -import me.shedaniel.architectury.utils.Env; +import net.fabricmc.api.EnvType; import net.minecraft.util.Tuple; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -41,6 +40,8 @@ public class RoughlyEnoughItemsState { public static final Logger LOGGER = LogManager.getFormatterLogger("REI"); + public static EnvType env; + public static boolean isDev; private static List> errors = new ArrayList<>(); private static List> warnings = new ArrayList<>(); private static Set errorSet = new LinkedHashSet<>(); @@ -48,7 +49,7 @@ public class RoughlyEnoughItemsState { private static List continueCallbacks = new ArrayList<>(); public static void error(String reason) { - if (Platform.getEnvironment() == Env.SERVER || Platform.isDevelopmentEnvironment()) + if (env == EnvType.SERVER || isDev) throw new RuntimeException(reason); if (RoughlyEnoughItemsState.errorSet.add(reason + " " + null)) { RoughlyEnoughItemsState.errors.add(new Tuple<>(reason, null)); @@ -57,7 +58,7 @@ public class RoughlyEnoughItemsState { } public static void error(String reason, String link) { - if (Platform.getEnvironment() == Env.SERVER || Platform.isDevelopmentEnvironment()) + if (env == EnvType.SERVER || isDev) throw new RuntimeException(reason + " " + link); if (RoughlyEnoughItemsState.errorSet.add(reason + " " + link)) { RoughlyEnoughItemsState.errors.add(new Tuple<>(reason, link)); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/ErrorDisplayer.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/ErrorDisplayer.java index e007f0ec8..b9e512bc9 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/ErrorDisplayer.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/ErrorDisplayer.java @@ -23,15 +23,19 @@ package me.shedaniel.rei.impl.client; +import me.shedaniel.architectury.annotations.ExpectPlatform; import me.shedaniel.architectury.event.events.GuiEvent; import me.shedaniel.rei.RoughlyEnoughItemsState; import me.shedaniel.rei.impl.client.gui.screen.WarningAndErrorScreen; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.Screen; import net.minecraft.world.InteractionResult; +import java.util.function.Consumer; + public class ErrorDisplayer { public void onInitializeClient() { - GuiEvent.INIT_PRE.register((screen, widgets, children) -> { + registerGuiInit((screen) -> { Minecraft minecraft = Minecraft.getInstance(); if ((!RoughlyEnoughItemsState.getErrors().isEmpty() || !RoughlyEnoughItemsState.getWarnings().isEmpty()) && !(screen instanceof WarningAndErrorScreen)) { WarningAndErrorScreen warningAndErrorScreen = new WarningAndErrorScreen("initialization", RoughlyEnoughItemsState.getWarnings(), RoughlyEnoughItemsState.getErrors(), (parent) -> { @@ -51,7 +55,11 @@ public class ErrorDisplayer { minecraft.screen = null; minecraft.setScreen(warningAndErrorScreen); } - return InteractionResult.PASS; }); } + + @ExpectPlatform + public static void registerGuiInit(Consumer consumer) { + throw new AssertionError(); + } } -- cgit