Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hey!

 

I'm new to forge modding, and this is probably just me being an idiot, but whenever I build my mod (either gradlew build or gradlew runClient), my recipes do not register.

It works in eclipse run, not gradlew build. I messed around with a bunch of things, but I still couldn't get it to work.

Anyways, it looks something along the lines of this now:

Generic.java

package tutorial.generic;

//Imports snipped

@Mod(modid=Generic.MODID, name=Generic.MODNAME, version=Generic.MODVER) //Tell forge "Oh hey, there's a new mod here to load."
public class Generic //Start the class Declaration
{
    //Set the ID of the mod (Should be lower case).
    public static final String MODID = "generic";
    //Set the "Name" of the mod.
    public static final String MODNAME = "somename";
    //Set the version of the mod.
    public static final String MODVER = "0.0.1";

    @Instance(value = Generic.MODID) //Tell Forge what instance to use.
    public static Generic instance;
    
    @SidedProxy(clientSide = "tutorial.generic.ClientProxy", serverSide = "tutorial.generic.ServerProxy")
    public static CommonProxy proxy;
    
    static GenEventHandler events = new GenEventHandler();
       
    @EventHandler
    public void preInit(FMLPreInitializationEvent event)
    {
    	proxy.preInit(event);
    	FMLCommonHandler.instance().bus().register(events);
    	MinecraftForge.EVENT_BUS.register(events);
    	GenericEntity.mainRegistry();
    	GameRegistry.addShapelessRecipe(new ItemStack(GenericItem.genericItem), new Object[] {Blocks.dirt});
    	GameRegistry.addRecipe(new ItemStack(GenericItem.genericItem),"  B"," A ","A  ",'A',Items.stick, 'B', Items.redstone);
    }
    
    @EventHandler
    public void init(FMLInitializationEvent event)
    {
    	proxy.init(event);
    }
       
    @EventHandler
    public void load(FMLInitializationEvent event)
    {

    }
       
    @EventHandler
    public void postInit(FMLPostInitializationEvent event)
    {
    	proxy.postInit(event);
    }
}

GenericItem.java

package tutorial.generic;

//Imports snipped

public class GenericItem extends Item {

public static Item genericItem;

@SideOnly(Side.CLIENT)
public EnumRarity getRarity(ItemStack par1ItemStack)
{
	return EnumRarity.epic;
}

public GenericItem(){
	setMaxStackSize(1);
	setCreativeTab(CreativeTabs.tabCombat);
	setUnlocalizedName("genericItem");
	setTextureName(Generic.MODID + ":genericTexture");
	setMaxDamage(400);
	setFull3D();
}

@EventHandler
public static final void init() {
	genericItem = new GenericItem()
	.setMaxStackSize(1)
	.setCreativeTab(CreativeTabs.tabCombat)
	.setUnlocalizedName("genericItem")
	.setTextureName(Generic.MODID + ":genericTexture")
	.setMaxDamage(400)
	.setFull3D();
	GameRegistry.registerItem(genericItem, "genericItem"); 


}

CommonProxy.java

package tutorial.generic;

//Imports snipped

public class CommonProxy {

    public void preInit(FMLPreInitializationEvent e) {
    	GenericItem.init();
    }

    public void init(FMLInitializationEvent e) {

    }

    public void postInit(FMLPostInitializationEvent e) {

    }

}

 

build.gradle

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.2-SNAPSHOT'
    }
}

apply plugin: 'forge'

version = "1.0"
group= "tutorial.generic.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "modid"

sourceSets {
    main {
        java { srcDirs = ["$projectDir/src/java"] }
        resources { srcDirs = ["$projectDir/src/resources"] }
    }
}

minecraft {
    version = "1.7.10-10.13.4.1558-1.7.10"
    runDir = "eclipse"
}

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

    // 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, thats not the mcmod.info
    from(sourceSets.main.resources.srcDirs) {
        exclude 'mcmod.info'
    }
}

  • Author

The files are located in src\main\java\tutorial\generic

I'm using 1.7 because I already have a server running that, that has some other mods, and I'd like it to be compatible without updating it (aka starting over).

  • Author

Eclipse run loads the mod and shows the prints

gradlew runClient does say that it loads the mod, it appears in the menu > mods etc., but doesn't show the prints

  • Author

After messing around a bit, adding some things, and trying to build it again, it now appears, that CommonProxy.class does not exist in the jar. 

 

Furthermore, assets\generic\textures only contains "entity" but should contain entity and "items"

  • Author

This makes a jar only with a META-INF folder, with a MANIFEST.MF containing "Manifest-Version: 1.0"

  • Author

Aha, that did the trick.

The files are all there and the code runs, crafting works etc.

I must have accidentally added that from some old tutorial.

 

Thanks a lot!

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.