Amazon Ad

Tuesday, May 23, 2017

Moderate Minecraft Modding Tutorial Part 1: Setting Up with IntelliJ Part 1

Hello, everyone! I know I've been gone for a while, and I am sorry about that, but I am back with even better tutorials! I am going to show you how you can make even better mods with even better code! I will start with showing you how to set up your environment with JetBrains IDEA IntelliJ (which is now my new favorite IDE!) Let's start by obviously downloading and installing IntelliJ from here. Once you have gotten that installed, you are gonna want to go and get forge for 1.11.2 into a new separate folder somewhere on your computer. I will be using mappings for Minecraft Forge 1.11.2-13.20.0.2304. We are going to open IntelliJ and click on "Import Project..." (As shown below).


Navigate to your new project folder that you put your forge files in and double click build.gradle. Click Ok and it should open up a new window. (If your window is not dark theme you can configure it by doing some googling *wink wink*).

You're gonna want to navigate your mouse to the bottom left corner of IntelliJ and a list should pop up, including Gradle.



Click on Gradle and a new window should open on the right. Wait for the tasks to load and that might take a little while so give a bit. You should now see something like this,


Open up tasks and you should be able to view a bunch of different tasks. These tasks are performed through Gradle is how Forge organizes itself for obfuscation and compiling, and even releasing (which we will get to in a later post). Gradle is very useful for fetching code from remote locations and even executing tasks for a program. What we want to do is execute two different tasks, setupDecompWorkspace, and genIntellijRuns.

setupDecompWorkspace is going to setup our workspace so that we can view the minecraft source code along with the forge API. genIntellijRuns is going to setup our workspace to work with IntelliJ. When you run genIntelliJRuns, it will ask you to restart IntelliJ, which you will need to agree to do so in order for everything to work properly

To find these tasks you gotta go into tasks and go into forgegradle, and execute setupDecompWorkspace followed by genIntellijRuns. When these two tasks have completed and you have restarted your IDE, then you are going to need to set up your configurations. Before that, we need to refresh our workspace by clicking the refresh button at the top of our Gradle window. Now if you look in your External Libraries you should see forgeSrc-1.11.2-13.20.0.2304. We are now ready to start programming!

24 comments:

  1. When I try to set it up this way I get this:

    Error:Unable to start the daemon process.
    This problem might be caused by incorrect configuration of the daemon.
    For example, an unrecognized jvm option is used.
    Please refer to the user guide chapter on the daemon at https://docs.gradle.org/2.14/userguide/gradle_daemon.html
    Please read the following process output to find out more:
    -----------------------
    Error occurred during initialization of VM
    Could not reserve enough space for 3145728KB object heap

    ReplyDelete
    Replies
    1. You might want to reinstall your JVM. It might be outdated so you might need to update it. If you are up to date, then your JVM arguments are configured incorrectly.

      Delete
    2. That was it, thanks. I pointed it to the wrong jdk version.

      Delete
  2. Complete newbie, utterly confused by "Navigate to your new project folder that you put your forge files in". Is it AppData\Roaming\.minecraft\libraries\net\minecraftforge\forge\1.11.2-13.20.0.2315 or should I be making a new folder there, or somewhere else?

    Thanks

    ReplyDelete
    Replies
    1. No, it's the folder you created to store your workspace in. The part where you dragged and dropped your forge workspace into a blank folder.

      Delete
  3. I keep getting Gradle location is incorrect. What is the issue here?

    ReplyDelete
    Replies
    1. I honestly have never heard that one before. Are you sure you've got your gradle installed on your system? Forge Gradle should install it for you.

      Delete
    2. Im not sure what you mean by it was supposed to install it for me. I followed the instructions here and you didn't tell me i was supposed to install Gradle at all.

      Delete
    3. Nor did you mention which Forge file to get, i grabbed the MDK one since that's what i thought you're supposed to get.

      Delete
    4. I could have swore that I specified to go to the original set up first for details about getting forge and whatnot. But basically, yes you get the MDK, as that stands for Mod Development Kit. Also, with a quick google search, I found that your intellij is pointing to gradle in the wrong place. Below is a stackoverflow thread that should answer your question.
      https://stackoverflow.com/questions/17623439/gradle-location-is-incorrect-error-while-importing-actionbarsherlock-in-android

      Delete
  4. It says JAVA_HOME(not defined)...

    ReplyDelete
  5. Is "build.gradle" a file? I extracted the JAR file that forge comes in and didn't find anything

    ReplyDelete
    Replies
    1. nvm i realized i downloaded forge installer instead of the MDK

      Delete
  6. FYI: If you see an error with refreshing or executing gradle scripts like about '_BuildScript_' unsupported target MODULE -- take a look at https://youtrack.jetbrains.com/issue/IDEA-171520#u=1506468536848 (I set up a Java8 runtime -- one was already present with intellij, but I downloaded a new one and set it as the project JDK; then I changed global gradle settings to use the Java8 JDK and got past that error).

    ReplyDelete
    Replies
    1. Ah thank for the heads up! (Sorry for the uber late reply, I stopped getting notifications for whatever reason.)

      Delete
  7. I did exactly the same as in the tutorial, but I don't see
    forgeSrc-1.11.2-13.20.0.2304 in External Libraries. Please help me.

    ReplyDelete
    Replies
    1. Sorry for the late reply, I never get notifications for comments anymore. I used to, though. Yeah, as the title suggests, this is an intermediate level tutorials. But the answer to that is you need to make sure that you ran through the "setupDecompWorkspace" then "genIntellijRuns" in that order, then click the refresh button in the window on the right. That should get you the forgeSrc

      Delete
    2. If someone else gets this, I ran through those back to back and did not get the forgeSrc in my external libraries. So I ran the genIntellijRuns again and that fixed it.

      Delete
  8. Please help me!!!!
    I did it the exact same way, but it says "This mapping 'snapshot_20161220' was designed for MC 1.11! Use at your own peril." at the beginning and "* What went wrong:
    Execution failed for task ':fixMcSources'.
    > com.cloudbees.diff.PatchException: Cannot find hunk target," I don't know what's wrong at all, please help me!!!!!!

    ReplyDelete
    Replies
    1. Don't worry about the mappings warning. That happens regardless. It's totally fine. A failed ":fixMcSources" is...not really something I understand cause I've never ran into it. Have you tried running it again? Just in case it was a one time thing?

      Delete
  9. It isn't asking me if I want to restart the program after running both commands.

    ReplyDelete
  10. where can I find the Gradle JVM??

    ReplyDelete
  11. Having trouble with the Intelli J thing, it's telling me about a activation code or what not, but this is basically a pay wall, whats up with this did i do something wrong?

    ReplyDelete