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 --- .../java/me/shedaniel/rei/impl/client/config/ConfigObjectImpl.java | 6 +++--- .../java/me/shedaniel/rei/impl/common/entry/AbstractEntryStack.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'runtime/src/main/java/me/shedaniel') 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 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 --- .../java/me/shedaniel/rei/RoughlyEnoughItemsInitializer.java | 8 ++++++++ .../main/java/me/shedaniel/rei/RoughlyEnoughItemsState.java | 9 +++++---- .../java/me/shedaniel/rei/impl/client/ErrorDisplayer.java | 12 ++++++++++-- 3 files changed, 23 insertions(+), 6 deletions(-) (limited to 'runtime/src/main/java/me/shedaniel') 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