Jump to content

Recommended Posts

Posted (edited)

Today I'm going to start modding.
Wish me luck! :D

--Gotlyfe--

 

I will be editing this post and providing sources for the reasoning behind my actions in the spoilers.

 

Updates:

-Downloaded and installed Java version of Minecraft from https://minecraft.net/download/

-Downloaded and installed Minecraft forge(recommended version 1.12.2 - 14.23.3.2655) from https://files.minecraftforge.net/

-Ran once to test it was working properly

Spoiler

Need Minecraft and Forge installed to create and test mods.


-Removed all versions of Java from my computer
-Installed Java 8u171 from Oracle 8u171 Download

Spoiler
On 2/21/2018 at 11:30 PM, Cadiboo said:

I dont believe you need the Development kit, but I've always downloaded it just to be safe (it includes normal java in it) and its worked fine


 

How to change it:

It could be complicated, you should be able to change it with commands but that didn't work for me (MacBook Pro 2013) so I deleted java completely then installed the right java

Java 8u151:

http://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html

 

MAKE SURE you download 8u151 not 8u152 (8u151 is the second release from the to, and the 3rd item from the top)

 

Minecraftforge Forum minecraft-forge-server-wont-start-when-trying-to-add-rammac
This thread went on to discuss that you should only have the working version of java installed or you might get an error such as I did.  "Could not determine java version from '10.0.1'."

 


I was unable to get specifically 8u151 as 8u151 Release Notes states that "This JRE (version 8u151) will expire with the release of the next critical patch update scheduled for January 16, 2018."

Instead I installed the newest version of Java 8 (8u171) which, to my knowledge, should be compatible.


-Downloaded Forge source distribution(mdk) from http://files.minecraftforge.net/ (same version as installed earlier)

-Extracted zip file into empty folder
-Copied build.gradle gradlew.bat gradlew and the gradle folder to a new folder for project

Spoiler

In the Forge Documentation
http://mcforge.readthedocs.io/en/latest/gettingstarted/
Step 1-3


-Installed Eclipse from https://www.eclipse.org/downloads/

Spoiler

In the Forge Documentation
http://mcforge.readthedocs.io/en/latest/gettingstarted/
Step 5

 

Quote

Forge explicitly supports developing with Eclipse or IntelliJ environments, but any environment, from Netbeans to vi/emacs, can be made to work.

 

 

-Opened Command Prompt as administrator

-Navigated to project Folder
-ran gradlew -Dorg.gradle.jvmargs=-Xmx3000m setupDecompWorkspace eclipse to set up workspace, set up for eclipse and make sure it had enough RAM to complete
-Completed in 11 mins 23 seconds

Spoiler

In the Forge Documentation
http://mcforge.readthedocs.io/en/latest/gettingstarted/
Step 4-5

 

Then when I found myself stuck at 56% decompileMC

On 5/3/2017 at 2:52 PM, SubDivide said:

Happens a lot to me, Just use:

 



gradlew -Dorg.gradle.jvmargs=-Xmx3000m setupDecompWorkspace eclipse

 

Fixes my issue perfectly, I'm not sure if it's the right way of doing things but it certainly works for me

from the thread Minecraftforge Forum forgegradlemcdeps-stays-at-56

 

-Opened Eclipse and set workspace one level above project folder

-Added Project to package explorer by Import > General > Existing Projects into Workspace > Select Root Directory

Spoiler

 

-Altered Mod Information, changing build name, "maven coordinates", and version number under build.gradle

 

-Created new source folder for java, package inside source folder, project class inside package

-Created new source folder for resources

-Creating mcmod.info file in resources and fill with metadata about mod

Spoiler

mcmod.info example included in forge distribution mdk under src/main/resources

Spoiler


[
{
  "modid": "examplemod",
  "name": "Example Mod",
  "description": "Example placeholder mod.",
  "version": "${version}",
  "mcversion": "${mcversion}",
  "url": "",
  "updateUrl": "",
  "authorList": ["ExampleDude"],
  "credits": "The Forge and FML guys, for making this example",
  "logoFile": "",
  "screenshots": [],
  "dependencies": []
}
]

 

But explanations of mcmod.info from https://mcforge.readthedocs.io/en/latest/gettingstarted/structuring/#the-mcmodinfo-file

 

-Adding parts one by one to project class from ExampleMod.java

Spoiler

 ExampleMod.java is in the forge distribution mdk under src/main/java

Spoiler


package com.example.examplemod;

import net.minecraft.init.Blocks;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import org.apache.logging.log4j.Logger;

@Mod(modid = ExampleMod.MODID, name = ExampleMod.NAME, version = ExampleMod.VERSION)
public class ExampleMod
{
    public static final String MODID = "examplemod";
    public static final String NAME = "Example Mod";
    public static final String VERSION = "1.0";

    private static Logger logger;

    @EventHandler
    public void preInit(FMLPreInitializationEvent event)
    {
        logger = event.getModLog();
    }

    @EventHandler
    public void init(FMLInitializationEvent event)
    {
        // some example code
        logger.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
    }
}

 

 

-Adding

@Mod(modid = ClassName.MODID, name = ClassName.NAME, version = ClassName.VERSION)

 above public class ClassName which requires 


import net.minecraftforge.fml.common.Mod;
Spoiler

@Mod is described as 

Quote

This is an annotation indicating to the Forge Mod Loader that the class is a Mod entry point. It contains various metadata about the mod. It also designates the class that will receive @EventHandler events.

from https://mcforge.readthedocs.io/en/latest/gettingstarted/structuring/#what-is-mod

 

The parameters are to give the metadata that mcmod.info otherwise provided or set the useMetadata property to true to override what is written here with the information from mcmod.info.

 

-Adding public static final strings to project class definition for previously used metadata in @Mod 

Spoiler

public static final String MODID = "examplemod";
public static final String NAME = "Example Mod";
public static final String VERSION = "1.0";

MODID and NAME being the same as in mcmod.info

Version best practices explained by https://semver.org/

 

-Adding

private static Logger logger;

into class which requires

import org.apache.logging.log4j.Logger;
Spoiler

This is for any logging operations to be done.

Documentation can be found at https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Logger.html

 

It is my understanding there are numerous logging libraries to choose from.

 

The example uses 


logger = event.getModLog();

which is more easily explained through the examples at ProgramCreek FMLPreInitializationEvent.getModLog()

 

 

 

-Creating initialization event functions

@EventHandler
    public void preInit(FMLPreInitializationEvent event)
    { 
  		logger = event.getModLog();
    }

@EventHandler
    public void init(FMLInitializationEvent event)
    { }

@EventHandler
    public void postInit(FMLPostInitializationEvent event)
    { }

which requires


import net.minecraftforge.fml.common.Mod.EventHandler;

to handle events at all and

import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;

to handle these specific events.

Spoiler

The forge initialization events are all described here https://mcforge.readthedocs.io/en/latest/conventions/loadstages/

There are some specific actions which can only be done upon these events and only inside the @Mod class

 

Spoiler

 

Need to re-work these, see Comments below

-Create 3 new classes in package Common Proxy, ClientOnlyProxy and DedicatedServerProxy

Spoiler

The details of the need for the 3 proxy classes is explained well here GreyMinecraftCoder how-forge-starts-up-your-code

by @TheGreyGhost

 

Some details also described in the documentation at https://mcforge.readthedocs.io/en/latest/networking/simpleimpl/

 

-The Common Proxy being an abstract class and the Client and Server classes being extensions of it.


public abstract class CommonProxy {
}

public class DedicatedServerProxy extends CommonProxy{
}

public class ClientOnlyProxy extends CommonProxy{
}

giving each of them the functions


	public void preInit()
	  { }
	public void init()
	  { }
	public void postInit()
	  { }
	abstract public boolean isDedicatedServer();

but having the Client return false and the Server return true for the isDedicatedServer(); and removing the abstract keyword

 

 

 

 

-Created build by using the cmd in the project folder directory to run gradlew build

-Copied the output file ([archivesBaseName]-[version].jar from build/libs into .minecraft\mods

 

Success!

 

-- Will start a new thread specific to the kind of mod I am going to make it into. This seems to be a good general starting mod thread in my opinion.

Edited by Gotlyfe
  • Thanks 1
Posted

This is not by any chance a tutorial.

 

This is mostly copy-paste from the existing Forge docs intro (which is perfectly fine for people new to modding), and gave code which users can copy-paste into their files without learning anything, resulting in the same code as the example source. 

 

Also, the CommonProxy system doesn't make sense. Read Code Style, issue #1.

 

Your proxies shouldn't have code to distinguish the dedicated server from the integrated server. Almost all logic should be done on both servers, not just on one of them. That'll cause issues on the other server.

  • Sad 1

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted
51 minutes ago, larsgerrits said:

This is not by any chance a tutorial.

 

This is mostly copy-paste from the existing Forge docs intro (which is perfectly fine for people new to modding), and gave code which users can copy-paste into their files without learning anything, resulting in the same code as the example source. 

I think you really missed the point of this topic. Not trying to be a tutorial, that's why this isn't in the user-submitted-tutorials. It was a description of what I did and the places I went to, to figure out how to get the basics of a mod set up.

 

 

52 minutes ago, larsgerrits said:

Also, the CommonProxy system doesn't make sense. Read Code Style, issue #1.

 

Your proxies shouldn't have code to distinguish the dedicated server from the integrated server. Almost all logic should be done on both servers, not just on one of them. That'll cause issues on the other server.

Thanks, I'll re-work my code straight away.

  • 1 month later...

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.