Skip to content

Commit

Permalink
Fix other MinecraftHelpers.* causing crashes at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Aug 24, 2024
1 parent 6d145fe commit cc9947e
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.cyclops.cyclopscore.helper;

import cpw.mods.modlauncher.TransformingClassLoader;
import net.minecraft.DetectedVersion;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.core.BlockPos;
Expand All @@ -9,6 +11,9 @@
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import net.neoforged.fml.loading.FMLEnvironment;
import net.neoforged.fml.loading.FMLLoader;

import java.util.Arrays;

/**
* Contains helper methods for various minecraft specific things.
Expand Down Expand Up @@ -65,7 +70,7 @@ public static boolean isPlayerInventoryFull(Player player) {
* @return If we are currently running inside a deobfuscated development environment.
*/
public static boolean isDevEnvironment() {
return IModHelpers.get().getMinecraftHelpers().isDevEnvironment();
return !FMLLoader.isProduction();
}

/**
Expand All @@ -79,22 +84,22 @@ public static boolean isMinecraftInitialized() {
* @return The Minecraft version (e.g. "1.14.4")
*/
public static String getMinecraftVersion() {
return IModHelpers.get().getMinecraftHelpers().getMinecraftVersion();
return DetectedVersion.BUILT_IN.getName();
}

/**
* @return The Minecraft major and minor version (e.g. "1.14")
*/
public static String getMinecraftVersionMajorMinor() {
return IModHelpers.get().getMinecraftHelpers().getMinecraftVersionMajorMinor();
return String.join(".", Arrays.asList(getMinecraftVersion().split("\\.")).subList(0, 2));
}

/**
* Check if we are inside a modded minecraft environment.
* @return If in minecraft.
*/
public static boolean isModdedEnvironment() {
return IModHelpers.get().getMinecraftHelpers().isModdedEnvironment();
return MinecraftHelpersNeoForge.class.getClassLoader() instanceof TransformingClassLoader;
}

/**
Expand Down

0 comments on commit cc9947e

Please sign in to comment.