All users will need to merge their Minecraft Forum account with a new or existing Twitch account starting October 23rd. You can merge your accounts by clicking here. Have questions? Learn more here.
Dismiss
  • 2

    posted a message on [1.7.x] Modding with Forge #3 - The Basics of 1.7.x Mod Creation
    [1.7.x] Modding with Forge #3 - The Basics of 1.7.x Mod Creation

    Hello and, finally, welcome back to the long overdue third tutorial in my Modding with Forge series. It's only taken me 7 months to get around to this tutorial, so I really hope that the series restarts with a bang!

    In the previous two tutorials, we have looked at how to set up Eclipse, Forge and Gradle and now have all three working in collaboration with each other. For anybody who is struggling with setting up Minecraft Forge, especially version 1.7.10, take a look through the previous two tutorials again, since I have added some little pointers throughout the tutorial that explain how I have set it up with 1.7.10 to get it working, since some things, though not many, are a little bit different.

    Now, instead of boring you with the basics of setting up your mod structure, which I am sure you already know how to do, I have pre-coded the required code for this tutorial, which can be found here (Episode 3 startup). If there is anything you don't understand about this code, look back at my tutorials for 1.6.4 and, if you are still confused after this, let me know in the comments below and I'll explain it as best as I can.

    Now, the next thing we need to do is actually get the code to work properly. You may have noticed that, when typing out (or copying) my source code, that you may get some import errors. The reason for this (if you are experiencing them) is because your project does not know it should be using Forge as a dependency.

    Okay, so what the h**l am I talking about? Your project needs a dependency project... What? Well, currently, your eclipse should look like this. To fix the dependency issues and, then, the import issues, you want to right click on your project (mine is called "MCForums"). Right at the bottom, there is an option called "Properties"; click on that and it will open this view. Go to the option called "Java Build Path" and then, at the top of the view, select "Projects". Currently, the view should be empty. Select "Add..." on the right and then tick the Forge project. Press "OK" twice, so that both the windows close.

    Now, if you go into the "Tutorial" class file, or wherever your import errors are occurring, press 'Ctrl' ('Command' on Mac), 'Shift' and 'O'. You should now have 4 imports:
     import cpw.mods.fml.common.Mod;
    import cpw.mods.fml.common.event.FMLInitializationEvent;
    import cpw.mods.fml.common.event.FMLPostInitializationEvent;
    import cpw.mods.fml.common.event.FMLPreInitializationEvent;

    This is the basics of your mod file; the empty skeleton that we will fill with our content.

    If you are having any troubles with the build.gradle file from the last tutorial, feel free to check mine out at the BitBucket page (linked at the start of this tutorial). If you don't understand anything that I have explained in this tutorial, please take a look at the 1.6.x tutorials that I have written (there is an in-depth one explaining everything we have just done here) before commenting below.

    End of Tutorial

    This is the end of Modding with Forge #3 - The Basics of 1.7.x Mod Creation. Although this tutorial has been short, I hope that it indicates a return to the Forums and will keep my progress with these tutorials going. We have set up the skeleton of our 1.7.x mod in this tutorial and, in the next one, we will take a look at setting up custom items and blocks with the new 1.7.x code.

    If you have liked the way I have delivered this tutorial (providing a base code for you to look at and then explained it), please let me know below and I will continue to do so for future tutorials. It should also make it easier to understand anything that I don't fully explain or explain in a complicated way.

    If you have suggestions for tutorial content, please let me know, either in the comments below or by sending me a PM. With the new forum setup, I will be notified either way.

    I hope you have enjoyed this tutorial and I am glad to be back to the forums.

    I'll see you in the next one.

    ~MrrGingerNinja

    View the previous tutorial (Tutorial #2 - Exporting our Mod)
    View the next tutorial (Tutorial #3b - An Empty Mod File (and Hard-Coding mcmod.info))
    Posted in: Mapping and Modding Tutorials
  • 18

    posted a message on [1.7.x] Modding with Forge #2 - Exporting our Mod
    [1.7.x] Modding with Forge #2 - Exporting our Mod

    Hello and welcome back to Modding with Forge! In the last tutorial, we looked at setting up our workspace in a user-friendly manner, even if it required a little bit of work on our part. In this tutorial, we are going to take a look at how to get our code out of Eclipse when we want to release our mod.

    Obviously, we do not have any code yet, but I thought I would get this tutorial done nice and early so if people don't need to use some of the later tutorials, at least they know how to do this very important step!

    So, as I said in the last tutorial, Minecraft Forge now uses Gradle for its installation and exportation of code. This means that we need to do a little bit of work so that our code will be exported from Eclipse when we want it to be.

    In the last tutorial, I told you that you needed to download Gradle, but we didn't use it. That is because we are going to use it in this tutorial. I hope you kept the .zip file kept somewhere nice and safe. Of course, we need to export the .zip file and that's it. Well, sort of. If you needed to install the JDK last tutorial, I took you through the steps of adding the JDK bin folder to the system's 'Environment Variables'. Well, guess what? We have to do this again for Gradle!

    So, right-click on 'This PC' (if using Windows 8.1, otherwise it is 'My Computer') and select 'Properties'. On the left-hand side of the screen, select the link that says 'Advanced system settings'. In the new window that opens, select 'Environment Variables...'. To get this far, you will have had to create a variable called 'Path' (or 'PATH'). Navigate to this in the list and select 'Edit...'. At the very end of the 'Variable value' field, without putting any spaces, put a semi-colon (';') and then type the directory of the 'bin' folder inside of the 'Gradle' folder you just extracted. I placed mine in my 'Program Files' so, like with the Java setup, my path will be 'C:\Program Files\Gradle\bin'.

    To check this has installed properly, like with the JDK last episode, open up the Command Prompt (on Windows) and type 'gradle'. It should print out a few things and not return with an error. If it doesn't return with an error, great; gradle has been succesfully installed! If you do get an error, go back and check the 'Path' variable that you added.

    Now that Gradle is succesfully installed, we can write the code that is going to export our mod for us. Head to the 'Minecraft' folder that we set up in Tutorial #1. There will be a folder called 'Forge' and a folder called 'Tutorials' here. Go into the 'Tutorials' folder. Again, in the last tutorial, we created a project called 'Tutorial' inside of Eclipse. This folder is now visible in the 'Tutorials' folder and we want to go into it. Here, we want to create a new file called 'build.gradle'. To do this, right-click, select 'New' and then press 'Text Document'. Call the document 'build'. Now, open it with Notepad and head to the 'File' tab. Select 'Save As...' and save the file as 'build.gradle'. Be sure to change the 'Save as type' field from 'Text Documents (*.txt)' to 'All Files'. You can now delete the 'build.txt' file.

    Inside of this 'build.gradle' file is where we are going to write the code that will export our mod for us. To do this, I would recommend copying the following code and changing the things I highlight:
     buildscript {
    repositories
    {
    mavenCentral()
    maven {
    name = "forge"
    url = "http://files.minecraftforge.net/maven"
    }
    maven {
    name = "sonatype"
    url = "https://oss.sonatype.org/content/repositories/snapshots/"
    }
    }
    dependencies
    {
    classpath "net.minecraftforge.gradle:ForgeGradle:1.1-SNAPSHOT"
    }
    }
    
    apply plugin: "forge"
    
    sourceSets
    {
    main
    {
    java { srcDirs = ["$projectDir/java"] }
    resources { srcDirs = ["$projectDir/resources"] }
    }
    }
    
    archivesBaseName = "Modding with Forge"
    version = "in_development"
    minecraft.version = "1.7.2-10.12.0.1030"

    There is not actually a huge amount you need to change here. In the first tutorial, I create a source folder called 'java' and a source folder called 'resources'. If you did not call them this, you need to change the line of code that says:
     java { srcDirs = ["$projectDir/java"] }
    to
     java { srcDirs = ["$projectDir/"] }

    Similarly, you will need to change the line that says:
     resources { srcDirs = ["$projectDir/resources"] }
    to
     resources { srcDirs = ["$projectDir/"] }

    EDIT: For Forge 1.7.10 development, you need to change the line:
     classpath "net.minecraftforge.gradle:ForgeGradle:1.1-SNAPSHOT"
    to:
     classpath "net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT"

    The important lines that you definitely need to change, however, are the lines starting 'archivesBaseName', 'version' and 'minecraft.version':
    The 'archivesBaseName' is the name of your mod; I am going to have this as 'Modding with Forge', since that is going to be my mod's name.
    The 'version' is, obviously, the version of your mod. You will need to change this each time you export your mod or the generated .jar file will be named incorrectly.
    The 'minecraft.version' is the version of Minecraft you are using, followed by a hyphen ('-') and then the version of Forge. Be sure to update this if you change Forge build numbers!

    Once you have changed everything to your liking, close the 'build.gradle' file and open Command Prompt. Navigate to the current folder (either by shift-right clicking and selecting 'Open command window here' or using 'cd' to change the directory). Once in the folder, simply type 'gradle build' to recompile and reobfuscate your mod.

    Once Gradle has finished, it will print a line saying 'BUILD SUCCESSFUL'. Your code has been successfully compiled into a .jar file, ready for global use! To access your .jar file, head into the 'build' folder that was created inside the 'Tutorial' folder. Inside here, head to 'libs'. Inside of the 'libs' folder, you will find a .jar file that, in my case, is called 'Modding with Forge-in_development'.

    Your mod has been exported and can now be used (as long as it has content!) by any user you wish to give it to.

    End of Tutorial

    This is the end of Modding with Forge #2 - Exporting our Mod. In this tutorial, we took a look at how to recompile and reobfuscate our code using Gradle, to allow us to export it from Eclipse when we feel we are ready to release a beta version of our mod. Our mod is currently empty, but we will be adding content to it very soon!

    I hope you have enjoyed this tutorial and, as ever, I'll see you in the next one!

    ~MrrGingerNinja

    Click here to see my Minecraft Forums profile
    Click here to navigate to 'Modding with Forge #1 - JDK, Eclipse, Forge and Gradle'
    Click here to navigate to 'Modding with Forge #3 - The Basics of 1.7.x Mod Creation'
    Posted in: Mapping and Modding Tutorials
  • 27

    posted a message on [1.7.x] Modding with Forge #1 - JDK, Eclipse, Forge and Gradle
    [1.7.x] Modding with Forge #1 - JDK, Eclipse, Forge and Gradle

    Hello and welcome back to another MrrGingerNinja tutorial! It's been a while since I've posted any actual content on the Forums here, but that is because I spent quite a lot of my free-time learning the differences between Minecraft Forge 1.6.4 and 1.7.x. I even (you may have already heard) recorded a few videos on it, but YouTube broke those videos during upload (it uploaded the sound but no video) so I am changing them to written tutorials and I will be continuing the series as this.

    So, the first thing you are going to want to know about Minecraft Forge 1.7.x is that it is very different to past versions of Minecraft Forge. There are a few reasons for this. The first is that the actual code that runs Minecraft had a complete overhaul. When LexManos released the first 'official' version of Minecraft Forge 1.7.2, he stated that after previous Minecraft updates, Forge could match approximately 90% of the source code, so some change was needed but not a huge amount. After the Minecraft 1.6.4 to 1.7.2 update, Forge could match only 40% of the code. So, this explains the long wait for Minecraft Forge 1.7.2, as well as the reason behind a lot of the code changing. Secondly, Forge itself changed since it now uses Gradle as it's installation software. The main reason for this is because it helps keep the Minecraft source code and our code seperate, making it easier for us to post onto GitHub and distribute our code, without the worry of accidentally releasing the Minecraft source code illegally. Due to Forge's migration to Gradle for installation, recompiling is now a little bit trickier also, but I will walk you through that in the next tutorial, just so we know what we're doing.

    So, as I just said, a lot has changed in both the Vanilla Minecraft code and in Forge's setup. So, without further ado, here is a step-by-step guide that will walk you through setting up your new Eclipse workspace in the most efficient way possible.

    The very first thing that we're going to want to do is download three files; Eclipse (http://eclipse.org/downloads), Minecraft Forge src (http://files.minecraftforge.net) and Gradle (http://www.gradle.org). I would recmomend getting the Eclipse Standard (v4.3.1 at time of this posting) and the latest version of Forge (10.13.1.1217 at time of this updating). Whilst these files are downloading, you are going to want to create a folder somewhere that will contain all of your source code. I'm just going to call mine 'Tutorials' and the path to this folder is 'C:\Users\MrrGingerNinja\Desktop\Minecraft\Tutorials'.

    EDIT: For anyone who didn't realize, it is here that I create both the "Minecraft" folder on my Desktop and then, inside that folder, create the "Tutorials" folder. Just for clarification ;)

    You're also going to want to check that you have Java installed. To do this, open up your command line editor (Command Prompt on a Windows) and type 'javac'. If you get an error, you will need to download and setup Java by following the guide in the spoiler below. Otherwise, you can skip to the next bit.

    The reason you get an error when trying to run the 'javac' command is because you either don't have Java installed or have not applied it to your Environment Variables. If you're not sure if you have installed Java, go to 'C:\Program Files\' and look for a folder calld Java. If it is there, check that there is another folder inside of that, called something along the lines of 'jdk#.#.#_##' (in my case, this is 'jdk1.7.0_51'. Head inside of this folder, open the 'bin' folder and check that there is a .jar file called 'javaw'. If this file exists, you can skip over the following spoiler and simply setup the Environment Variables. If either the file or folder does not exist, you have either not installed Java before or not installed it correctly, so read the spoiler below on how to do this.

    You are going to need to head to the Java website (http://www.oracle.co...oads/index.html). There will be a button around the middle of your page, slightly offset to the left that says 'Java'. Underneath, it should say 'Java Platform (JDK) #u##' (at the time of this post, the #u## was equal to '7u51' but this may change). Click on the 'Download' button and you'll be redirected to a new page. Before scrolling down the page, be sure to check the 'Accept License Agreement' radio button (only if you agree with the license!) in the section with the header 'Java SE Development Kit #u##'. Make sure that you are in this section and not any of the others, since we want the Development Kit and nothing else. Now, select the Operating System you're on (in my case, Windows x64) and click on the download link (just a heads up for Windows 32-bit users, you will need to download the Windows x86 file). The appropriate file will then download.

    Once downloaded, run the file and follow the steps on correctly installing Java. Okay, you have now successfully installed Java!

    Okay, so we're now at the stage where Java is installed. But, if Java is installed, why did the 'javac' command not work? Well, we need to add an Environment Variable to our system that tells it where it can find information relating to the 'javac' (and other Java) command(s). To do this (bare in mind that I am using Windows 8.1 for these tutorials so the Windows layout may seem a little different to Windows 7 and earlier useers), you will need to open the File Navigator and right-click on 'This PC'. For Windows 7 and earlier, you will just need to right-click 'My Computer'. Then, select 'Properties'. A new window will open up with information relating to your computer. On the left-hand side of this window, there will be a link that says 'Advanced system settings'. You need to select this and provide appropriate Administrator details if you're not already on an Admin account. Yet another window will pop up and, at the bottom of this window, there will be a button that says 'Environment Variables...'. Click on this button and another window will open. Under the header 'System variables', scroll through the list until you find 'Path' (it may be shown as 'PATH'). If the variable alreedy exists, select it and click 'Edit...'. If it does not exist, simply select 'New...'. If you chose 'New', name the variable 'PATH'. If you chose 'Edit', this will already be done for you. In the 'Variable value' field, we are going to need to add a directory path, so that our system knows where to look when we run the 'javac' command. If this field is blank, you can type directly into it. If the field already exists and the 'Variable value' field contains information already, scroll to the end of this information. At the end, without adding a space, put a semi-colon (';'). Now, you can type directly into the box (again, without spaces) the location of the 'bin' folder inside of your Java folder. So, in my case, I would type 'C:\Program Files\Java\jdk1.7.0_51\bin'.

    Now, if I open Windows Command Prompt and type 'javac' and press Enter, I am no longer greeted by an error, but by a list of possible usages of the 'javac' command. Great, so the Java Development Kit (JDK) is successfully installed! Time to set up Forge!

    Once Eclipse has downloaded, extract the .zip file to a suitable location and you're done with this for now. Eclipse is an application that does not require any installation, so we will just come back to it in a little while. We're now going to need to head into the 'Minecraft' folder we created on our Desktop. The 'Tutorials' folder we created will already be here, but we don't want to do anything with that quite yet. Inside of the 'Minecraft' folder, we are going to extract the recently downloaded Minecraft Forge folder here. Once extracted, rename the folder from 'forge-1.7.#-10.##.#.####-src' to something simpler, like 'Forge'. Once you have done that, head into the newly-renamed folder. Now, we are actually going to need to use our command line editor again here. To do this, you can either shift and right-click in the folder, which will give you the option to 'Open command window here' or you can open Command Prompt and navigate to the folder (to do this, type 'cd C:\Users\MrrGingerNinja\Desktop\Minecraft\Forge'). Next, we need to run the 'gradlew' file that is inside of this folder. To do this, we need to provide a few conditions. The first we are going to provide is 'setupDecompWorkspace'. This will setup a decompiled workspace for Minecraft Forge, which will, obviously, decompile the Minecraft and Minecraft Forge source code for us. We are then going to tell the program to refresh Forge's dependencies; this is because, occasionally, not all of the required libraries are download during this process and we run into problems later on. Please note that this can still happen even with the '--refresh-dependencies' condition. We are also going to type the condition 'eclipse' since we are using Eclipse as our Integrated Development Environment (or IDE). This is just the software that we use to write code. Alternatively, if you have and prefer using IntelliJ IDEA, type 'idea' here, instead of 'eclipse'. So, the command line that I am running looks like the following:
     C:\Users\MrrGingerNinja\Documents\Minecraft\Forge>gradlew setupDecompWorkspace --refresh-dependencies eclipse

    EDIT: If this, for some reason, does not work, I recommend running each parameter separately:
     xxxx > gradlew setupDecompWorkspace
    xxxx > gradlew --refresh-dependencies
    xxxx > gradlew eclipse

    Once you press enter, Gradle will begin to setup your decompiled workspace, as well as creating the workspace for your designated IDE. This will take a varying amount of time depending on your system, but the installation process takes me about 15 minutes, so read on once it has finished. You will know it has finished because there will be a message that says 'BUILD SUCCESSFUL'.

    Once finished, you can close the Command Prompt because we are now finished with it. Time to head on over to that Eclipse application we extracted a while ago! Double-click on the 'eclipse' application to run it. A window will pop up asking for you to select a workspace. We want to set our workspace to the 'Tutorials' folder we created at the very beginning of this tutorial (so, type 'C:\Users\MrrGingerNinja\Desktop\Minecraft\Tutorials').

    Once Eclipse has opened up, you will be met with a 'Welcome' tab since our workspace is currently empty. You can either press the cross next to 'Welcome' or press the arrow on the top right that says 'Workbench'. Now that we have reached our workbench, you will see that we have no code as of yet. What we need to do is import the Forge project we created a step back. To do this, go to 'File' and the top left and select 'Import...'. Expand the 'General' folder at the top of the new window and select 'Existing Projects into Workspace'. Because of the way we set Forge up in the last step, an Eclipse workspace has already been set up by Forge, so we're just importing it here. Click 'Next'. In the 'Select root directory' field, we need to browse to the 'Forge' folder that we set our workspace up in ('C:\Users\MrrGingerNinja\Desktop\Minecraft\Forge'). Once you have selected this, a list of available projects will appear in the 'Projects' box below (there should only be 1!). Make sure that you tick the box next to this project if it is unselected and, without altering anything else, press Finish.

    Okay, so we now have Vanilla Minecraft (with Forge installed) in our workspace! Great! Now, you may recieve an error on the Forge folder. The error will most likely read 'Project 'Forge' is missing required library: 'C:\Users\MrrGingerNinja\Desktop\Minecraft\Forge\unresolved dependency - forgeBin 1.7.2-10.12.0.####'. I'm not sure what the cause for this is, but according to posts that I uncovered through the Forums and through personal testing, the best method to fix this issue is to go into the 'Forge' folder and rerun the command we typed earlier starting 'gradlew'. Be sure to include the '--refresh-dependencies' condition and this should fix your problems! Sorry if this happens to you, I don't know what the reason for it is!

    If we now open the Forge project, you'll see that there are two source folders: 'src/main/java' and 'src/main/resources'. If you open the 'src/main/java' folder, you will see an already existing package called 'com.example.examplemod'. Select this package and delete it, since we are going to be writing our own code. Similarly, inside the 'src/main/resources' folder, there is a file called 'mcmod.info'. Delete this file too.

    Now that the Forge file is empty and contains purely Vanilla code (with the Minecraft Forge code placed in it, too), we need to setup our 'Run Configurations' so that Minecraft will launch! Just so you are aware, those of you who wish to know how to access the Minecraft source code, expand the 'Forge' project and then expand the 'Reference Libraries' tab. In here, most likely at the top of the list, should be a file called 'forgeSrc-1.7.2-10.12.0.####.jar'. Expand this file and you will be able to browse all of the source code and assets that Minecraft and Minecraft Forge has to offer! Since the files are inside a .jar file, they are .class files, meaning you can look at them but cannot edit them!

    Okay, back to setting up the 'Run Configurations'. In the toolbar at the top of Eclipse, go to the 'Run' tab and then select 'Run Configurations...'. In the left-hand side of the new window, double-click on 'Java Application' to create a new Run Configuration. Name it something like 'Run Client' (you cannot call it 'Client' because Forge already has a Run Configuration with this name). Choose the 'Forge' project as the Project and either type or find 'net.minecraft.launchwrapper.Launch' as the 'Main class'.

    Next, go the 'Arguments' tab and, in the 'Program arguments' field, add the following text:
     --version 1.7 --tweakClass cpw.mods.fml.common.launcher.FMLTweaker --accessToken modstest

    EDIT: If using Forge 1.7.10 (I'm using version 1.7.10-10.13.1.1217), you will also need to add the following text to the 'Program arguments' field:
     --userProperties {}

    You can also apply a username here, by typing '--username ' (e.g '--username MrrGingerNinja').

    In the 'VM arguments' field, add the following text:
     -Dfml.ignoreInvalidMinecraftCertificates=true

    Once you have added all of this, press 'Apply' and then 'Run'. Minecraft should now successfully launch!

    As a quick note, Minecraft may not play noise when you launch it. If this is the case, close it and head to the 'Forge' folder outside of the workspace. Aeronica provided me with a guide to fix this issue; in the 'Program Arguments' of the 'Run Configurations', add the following line:
     --assetsDir=eclipse/assets
    Now go into the 'eclipse' folder ('C:\Users\MrrGingerNinja\Desktop\Minecraft\Forge\eclipse') and check that there is an 'assets' folder. As long as there is, refresh the Eclipse workspace and rerun Minecraft. You should now have sounds!

    EDIT: With 1.7.10, this has to be set up in a slightly different way. Instead of typing:
     --assetsDir=eclipse/assets
    you need to type:
     --assetIndex 1.7.10 --assetsDir C:\Users\MrrGingerNinja\.gradle\caches\minecraft\assets

    So, the final thing to cover in this tutorial is how to actually create a mod that Forge will run. Well, as I said previously, Minecraft Forge now recompiles code a little bit different, so we've set up our workspace accordingly. The way that we have set our workspace up allows us to have as many mods as we want with no conflicts. It is very simple to create a new mod for Forge with the workspace in its current state. Simply go to the 'File' tab, select 'New' and click 'New Java Project'. Name the project whatever you want (I'm going to call mine 'Tutorial'). Click 'Next' at the bottom of the window. On the next page, we will see that Eclipse automatically creates a 'src' folder for us inside of our project. We are going to right-click this 'src' folder and select 'Remove from Build Path'. Next, we're going to right-click on the 'Tutorial' project and select 'New Source Folder...'. We are going to create two source folders; one called 'java' and one called 'resources'. Once you have created these two source folders, select the 'Projects' tab at the top of the window. In here, select 'Add...' on the right-hand side and then choose 'Forge'. Now press 'Finish'. Eclipse will now create our project for us. The first thing we want to do is delete the 'src' folder that is left inside of our project; simply right-click and select 'Delete'.

    One final thing to do before I wrap up this tutorial. We need to go to the 'Run' tab again and alter our 'Run Configurations'. Currently, our 'Run Client' configuration is set up to run just the Forge project. To fix this, go to the 'Classpath' tab. In the window, select 'User Entries' (it will have 'Forge' beneath it as the 'default classpath') and then select 'Add Projects...' on the right-hand side. Select the tick box next to 'Tutorial' and, before pressing 'OK', be sure to untick the two boxes at the bottom of the window that say 'Add exported entries of selected projects.' and 'Add required projects of selected projects.'. Once they are unticked, press 'OK', then 'Apply' and then 'Run'.

    Obviously, it will appear as if nothing has happened and that is because we have not written any code yet. We will be doing that in Episode #3 of this series.

    End of Tutorial

    This is the end of Modding with Forge #1 - JDK, Eclipse, Forge and Gradle. In this tutorial, we took a look at how to correctly install the Java Development Kit, as well as set up our Integrated Development Environment (IDE, 'Eclipse') to contain and run Minecraft 1.7.x with Forge. We also took a look at how to install Minecraft Forge 1.7.x using the new Gradle installation system.

    In the next tutorial, we will be taking a look at how to recompile and reobfuscate our code, to allow us to export it from Eclipse when we feel we are ready to release a beta version of our mod.

    I hope you have enjoyed this tutorial (it's been a long time coming!) and I'll see you in the next one!

    ~MrrGingerNinja

    Click here to see my Minecraft Forums profile
    Click here to navigate to 'Modding with Forge #2 - Exporting our Mod'
    Posted in: Mapping and Modding Tutorials
  • 1

    posted a message on [1.6.4] NuclearPower pre-0.2-2Apr (DELAY)
    NuclearPower pre0.2-2Apr

    Basic Description

    NuclearPower (formerly NuclearCraft) is an IC2 addon that allows for the construction of several reactors that produce varying amounts of EU.

    CURRENT DOWNLOAD (pre0.2-2Apr)

    Direct Download
    AdFly Download (Temporarily unavailable)

    DEPENDENCIES

    - Minecraft Forge 9.11.1.965 (http://files.minecraftforge.net)
    - IndustrialCraft 2 (ver. 2.0.397) (http://ic2api.player...xperimental/397)

    SCREENSHOTS


    pre-0.2-2Apr

    Coming soon!

    pre-0.2-26Mar



    WAILA (What Am I Looking At?) support

    Buildcraft/Thermal Expansion support

    GUI updates dependent on surroundings

    Fusion Reactor Coils correctly placed

    The finished (for now) product

    Cables can connect to the top and bottom of the Reactor Controller

    The impact of a Coil reaching maximum temperature

    UPDATES

    pre-0.2-2Apr

    The second update video is available on YouTube here (not yet available)
    It shows the new features added to the Fusion Reactor, but, be aware, the steam production has been temporarily removed due to a fluid rendering problem that only occurs outside of the Eclipse workspace.

    pre-v0.2-26Mar

    The "First Look" video is available on YouTube here
    It shows you the basic setup and runs through the safety features of the Fusion Reactor released in this version.

    CHANGELOG

    pre-0.2-2Apr

    - Added NuclearPower creative tab
    - Added use for Pressure Regulator (temporarily disabled)
    - Added use for Plating
    - Added Coil corrosion (say what?! ;) )

    pre-v0.2-26Mar

    The first public release of the mod is available!
    The Fusion Reactor is relatively stable to use, although watch out when it reaches about 50,000 degrees ;)

    BUGS/CAVEATS

    pre-0.2-2Apr

    [FIX] The Reactor Controller now updates whenever a block is broken and/or replaced
    [BUG] The Reactor does not produce steam due to a fluid rendering issue that only occurs when the mod is exported to a normal, non-workspace client v_v

    pre-v0.2-26Mar

    As of this release, there are 3 clear bugs that I am aware of from my own testing:

    [BUG] When the world is closed and reloaded, the tanks lose their stored liquid.
    [BUG] When the world is closed and reloaded, the coils lose their stored temperature (fix this by opening the Reactor Controller GUI)
    [BUG] When a coil is broken, the Reactor Controller GUI stops updating information about that block

    Posting bugs

    If you find a bug or encounter a crash other than those listed (and not fixed) above, please leave a comment below with the following format:
    - What you were doing when the crash occurred
    - If the crash occurred more than once or if it was a one of thing
    - A spoilered crash-log (comments with unspoilered logs will be removed due to their length)

    ~ MrrGingerNinja

    COPYRIGHT

    This mod (plugin, patch to Minecraft source, henceforth "Mod" or "The Mod"), by the terms of http://minecraft.net/terms are sole property of the Mod author (MrrGingerNinja, henceforth "Owner" or "The Owner"). By default it may only be distributed on minecraftforums.net and minecraft.curseforge.com by the Owner. They may only be mirrored or reposted with advance written permission of the Owner. URL shorteners or other attempts to make money off The Owner's Mods are strictly forbidden without advance written permission. This mod is closed open source.
    Posted in: WIP Mods
  • 2

    posted a message on [1.7.2] NEI in Eclipse
    NOTE: THIS ONLY WORKS IN FORGE VERSIONS BEFORE Forge10.12.0.1047

    [1.7.2] Setting Up Not Enough Items in Eclipse

    Hey, guys,
    This is a brief tutorial today but one that, I hope, will help a great number of people regarding CodeChickenCore and NEI for Minecraft 1.7.2, which were recently released.

    As normal, download CCC and NEI and drop them into your mods folder (if you followed my tutorial for setting up Forge for 1.7.2, go to 'Forge' and then 'mods'.

    Now, when you launch the Client, a box will pop up asking you to select an 'mcp conf dir'. After a bit of playing, I found out how to set this up.When this box pops up, it should already be inside your Forge folder. Go into 'build' and then 'unpacked'. Then, simply select the 'conf' folder and you're all set to go.

    UPDATE (30th June 2014)
    According to the replies below, the new location for this is:
    %USER_HOME%/.gradle/caches/minecraft/net/minecraftforge/forge/FORGE_VERSION/unpacked/conf

    The box will not pop up once you have done this and, there you go, NEI now works for Minecraft 1.7.2!

    Great job, ChickenBones!

    ~MrrGingerNinja
    Posted in: Mapping and Modding Tutorials
  • 1

    posted a message on [1.7.x] Modding with Forge #2 - Exporting our Mod
    Quote from burnner_

    This new Forge with gradle, etc. is ­the biggest shi*t in Minecraft since 2011..


    Gradle is a very large shift in how Forge functions but, at the end of the day, it makes modding a lot tidier, it is so much simpler to post code online (because there is no having to use .gitingore files to remove all of the Minecraft and Minecraft Forge src code) and it automatically creates our mod for us when we run one command.

    Overall, yes, it does take a little bit of getting used to, but only when setting up and exporting our mod... Otherwise, the coding experience is the same as ever, just a little bit tidier :)

    Quote from VeliceVenom

    Looking forward to #3!


    Thanks Venom :) had a lot of stuff going on IRL lately so wasn't able to get a tutorial up on Monday as I said I would... But I might be able to put one out a little while later...

    I really do appreciate everyone's continued support despite my inability to be active on these forums every day... Hopefully normal service will be resumed within the next couple of weeks.

    :Diamond: :Diamond: :Diamond: :Diamond: :Diamond: :Diamond: :Diamond: :Diamond: <-- Here are some diamonds for your amazing support!

    You guys are the best!

    ~Ginger
    Posted in: Mapping and Modding Tutorials
  • 1

    posted a message on [1.6.2] Minecraft Forge Modding #5b - Functionality for our Custom Item
    Quote from Snipehawk


    So what method would I use to check blocks of air beneath the player?
    if(player.....?
    and another quick question..is it possible to spawn animals with onItemRightClick and how would I go about doing that?
    thanks! :)


    if(world.getBlockId((int) player.posX, (int) player.posY - 1, (int) player.posZ) == 0) {
      // Run code here
    }


    Also, you can easily spawn an animal:
    world.spawnEntityInWorld(new EntityPig(world));


    The above method may be called 'spawnEntity' and not 'spawnEntityInWorld' (replying from my phone!)
    Posted in: Mapping and Modding Tutorials
  • 1

    posted a message on [1.6.2] Minecraft Forge Modding #5b - Functionality for our Custom Item
    Quote from GamerInspired



    Do you know if there's a or function e.g and = &&. Because I still want it to work on mobs as well.


    Indeed there is :-) as you said,
    and is '==',
    or is '||' :-)
    Posted in: Mapping and Modding Tutorials
  • 1

    posted a message on [1.6.2] Minecraft Forge Modding #5b - Functionality for our Custom Item
    Quote from GamerInspired



    Would it be; if target == EntityPlayer

    Sorry quite new to this.


    No worries :-) you can't check directly if it equals EntityPlayer in this way... You would have to create the EntityPlayer object first:
    if(target instanceof EntityPlayer) {
      EntityPlayer player = (EntityPlayer) target;
    
      if(target == player) {
        // run code here
      }
    }


    However, this is really not necessary. As with the zombie and creeper, we just need to check that the target (I.e. The EntityLivingBase that we clicked on) is an instance of EntityPlayer and, if so, run the appropriate code :-) otherwise, we're wasting space writing a bunch of basically pointless code :-) hope I helped cleared some things up here :-)
    Posted in: Mapping and Modding Tutorials
  • 1

    posted a message on [1.6.4] Minecraft Modding Tutorial #11b - Handling our Custom Fluid
    [1.6.4] Minecraft Modding Tutorial #11b - Handling our Custom Fluid

    Hey, guys, and welcome to Tutorial #11b of my Forge modding series. In this tutorial, we are going to continue on with our work from the last part of Tutorial #11 and we're going to create a bucket that can pick up and place our custom liquid. As an advance warning, you may want to take a little bit of time looking at Events before continuing on with this tutorial, because it does require a little bit of Event knowledge.

    In the last tutorial, we created our custom liquid. At the moment, however, the liquid is in the Creative menu, out of a bucket and looking a little bit weird. To fix this, we're going to add a bucket that holds our liquid instead. The first thing that we are going to want to do is go into our TutFluidBlock class and remove the setCreativeTab() method from our constructor. Now that we've done this, we can close the class and go to our Items class.

    In here, we are going to create a new object, called 'bucket':
    public static Item bucket;


    Next, we're going to go to our Names class and create a name variable, as well as heading to our Ids and creating the IDs (don't forget to add them to the ConfigHandler!):
    // Inside 'Names.java'
    public static final String tutFluidBucket_unlocalizedName = "tutBucket";
    public static final String tutFluidBucket_name = "Tutorial Bucket";
    
    // Inside 'Ids.java'
    public static int tutFluidBucketActual;
    public static final int tutFluidBucketDefault = 16003;
    
    // Inside 'ConfigHandler.java'
    Ids.tutFluidBucketActual = config.getItem(config.CATEGORY_ITEM, Names.tutFluidBucket_name, Ids.tutFluidBucketDefault).getInt() - 256;


    Once you have set up all the above, we can head back to our Items class. We're going to add the item name, first, inside the addNames() method:
    LanguageRegistry.addName(bucket, Names.tutFluidBucket_name);


    Next, we're going to initialize our bucket. To do this, we're going to initialize our item the same as before, but we're going to have two parameters instead of one:
    bucket = new ItemTutBucket(Ids.tutFluidBucketActual, Blocks.fluid.blockID);


    As you can see, the first parameter we provide is the ID of the bucket itself. The second parameter is the ID of the source block that needs to be clicked on to acquire this item. In this case, that is the Blocks.fluid block, since this is the source block of our fluid.

    Of course, we're going to get an error beneath ItemTutBucket, so go ahead and create this class. We want our ItemTutBucket to extend ItemBucket, rather than the typical Item. Of course, our constructor must take two parameters and have a super call:
    public class ItemTutBucket extends ItemBucket {
    public ItemTutBucket(int id, int blockID) {
    super(id, blockID);
    setUnlocalizedName(Names.tutFluidBucket_unlocalizedName);
    setCreativeTab(Tutorial.tutorial);
    }
    }


    As per usual, we need to register the icon for our item:
    @SideOnly(Side.CLIENT)
    @Override
    public void registerIcons(IconRegister icon) {
    itemIcon = icon.registerIcon(ModInfo.ID.toLowerCase() + ":" + Names.tutFluidBlock_unlocalizedName);
    }


    This is all we have to do in our ItemTutBucket class. Simple, right? But now you're asking "But how do I use my bucket on my fluid?". Well, I'm afraid this is the part of the tutorial that requires a little bit of Event knowledge.

    We need to head back to our Tutorial class file at this point. We need to go inside of our init() method and, before our LanguageRegistry call (to correct our Creative Tab's name), we want to create a new event. To do this, we need to register a new event with the Event Bus in Minecraft Forge:
    public static void init(FMLInitializationEvent event) {
    // All other initialization stuff above...
    
    MinecraftForge.EVENT_BUS.register(new CustomBucketEvent());
    
    LanguageRegistry.instance().addStringLocalization("itemGroup." + ModInfo.NAME, "en_US", ModInfo.NAME);
    }


    Of course, we need to create the CustomBucketEvent, which I am going to place inside a new package called 'event'.

    The first thing we are going to want to do here is to use a new annotation:
    @ForgeSubscribe


    Next, we need to create a method that, like with our @EventHandler annotation, takes a parameter that will be listened for:
    @ForgeSubscribe
    public void onBucketFill(FillBucketEvent event) {
    
    }


    What we are doing above, and by registering this class with Minecraft Forge's Event Bus, is creating an 'action listener'. Is this case, our event is 'listening' for a FillBucketEvent (i.e. when a fluid source block is clicked on with an empty bucket).

    The first thing we need to do inside this method is check if the bucket can pick the fluid up. We're going to do this using a method that we will create in a minute:
    ItemStack result = fillBucket(event.world, event.target);


    The above code calls the fillBucket method and provides two parameters; a World parameter and a MovingObjectPosition parameter.

    If the fillBucket() returns null, then the fluid that has been clicked on cannot be picked up. This means that we should just exit out of our listener:
    if(result == null) return;


    However, if we do return something, then we should allow the event to carry out its action, as well as telling the event what item was returned:
    event.result = result;
    event.setResult(Result.ALLOW);


    Now we can create our fillBucket method:
    public ItemStack fillBucket(World world, MovingObjectPosition position) {
    
    }


    This method is going to be used to determine if the fluid we are clicking on is:
    a) a source block;
    B) a fluid we can pick up
    so, of course, we need to find out what the block is:
    int blockID = world.getBlockId(position.blockX, position.blockY, position.blockZ);


    Next up, we need to check that the ID of the block is the same as our fluid and that the block we clicked on is, indeed, a source block:
    if(blockID == Blocks.fluid.blockID && world.getBlockMetadata(position.blockX, position.blockY, position.blockZ) == 0) {
    
    }


    We need to make sure to remove the source block (set it to air) and return the newly filled bucket:
    if(blockID == Blocks.fluid.blockID && world.getBlockMetadata(position.blockX, position.blockY, position.blockZ) == 0) {
    world.setBlock(position.blockX, position.blockY, position.blockZ, 0);
    return new ItemStack(Items.bucket, 1);
    }


    The final thing we need to do is return null if the blockID does not equal our fluid (obviously, we can have mulitple fluids using this one event by adding an else if statement). Our finalised event code should look like the following:
    package tutorial.event;
    
    import tutorial.blocks.Blocks;
    import tutorial.items.Items;
    import net.minecraft.item.ItemStack;
    import net.minecraft.util.MovingObjectPosition;
    import net.minecraft.world.World;
    import net.minecraftforge.event.Event.Result;
    import net.minecraftforge.event.ForgeSubscribe;
    import net.minecraftforge.event.entity.player.FillBucketEvent;
    
    public class CustomBucketEvent {
    @ForgeSubscribe
    public void onBucketFill(FillBucketEvent event) {
    ItemStack result = fillBucket(event.world, event.target);
    if(result == null) return;
    event.result = result;
    event.setResult(Result.ALLOW);
    }
    
    public ItemStack fillBucket(World world, MovingObjectPosition position) {
    int blockID = world.getBlockId(position.blockX, position.blockY, position.blockZ);
    
    if(blockID == Blocks.fluid.blockID && world.getBlockMetadata(position.blockX, position.blockY, position.blockZ) == 0) {
    world.setBlock(position.blockX, position.blockY, position.blockZ, 0);
    return new ItemStack(Items.bucket, 1);
    } else return null;
    }
    }


    If you now go ahead and run your client, you will see your item in the game. If you encounter an error, go to your Tutorial class file and, inside the init() method, move the Items related code beneath the Blocks, so the order is Fluids, followed by Blocks, followed by Items.

    Once the client loads, open a world and, if you are in survival mode (make sure you are to test this!), you can place the fluid and your filled bucket becomes an empty bucket. Clicking on the source of the fluid with the empty bucket will return the filled one to you.

    End of Tutorial

    This is the end of Tutorial #11b - Handling our Custom Fluid. In this tutorial, we have added a custom bucket for our liquid, which can be used to place our fluid, and allowed for it to be picked up in an empty bucket.

    In the next tutorial, we're going to move on from fluids to something that I have been getting a lot of requests for... Mobs! That's right, in the next tutorial, we are going to create our very own passive mob that wanders around the world.

    I hope you are looking forward to the next tutorial and that this one has been useful. Until then, keep modding.

    ~MrrGingerNinja

    View the previous tutorial (Tutorial #11a - Creating a Custom Fluid) here
    View the next tutorial (Tutorial #12a - A Passive Mob) here
    Posted in: Mapping and Modding Tutorials
  • To post a comment, please or register a new account.