diff --git a/gradle.properties b/gradle.properties
index 6f45dd6..55f3a6d 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -15,15 +15,15 @@ autoUpdateBuildScript = false
minecraftVersion = 1.7.10
forgeVersion = 10.13.4.1614
-# Select a username for testing your mod with breakpoints. You may leave this empty for a random user name each time you
+# Select a username for testing your mod with breakpoints. You may leave this empty for a random username each time you
# restart Minecraft in development. Choose this dependent on your mod:
# Do you need consistent player progressing (for example Thaumcraft)? -> Select a name
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
-developmentEnvironmentUserName = "Developer"
+developmentEnvironmentUserName = Developer
# Define a source file of your project with:
# public static final String VERSION = "GRADLETOKEN_VERSION";
-# The string's content will be replaced with your mods version when compiled. You should use this to specify your mod's
+# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...])
# Leave these properties empty to skip individual token replacements
replaceGradleTokenInFile = CodeChickenCoreModContainer.java
@@ -32,7 +32,7 @@ gradleTokenModName = GRADLETOKEN_MODNAME
gradleTokenVersion = GRADLETOKEN_VERSION
gradleTokenGroupName =
-# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise you can
+# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
# leave this property empty.
# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api
apiPackage =
@@ -48,7 +48,7 @@ mixinPlugin =
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
mixinsPackage =
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
-# This parameter is for legacy compatability only
+# This parameter is for legacy compatibility only
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
coreModClass = core.launch.CodeChickenCorePlugin
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
diff --git a/src/main/java/codechicken/core/launch/CodeChickenCorePlugin.java b/src/main/java/codechicken/core/launch/CodeChickenCorePlugin.java
index 5ff5ebf..284b84d 100644
--- a/src/main/java/codechicken/core/launch/CodeChickenCorePlugin.java
+++ b/src/main/java/codechicken/core/launch/CodeChickenCorePlugin.java
@@ -1,9 +1,11 @@
package codechicken.core.launch;
-import java.awt.Desktop;
+import java.awt.*;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
+import java.text.CharacterIterator;
+import java.text.StringCharacterIterator;
import java.util.List;
import java.util.Map;
import java.util.jar.Attributes;
@@ -16,6 +18,7 @@ import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import codechicken.core.asm.*;
+import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.CoreModManager;
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
@@ -91,6 +94,64 @@ public class CodeChickenCorePlugin implements IFMLLoadingPlugin, IFMLCallHook
}
}
+ public static long parseSize(String text) {
+ double d = Double.parseDouble(text.replaceAll("[GMK]B?$", ""));
+ long l = Math.round(d * 1024 * 1024 * 1024L);
+ switch (text.replaceAll("\\d?","").toUpperCase().charAt(0)) {
+ default: l /= 1024;
+ case 'K': l /= 1024;
+ case 'M': l /= 1024;
+ case 'G': return l;
+ }
+ }
+
+ public static String humanReadableByteCountBin(long bytes) {
+ long absB = bytes == Long.MIN_VALUE ? Long.MAX_VALUE : Math.abs(bytes);
+ if (absB < 1024) {
+ return bytes + " B";
+ }
+ long value = absB;
+ CharacterIterator ci = new StringCharacterIterator("KMGTPE");
+ for (int i = 40; i >= 0 && absB > 0xfffccccccccccccL >> i; i -= 10) {
+ value >>= 10;
+ ci.next();
+ }
+ value *= Long.signum(bytes);
+ return String.format("%.1f %cB", value / 1024.0, ci.current());
+ }
+
+ public static void systemCheck(String minRAM) {
+ long minBytes = parseSize(minRAM);
+ if (Runtime.getRuntime().maxMemory() < minBytes) {
+ String err = "You should have at least " + minRAM + " of RAM but you have only allocated " + humanReadableByteCountBin(Runtime.getRuntime().maxMemory()) + ".";
+ logger.error(err);
+
+ JEditorPane ep = new JEditorPane("text/html",
+ "" +
+ err +
+ "
GTNH seriously won't run without enough RAM. See the Wiki for details." +
+ "
Recommended values are between 4GB and 6GB. Check your launcher's JVM arguments." +
+ "");
+
+ ep.setEditable(false);
+ ep.setOpaque(false);
+ ep.addHyperlinkListener(new HyperlinkListener()
+ {
+ @Override
+ public void hyperlinkUpdate(HyperlinkEvent event) {
+ try {
+ if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
+ Desktop.getDesktop().browse(event.getURL().toURI());
+ } catch (Exception ignored) {}
+ }
+ });
+
+ if (!GraphicsEnvironment.isHeadless())
+ JOptionPane.showMessageDialog(null, ep, "lol nope", JOptionPane.ERROR_MESSAGE);
+ FMLCommonHandler.instance().exitJava(-98, true);
+ }
+ }
+
@Override
public String[] getASMTransformerClass() {
versionCheck(mcVersion, "CodeChickenCore");
@@ -124,6 +185,7 @@ public class CodeChickenCorePlugin implements IFMLLoadingPlugin, IFMLCallHook
@Override
public Void call() {
CodeChickenCoreModContainer.loadConfig();
+ systemCheck(CodeChickenCoreModContainer.config.getTag("minRAM").getValue("3GB"));
TweakTransformer.load();
scanCodeChickenMods();
diff --git a/src/main/java/codechicken/core/launch/DepLoader.java b/src/main/java/codechicken/core/launch/DepLoader.java
index c4f46b5..bf4e7d7 100644
--- a/src/main/java/codechicken/core/launch/DepLoader.java
+++ b/src/main/java/codechicken/core/launch/DepLoader.java
@@ -186,7 +186,7 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
}
});
- JOptionPane.showMessageDialog(null, ep, "A download error has occured", JOptionPane.ERROR_MESSAGE);
+ JOptionPane.showMessageDialog(null, ep, "A download error has occurred", JOptionPane.ERROR_MESSAGE);
}
}