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 5/16/2017 at 12:40 PM, Draco18s said:
Expand  

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • You will find the crash-report or log in your minecraft directory (crash-report or logs folder)
    • Use a modpack which is using these 2 mods as working base:   https://www.curseforge.com/minecraft/modpacks/life-in-the-village-3
    • inicie un mundo donde instale Croptopia y Farmer's Delight, entonces instale el addon Croptopia Delight pero no funciona. es la version 1.18.2
    • Hello all. I'm currently grappling with the updateShape method in a custom class extending Block.  My code currently looks like this: The conditionals in CheckState are there to switch blockstate properties, which is working fine, as it functions correctly every time in getStateForPlacement.  The problem I'm running into is that when I update a state, the blocks seem to call CheckState with the position of the block which was changed updated last.  If I build a wall I can see the same change propagate across. My question thus is this: is updateShape sending its return to the neighbouring block?  Is each block not independently executing the updateShape method, thus inserting its own current position?  The first statement appears to be true, and the second false (each block is not independently executing the method). I have tried to fix this by saving the block's own position to a variable myPos at inception, and then feeding this in as CheckState(myPos) but this causes a worse outcome, where all blocks take the update of the first modified block, rather than just their neighbour.  This raises more questions than it answers, obviously: how is a different instance's variable propagating here?  I also tried changing it so that CheckState did not take a BlockPos, but had myPos built into the body - same problem. I have previously looked at neighbourUpdate and onNeighbourUpdate, but could not find a way to get this to work at all.  One post on here about updatePostPlacement and other methods has proven itself long superceded.  All other sources on the net seem to be out of date. Many thanks in advance for any help you might offer me, it's been several days now of trying to get this work and several weeks of generally trying to get round this roadblock.  - Sandermall
    • sorry, I might be stupid, but how do I open it? because the only options I have are too X out, copy it, which doesn't work and send crash report, which doesn't show it to me, also, sorry for taking so long.
  • Topics

×
×
  • Create New...

Important Information

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