Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Using Intellij IDEA for Mod-Development with ForgeGradle


Recommended Posts

Note (Sep. 2017): This post is now getting very old, but it still applies. Regardless you might want to refer to the IntelliJ section in the official Getting Started guide instead.

 

In this Tutorial I will describe how you can use the Intellij IDEA IDE for Mod-Development.

 

First, you are going to need to download the Mod Development Kit ("MDK") package from http://files.minecraftforge.net/ ("src" for old versions) and unzip it.

 

Next, start up Intellij. If you already have a Project opened, select File > Open, otherwise select "Open Project". Navigate to the directory where you unzipped Forge to and select the build.gradle file. Leave the import-settings at default and click OK.

Intellij will now take a while to import the project. Once that's done, open the Gradle-sidebar.

If the sidebar is not visible, click the view-switcher in the bottom-left corner: oeiuGXW.png

 

Select the setupDecompWorkspace task from the list and run it (double-click). If you don't need the Minecraft source code visible, run setupDevWorkspace instead, it will be faster.

Once the task has finished, click the Refresh button in the Gradle-sidebar. That will again take a moment. Once Intellij has finished refreshing, your project is already almost ready to go. You should be able to see all the libraries used by Forge & Minecraft on the left and also the source code for the ExampleMod inside src/main/java.

 

All that is left to do are the run configurations, so that you can actually start Minecraft. For those again open the Gradle sidebar and run the genIntellijRuns task. Intellij might ask to reload the project, click OK if it does.

 

If your run configurations show an error in most recent versions of IntelliJ you have to go into Run > Edit Configurations and adjust both run configurations like shown below.

49qpav0.png

 

That's it!

Edited by diesieben07
Updated for new forum and new ForgeGradle / IntelliJ versions
  • Like 2
Link to comment
Share on other sites

I followed this and discovered this problem when trying to run the client:

 

/usr/lib/jvm/java-7-oracle/bin/java -Xincgc -Xmx1024M -Xms1024M -Djava.library.path=/home/jorrit/mc/forge_1.7.10_src/build/natives -Dfml.ignoreInvalidMinecraftCertificates=true -Didea.launcher.port=7533 -Didea.launcher.bin.path=/home/jorrit/idea-IC-135.909/bin -Dfile.encoding=UTF-8 -classpath /usr/lib/jvm/java-7-oracle/jre/lib/deploy.jar:/usr/lib/jvm/java-7-oracle/jre/lib/charsets.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jce.jar:/usr/lib/jvm/java-7-oracle/jre/lib/management-agent.jar:/usr/lib/jvm/java-7-oracle/jre/lib/plugin.jar:/usr/lib/jvm/java-7-oracle/jre/lib/javaws.jar:/usr/lib/jvm/java-7-oracle/jre/lib/resources.jar:/usr/lib/jvm/java-7-oracle/jre/lib/rt.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jfr.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jfxrt.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jsse.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/zipfs.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/localedata.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/sunpkcs11.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/dnsns.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/sunec.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/sunjce_provider.jar:/home/jorrit/mc/forge_1.7.10_src/classes/production/forge_1.7.10_src:/home/jorrit/.gradle/caches/minecraft/net/minecraftforge/forge/1.7.10-10.13.0.1186/start:/home/jorrit/.gradle/caches/minecraft/net/minecraftforge/forge/1.7.10-10.13.0.1186/forgeSrc-1.7.10-10.13.0.1186.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/net.minecraft/launchwrapper/1.9/116f2aad5b0c68353ebed66cd463517db6522f7e/launchwrapper-1.9.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm-debug-all/4.1/dd6ba5c392d4102458494e29f54f70ac534ec2a2/asm-debug-all-4.1.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/com.typesafe.akka/akka-actor_2.11/2.3.3/ed62e9fc709ca0f2ff1a3220daa8b70a2870078e/akka-actor_2.11-2.3.3.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/com.typesafe/config/1.2.1/f771f71fdae3df231bcd54d5ca2d57f0bf93f467/config-1.2.1.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-actors-migration_2.11/1.1.0/dfa8bc42b181d5b9f1a5dd147f8ae308b893eb6f/scala-actors-migration_2.11-1.1.0.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-compiler/2.11.1/56ea2e6c025e0821f28d73ca271218b8dd04926a/scala-compiler-2.11.1.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/org.scala-lang.plugins/scala-continuations-library_2.11/1.0.2/e517c53a7e9acd6b1668c5a35eccbaa3bab9aac/scala-continuations-library_2.11-1.0.2.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/org.scala-lang.plugins/scala-continuations-plugin_2.11.1/1.0.2/f361a3283452c57fa30c1ee69448995de23c60f7/scala-continuations-plugin_2.11.1-1.0.2.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-library/2.11.1/e11da23da3eabab9f4777b9220e60d44c1aab6a/scala-library-2.11.1.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/org.scala-lang.modules/scala-parser-combinators_2.11/1.0.1/f05d7345bf5a58924f2837c6c1f4d73a938e1ff0/scala-parser-combinators_2.11-1.0.1.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-reflect/2.11.1/6580347e61cc7f8e802941e7fde40fa83b8badeb/scala-reflect-2.11.1.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-swing_2.11/1.0.1/b1cdd92bd47b1e1837139c1c53020e86bb9112ae/scala-swing_2.11-1.0.1.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/org.scala-lang.modules/scala-xml_2.11/1.0.2/820fbca7e524b530fdadc594c39d49a21ea0337e/scala-xml_2.11-1.0.2.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/net.sf.jopt-simple/jopt-simple/4.5/6065cc95c661255349c1d0756657be17c29a4fd3/jopt-simple-4.5.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/lzma/lzma/0.0.1/521616dc7487b42bef0e803bd2fa3faf668101d7/lzma-0.0.1.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/com.mojang/realms/1.3.1/f78f5a841b1cf9d50c3382acdbeb7d3078e454d6/realms-1.3.1.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-compress/1.8.1/a698750c16740fd5b3871425f4cb3bbaa87f529d/commons-compress-1.8.1.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpclient/4.3.3/18f4247ff4572a074444572cee34647c43e7c9c7/httpclient-4.3.3.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/commons-logging/commons-logging/1.1.3/f6f66e966c70a83ffbdb6f17a0919eaf7c8aca7f/commons-logging-1.1.3.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpcore/4.3.2/31fbbff1ddbf98f3aa7377c94d33b0447c646b6e/httpcore-4.3.2.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/java3d/vecmath/1.3.1/a0ae4f51da409fa0c20fa0ca59e6bbc9413ae71d/vecmath-1.3.1.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/net.sf.trove4j/trove4j/3.0.3/42ccaf4761f0dfdfa805c9e340d99a755907e2dd/trove4j-3.0.3.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/com.ibm.icu/icu4j-core-mojang/51.2/63d216a9311cca6be337c1e458e587f99d382b84/icu4j-core-mojang-51.2.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/com.paulscode/codecjorbis/20101023/c73b5636faf089d9f00e8732a829577de25237ee/codecjorbis-20101023.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/com.paulscode/codecwav/20101023/12f031cfe88fef5c1dd36c563c0a3a69bd7261da/codecwav-20101023.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/com.paulscode/libraryjavasound/20101123/5c5e304366f75f9eaa2e8cca546a1fb6109348b3/libraryjavasound-20101123.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/com.paulscode/librarylwjglopenal/20100824/73e80d0794c39665aec3f62eee88ca91676674ef/librarylwjglopenal-20100824.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/com.paulscode/soundsystem/20120107/419c05fe9be71f792b2d76cfc9b67f1ed0fec7f6/soundsystem-20120107.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/io.netty/netty-all/4.0.10.Final/9e50bd52ffe257a0e2cd8d971688d6ce7d174325/netty-all-4.0.10.Final.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/commons-io/commons-io/2.4/b1b6ea3b7e4aa4f492509a4952029cd8e48019ad/commons-io-2.4.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/commons-codec/commons-codec/1.9/9ce04e34240f674bc72680f8b843b1457383161a/commons-codec-1.9.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/net.java.jinput/jinput/2.0.5/39c7796b469a600f72380316f6b1f11db6c2c7c4/jinput-2.0.5.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/net.java.jutils/jutils/1.0.0/e12fe1fda814bd348c1579329c86943d2cd3c6a6/jutils-1.0.0.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/com.google.code.gson/gson/2.2.4/a60a5e993c98c864010053cb901b7eab25306568/gson-2.2.4.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/com.mojang/authlib/1.5.16/ef1582b11fd0943d069cdcb72e99008ac209a283/authlib-1.5.16.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-api/2.0-beta9/1dd66e68cccd907880229f9e2de1314bd13ff785/log4j-api-2.0-beta9.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-core/2.0-beta9/678861ba1b2e1fccb594bb0ca03114bb05da9695/log4j-core-2.0-beta9.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/org.lwjgl.lwjgl/lwjgl/2.9.1/f58c5aabcef0e41718a564be9f8e412fff8db847/lwjgl-2.9.1.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/org.lwjgl.lwjgl/lwjgl_util/2.9.1/290d7ba8a1bd9566f5ddf16ad06f09af5ec9b20e/lwjgl_util-2.9.1.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/tv.twitch/twitch/5.16/1f55f009c61637c10c0acfb8b5ffc600f30044b4/twitch-5.16.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-actors/2.11.0/8ccfb6541de179bb1c4d45cf414acee069b7f78b/scala-actors-2.11.0.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/net.java.jinput/jinput-platform/2.0.5/7ff832a6eb9ab6a767f1ade2b548092d0fa64795/jinput-platform-2.0.5-natives-linux.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/net.java.jinput/jinput-platform/2.0.5/385ee093e01f587f30ee1c8a2ee7d408fd732e16/jinput-platform-2.0.5-natives-windows.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/net.java.jinput/jinput-platform/2.0.5/53f9c919f34d2ca9de8c51fc4e1e8282029a9232/jinput-platform-2.0.5-natives-osx.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/tv.twitch/twitch-platform/5.16/7c6affe439099806a4f552da14c42f9d643d8b23/twitch-platform-5.16-natives-windows-32.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/tv.twitch/twitch-platform/5.16/39d0c3d363735b4785598e0e7fbf8297c706a9f9/twitch-platform-5.16-natives-windows-64.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/tv.twitch/twitch-platform/5.16/62503ee712766cf77f97252e5902786fd834b8c5/twitch-platform-5.16-natives-osx.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/tv.twitch/twitch-external-platform/4.5/18215140f010c05b9f86ef6f0f8871954d2ccebf/twitch-external-platform-4.5-natives-windows-32.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/tv.twitch/twitch-external-platform/4.5/c3cde57891b935d41b6680a9c5e1502eeab76d86/twitch-external-platform-4.5-natives-windows-64.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/org.lwjgl.lwjgl/lwjgl-platform/2.9.1/4c517eca808522457dd95ee8fc1fbcdbb602efbe/lwjgl-platform-2.9.1-natives-windows.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/org.lwjgl.lwjgl/lwjgl-platform/2.9.1/aa9aae879af8eb378e22cfc64db56ec2ca9a44d1/lwjgl-platform-2.9.1-natives-linux.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/org.lwjgl.lwjgl/lwjgl-platform/2.9.1/2d12c83fdfbc04ecabf02c7bc8cc54d034f0daac/lwjgl-platform-2.9.1-natives-osx.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/17.0/9c6ef172e8de35fd8d4d8783e4821e57cdef7445/guava-17.0.jar:/home/jorrit/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-lang3/3.3.2/90a3822c38ec8c996e84c16a3477ef632cbc87a3/commons-lang3-3.3.2.jar:/home/jorrit/idea-IC-135.909/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain GradleStart
[19:40:19] [main/INFO] [GradleStart]: No arguments specified, assuming client.
[19:40:19] [main/INFO] [GradleStart]: Extra: []
Exception in thread "main" java.lang.RuntimeException: java.io.FileNotFoundException: /home/jorrit/.gradle/caches/minecraft/assets/indexes/{ASSET_INDEX}.json (No such file or directory)
at com.google.common.base.Throwables.propagate(Throwables.java:160)
at GradleStart.setupAssets(GradleStart.java:274)
at GradleStart.startClient(GradleStart.java:82)
at GradleStart.main(GradleStart.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: java.io.FileNotFoundException: /home/jorrit/.gradle/caches/minecraft/assets/indexes/{ASSET_INDEX}.json (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at java.io.FileReader.<init>(FileReader.java:72)
at GradleStart.loadAssetsIndex(GradleStart.java:280)
at GradleStart.setupAssets(GradleStart.java:218)
... 7 more

Process finished with exit code 1

 

Anything I missed?

Link to comment
Share on other sites

Actually that works! Thanks a lot. Now I need to make my very first mod :-)

 

I do have another question though. Now to add my own mod I suppose I need to make a module? I did that and copied the example mod code from forge. Added Forge dependencies and it compiles fine. However, how can I change my run configuration to actually add my mod when I run MC?

 

Thanks!

Link to comment
Share on other sites

I'm a bit confused on how to setup IntelliJ/gradle and github so that I can have a github repository with several mods (each with source and assets) and how to integrade that into the src/main/java dirs and src/main/resources. Is there a good guide on how to set that up with MC and IntelliJ in mind?

 

That's initially why I thought of using modules so that every module could have its own github directory but now it seems that I have to split assets and source?

 

Thanks,

Link to comment
Share on other sites

Hmm, doesn't that take up a lot of disk space? Seems not very handy to work like that. Especially if the mods are supposed to work together. Also that still doesn't solve how I can get the separate 'src/main/java' and 'src/main/resources' into a single github repository?

Link to comment
Share on other sites

Why do you want a single repository? That makes no sense. One Repo per mod.

And no, it does not take up a lot of disk space. All the dependencies (including forge, minecraft and their sourcecode) is stored in a central location, thanks to gradle. Even if you have 100 workspaces using the same forge version, you will only get one jar file containing forge, which is used by all workspaces.

Link to comment
Share on other sites

Yes I mean one repo for one mod. But the problem is that that repo should contain both the source and the assets dir. But the build dir contains separate src and resource folders. How do I map the folders on my HD to the single repository on github?

Link to comment
Share on other sites

Ok, but that example doesn't seem to have any resources/assets. And that's my problem. With the actual mod it has to be called 'assets' but it is called 'resources' in the project that I created. I guess I'm a bit confused how I could get my assets in the correct place in the github repository.

 

Ah oops! Missed the resources inside the main folder. Sorry!

Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...
  • 3 weeks later...

I'm trying to rebuild everything on IntelliJ IDEA 14.0 Ultimate (Yes i bought it). But it gives a crash when adding your fix for assets : Error:(1,0) Gradle DSL method not found: 'sourceSets()', is that normal ?

 

After second problem, when i arrive to rebuild the workspace without the crashing line of code (sourceSets thing), my game launches, forge find my mod, but no assets can be compiled, i tried everything and nothing works. The only way i found is forcing resource building by copying folders myself on the classes output folder.

 

 

EDIT : Ok, it's working now, just needed to add the spetial line of code after the rest of the file build.gradle

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share




×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.