diff options
| author | shedaniel <daniel@shedaniel.me> | 2021-05-17 21:41:37 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2021-05-17 21:41:37 +0800 |
| commit | 943c7aab9fe4dac5801d5dfa9af2611331eccd78 (patch) | |
| tree | 5956ccecec82a594830fcb6a8855b7a633595859 /runtime/src/main | |
| parent | 0cd2336ababe5d6c78a64943adde5b54cb3e72b6 (diff) | |
| parent | 745f78a4aa7d23fe03e7420eb3fe06b8c418db35 (diff) | |
| download | RoughlyEnoughItems-943c7aab9fe4dac5801d5dfa9af2611331eccd78.tar.gz RoughlyEnoughItems-943c7aab9fe4dac5801d5dfa9af2611331eccd78.tar.bz2 RoughlyEnoughItems-943c7aab9fe4dac5801d5dfa9af2611331eccd78.zip | |
Merge remote-tracking branch 'origin/6.x' into 6.x-1.17
Diffstat (limited to 'runtime/src/main')
5 files changed, 27 insertions, 10 deletions
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()) { @@ -83,6 +86,11 @@ public class RoughlyEnoughItemsInitializer { } @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<Tuple<String, String>> errors = new ArrayList<>(); private static List<Tuple<String, String>> warnings = new ArrayList<>(); private static Set<String> errorSet = new LinkedHashSet<>(); @@ -48,7 +49,7 @@ public class RoughlyEnoughItemsState { private static List<Runnable> 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<Screen> consumer) { + throw new AssertionError(); + } } 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 8d2f2b05b..9279a7f51 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<A> extends AbstractRenderer implements public Tooltip getTooltip(Point mouse, boolean appendModName) { Mutable<Tooltip> tooltip = new MutableObject<>(getRenderer().<A>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) { |
