Jump to content

Recommended Posts

Posted

So, long time ago I asked and was told it was not easy, that I stick to doing it manually, but I think it's time to do it, and learn how to do it. Even if it's not easy, it can't be impossible and should there be someone that can explain it on an easy way step by step.

 

The question is easy, how do I make so I can change the version of my mode in only 1 place, and it gets updated on ModInfo.java / mcmod.info and build.gradle

 

I think it's the same Forge example that comes with a {$version} or something like that, but I never knew how to use it.

 

Thanks a lot for the help ;)

Posted

I don't think that is what American means, I think he wants his ModInfo class (Which is presumably used for his @Mod annotation) and his mcmod.info file to be automatically updated from a gradle build property.

Posted

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)
On 16/5/2017 at 9:40 AM, Draco18s said:

Yes I guess that is, gonna take a look to see if I figure out how this works.

That is basically what already comes with the example mod I believe, that I don't know how to get it working. So.... kinda lost here. There must be more than just those def and that replace line, because when I try to build I get

4TPDdEU.png

Edited by American2050
Posted

...post...your...code...

 

Like, your gradle.build file and your main mod class.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • 2 weeks later...
Posted

So today, I redid it, so I could post the error I was getting, and for some reason I don't get the error anymore. So not sure, if either I did something different today, or if the other day it was Gradle doing some weird stuff.

Now the problem is, that it's not doing anything. Not sure what I'm missing.

 

Main Class
 

package com.mramericanmike.karatgarden;

import java.io.File;

import com.mramericanmike.karatgarden.configuration.ConfigValues;
import com.mramericanmike.karatgarden.configuration.ConfigurationHandler;
import com.mramericanmike.karatgarden.init.GeneralRecipes;
import com.mramericanmike.karatgarden.init.ModBlocks;
import com.mramericanmike.karatgarden.init.ModItems;
import com.mramericanmike.karatgarden.proxy.IProxy;

import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;

@Mod(modid = ModInfo.MODID, name = ModInfo.MOD_NAME, version = "{@version:mod}", guiFactory = ModInfo.GUI_FACTORY_CLASS, acceptedMinecraftVersions = "{@version:mc}")

public class KaratGarden
{
	@Mod.Instance(ModInfo.MODID)
	public static KaratGarden instance;
	
	@SidedProxy(clientSide = ModInfo.CLIENT_PROXY_CLASS, serverSide = ModInfo.SERVER_PROXY_CLASS)
	public static IProxy proxy;	
    
    @EventHandler
    public void preInit(FMLPreInitializationEvent event)
    {
    	//CONFIGURATION
    	ConfigurationHandler.init(new File(event.getModConfigurationDirectory(), ModInfo.MOD_NAME+".cfg"));
		MinecraftForge.EVENT_BUS.register(new ConfigurationHandler());
		
		//INIT ITEMS
    	ModItems.init();
    	
    	//INIT BLOCKS
    	ModBlocks.init();
    			
		//Register Renders - This will call the right Side - Check ClientProxy for Items and Blocks render registration
    	proxy.registerRender();
    	
    	//Init other Proxy stuff here - Check ClientProxy and ServerPorxy
    	proxy.otherInits();		
    	
    	//ADD SEEDS TO GRASS
    	if(ConfigValues.seedsDropsFromGrass){
    		MinecraftForge.addGrassSeed(new ItemStack(ModItems.SEED_CARROT_BASE), 10);
    	}
    }
    
    
    @EventHandler
    public void init(FMLInitializationEvent event)
    {
    	//INIT RECIPES
    	GeneralRecipes.init();
    }
    
    
    @EventHandler
    public void postInit(FMLPostInitializationEvent event)
    {
    }


}

 

The build.gradle

buildscript {
    repositories {
        jcenter()
        maven { url = "http://files.minecraftforge.net/maven" }
    }
    dependencies {
        classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
    }
}
apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.

def modVersion = "0.1.1"
def mcVersion = "1.11.2"


version = modVersion+"-["+mcVersion+"]"
group = "com.mramericanmike.karatgarden"
archivesBaseName = "KaratGarden"

sourceCompatibility = targetCompatibility = "1.8"
compileJava {
    sourceCompatibility = targetCompatibility = "1.8"
}

minecraft {
    version = "1.11.2-13.20.0.2296"
    runDir = "run"
    
    // the mappings can be changed at any time, and must be in the following format.
    // snapshot_YYYYMMDD   snapshot are built nightly.
    // stable_#            stables are built at the discretion of the MCP team.
    // Use non-default mappings at your own risk. they may not always work.
    // simply re-run your setup task after changing the mappings to update your workspace.
    mappings = "snapshot_20161220"
    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
    replace "{@version:mod}":modVersion,"{@version:mc}":mcVersion
}

dependencies {
    // you may put jars on which you depend on in ./libs
    // or you may define them like so..
    //compile "some.group:artifact:version:classifier"
    //compile "some.group:artifact:version"
      
    // real examples
    //compile 'com.mod-buildcraft:buildcraft:6.0.8:dev'  // adds buildcraft to the dev env
    //compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env

    // the 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
    //provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

    // the deobf configurations:  'deobfCompile' and 'deobfProvided' are the same as the normal compile and provided,
    // except that these dependencies get remapped to your current MCP mappings
    //deobfCompile 'com.mod-buildcraft:buildcraft:6.0.8:dev'
    //deobfProvided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

    // for more info...
    // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
    // http://www.gradle.org/docs/current/userguide/dependency_management.html

}

processResources {
    // this will ensure that this task is redone when the versions change.
    inputs.property "version", project.version
    inputs.property "mcversion", project.minecraft.version

    // replace stuff in mcmod.info, nothing else
    from(sourceSets.main.resources.srcDirs) {
        include 'mcmod.info'
                
        // replace version and mcversion
        expand 'version':project.version, 'mcversion':project.minecraft.version
    }
        
    // copy everything else except the mcmod.info
    from(sourceSets.main.resources.srcDirs) {
        exclude 'mcmod.info'
    }
}

 

 

I see the "processResources" there, I assume it's related with what I want to achieve here, but again, not sure, and don't understand what's going on there, that's why I'm asking here. That is all default as it comes with Forge

 

I do believe 1 time it did replaced somewhere, because when I launch on a test environment the built jar I get this:

 

 

So a 0.1.1 from somewhere and somewhere, got replaced.

Posted

Anyone has a clear guide for this explaining step by step everything that is needed?

 

I see once again I wont learn how to do this :P

 

I guess it's not just 1 line of code as Draco posted, but I need more stuff somewhere for this to work

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.