diff --git a/src/main/java/com/nomiceu/nomilabs/NomiLabs.java b/src/main/java/com/nomiceu/nomilabs/NomiLabs.java index 527e4a4..3a5146e 100644 --- a/src/main/java/com/nomiceu/nomilabs/NomiLabs.java +++ b/src/main/java/com/nomiceu/nomilabs/NomiLabs.java @@ -65,6 +65,7 @@ public void preInit(FMLPreInitializationEvent event) { @EventHandler public void postInit(FMLPostInitializationEvent event) { + CommonProxy.postInit(); if (LabsSide.isClient()) ClientProxy.postInit(); } diff --git a/src/main/java/com/nomiceu/nomilabs/event/CommonProxy.java b/src/main/java/com/nomiceu/nomilabs/event/CommonProxy.java index da1e4c4..3ff6b09 100644 --- a/src/main/java/com/nomiceu/nomilabs/event/CommonProxy.java +++ b/src/main/java/com/nomiceu/nomilabs/event/CommonProxy.java @@ -107,6 +107,10 @@ public static void preInit() { LabsDimensions.register(); } + public static void postInit() { + LabsModeHelper.onPostInit(); + } + public static void loadComplete() { FluidRegistryMixinHelper.loadComplete(); diff --git a/src/main/java/com/nomiceu/nomilabs/groovy/GroovyHelpers.java b/src/main/java/com/nomiceu/nomilabs/groovy/GroovyHelpers.java index 90c5d08..bbd7193 100644 --- a/src/main/java/com/nomiceu/nomilabs/groovy/GroovyHelpers.java +++ b/src/main/java/com/nomiceu/nomilabs/groovy/GroovyHelpers.java @@ -18,6 +18,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fml.common.Loader; +import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -422,7 +423,9 @@ public static ChancedFluidOutput chanced(FluidStack fluid, int chance, int chanc return new ChancedFluidOutput(fluid, chance, chanceBoost); } + @Contract("_ -> new") public static GTRecipeInput toGtInput(IIngredient ingredient) { + // noinspection Contract return RecipeBuilderAccessor.ofGroovyIngredient(ingredient); } } diff --git a/src/main/java/com/nomiceu/nomilabs/mixin/vanilla/DedicatedServerMixin.java b/src/main/java/com/nomiceu/nomilabs/mixin/vanilla/DedicatedServerMixin.java index afbf5a4..0c8da12 100644 --- a/src/main/java/com/nomiceu/nomilabs/mixin/vanilla/DedicatedServerMixin.java +++ b/src/main/java/com/nomiceu/nomilabs/mixin/vanilla/DedicatedServerMixin.java @@ -90,7 +90,6 @@ public void changeInitDifficulty(CallbackInfoReturnable cir) { NomiLabs.LOGGER.warn("-----------------------------------------------"); NomiLabs.LOGGER.warn("==============================================="); - } } diff --git a/src/main/java/com/nomiceu/nomilabs/util/LabsModeHelper.java b/src/main/java/com/nomiceu/nomilabs/util/LabsModeHelper.java index 411eae3..147eeee 100644 --- a/src/main/java/com/nomiceu/nomilabs/util/LabsModeHelper.java +++ b/src/main/java/com/nomiceu/nomilabs/util/LabsModeHelper.java @@ -16,25 +16,18 @@ public class LabsModeHelper { private static boolean checked = false; + private static boolean postInitPassed = false; @Nullable private static String modePreCache = null; public static boolean isNormal() { - if (!checked) - throw new IllegalStateException("Cannot access Pack Mode before Post Init or Labs Config Load!"); return getMode().equals(LabsValues.NORMAL_MODE); } public static boolean isExpert() { - if (!checked) - throw new IllegalStateException("Cannot access Pack Mode before Post Init or Labs Config Load!"); return getMode().equals(LabsValues.EXPERT_MODE); } - /** - * Used by Nomi-CEu Rich Presence. - */ - @SuppressWarnings("unused") public static String getFormattedMode() { return StringUtils.capitalize(getMode()); } @@ -43,8 +36,11 @@ public static String getFormattedMode() { * Get the Mode (at all times) */ public static String getMode() { + if (!postInitPassed) return getModePre(); + // Reflection: // ClassNotFound Exception Thrown if PMConfig not loaded + // (Just in Case, Prevent Load in Pre) try { // Prevent loading Static Init, use MC Mod Loader var pmCfgClass = Class.forName("io.sommers.packmode.PMConfig", false, @@ -64,7 +60,9 @@ public static String getMode() { } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { // PackMode not loaded - return getModePre(); + // Throw, causes problems with cleanroom if we did this + throw new RuntimeException( + "Tried to get mode when PMConfig class is not loaded! Fatal error, this should not happen! Report to Nomi-Labs devs!"); } } @@ -96,6 +94,10 @@ public static void check() { if (!checked) getMode(); // Will check, whether it uses getModePre or PMConfig.getPackMode } + public static void onPostInit() { + postInitPassed = true; + } + private static void check(String mode) { checked = true; if (LabsConfig.advanced.allowOtherPackModes) return;