-1

I am quite new to modding and don't know forge at all, and for some reason my mcmod.info file will not load. It says:

No mod information found. Please ask your mod author to provide a mcmod.info file.

I have a mcmod.info file set up. I have looked through other issues that seem similar, but the fixes they suggest have not helped.

My Main.java looks like this:

package com.crackrsnackr.simpleweapons;

import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraftforge.event.RegistryEvent;
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.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.registry.GameRegistry;

@Mod(
    modid = Main.MOD_ID,
    name = Main.MOD_NAME,
    version = Main.VERSION
)
public class Main {

public static final String MOD_ID = "simpleweapons";
public static final String MOD_NAME = "Simple Weapons";
public static final String VERSION = "1.0";

/**
 * This is the instance of your mod as created by Forge. It will never be null.
 */
@Mod.Instance(MOD_ID)
public static Main INSTANCE;

/**
 * This is the first initialization event. Register tile entities here.
 * The registry events below will have fired prior to entry to this method.
 */
@Mod.EventHandler
public void preinit(FMLPreInitializationEvent event) {

}

/**
 * This is the second initialization event. Register custom recipes
 */
@Mod.EventHandler
public void init(FMLInitializationEvent event) {

}

/**
 * This is the final initialization event. Register actions from other mods here
 */
@Mod.EventHandler
public void postinit(FMLPostInitializationEvent event) {

}

/**
 * Forge will automatically look up and bind blocks to the fields in this class
 * based on their registry name.
 */
@GameRegistry.ObjectHolder(MOD_ID)
public static class Blocks {
  /*
      public static final MySpecialBlock mySpecialBlock = null; // placeholder for special block below
  */
}

/**
 * Forge will automatically look up and bind items to the fields in this class
 * based on their registry name.
 */
@GameRegistry.ObjectHolder(MOD_ID)
public static class Items {
  /*
      public static final ItemBlock mySpecialBlock = null; // itemblock for the block above
      public static final MySpecialItem mySpecialItem = null; // placeholder for special item below
  */
}

/**
 * This is a special class that listens to registry events, to allow creation of mod blocks and items at the proper time.
 */
@Mod.EventBusSubscriber
public static class ObjectRegistryHandler {
    /**
     * Listen for the register event for creating custom items
     */
    @SubscribeEvent
    public static void addItems(RegistryEvent.Register<Item> event) {
       /*
         event.getRegistry().register(new ItemBlock(Blocks.myBlock).setRegistryName(MOD_ID, "myBlock"));
         event.getRegistry().register(new MySpecialItem().setRegistryName(MOD_ID, "mySpecialItem"));
        */
    }

    /**
     * Listen for the register event for creating custom blocks
     */
    @SubscribeEvent
    public static void addBlocks(RegistryEvent.Register<Block> event) {
       /*
         event.getRegistry().register(new MySpecialBlock().setRegistryName(MOD_ID, "mySpecialBlock"));
        */
    }
}
/* EXAMPLE ITEM AND BLOCK - you probably want these in separate files
public static class MySpecialItem extends Item {

}

public static class MySpecialBlock extends Block {

}
*/
}

I have reset the mcmod.info file, so it looks quite basic. (Yes, it was more specific to my mod earlier before I reset it, and the info file still would not load.) It now looks like this:

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

My build.gradle looks like this:

 MCVersion  Official field/method names from Mojang mapping files
//
// You must be aware of the Mojang license when using the 'official' mappings.
// See more information here: 
https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
//
// 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 channel: 'stable', version: '39-1.12'

// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')

// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs {
    client {
        workingDirectory project.file('run')

        // Recommended logging data for a userdev environment
        // The markers can be added/removed as needed separated by commas.
        // "SCAN": For mods scan.
        // "REGISTRIES": For firing of registry events.
        // "REGISTRYDUMP": For getting the contents of all registries.
        property 'forge.logging.markers', 'REGISTRIES'

        // Recommended logging level for the console
        // You can set various levels here.
        // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the- 
different-log-levels
        property 'forge.logging.console.level', 'debug'

        mods {
            simpleweapons {
                source sourceSets.main
            }
        }
    }

    server {
        workingDirectory project.file('run')

        // Recommended logging data for a userdev environment
        // The markers can be added/removed as needed separated by commas.
        // "SCAN": For mods scan.
        // "REGISTRIES": For firing of registry events.
        // "REGISTRYDUMP": For getting the contents of all registries.
        property 'forge.logging.markers', 'REGISTRIES'

        // Recommended logging level for the console
        // You can set various levels here.
        // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the- 
 different-log-levels
        property 'forge.logging.console.level', 'debug'

        mods {
            simpleweapons {
                source sourceSets.main
            }
        }
    }
}
}

// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }

repositories {
// Put repositories for dependencies here
// ForgeGradle automatically adds the Forge maven and Maven Central for you

// If you have mod jar dependencies in ./libs, you can declare them as a repository like 
so:
// flatDir {
//     dir 'libs'
// }
}

dependencies {
// Specify the version of Minecraft to use. If this is any group other than 
'net.minecraft' it is assumed
// that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied.
// The userdev artifact is a special name and will get all sorts of transformations 
applied to it.
minecraft 'net.minecraftforge:forge:1.12.2-14.23.5.2860'

// Real mod deobf dependency examples - these get remapped to your current mappings
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API 
as a compile dependency
// runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full 
JEI mod as a runtime dependency
// implementation 
fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // 
Adds registrate as a dependency

// Examples using mod jars from ./libs
// implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")

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

// Example for how to get properties into the manifest for reading at runtime.
jar {
manifest {
    attributes([
            "Specification-Title"     : "simpleweapons",
            "Specification-Vendor"    : "TheCrackrSnackr",
            "Specification-Version"   : "1", // We are version 1 of ourselves
            "Implementation-Title"    : project.name,
            "Implementation-Version"  : project.jar.archiveVersion,
            "Implementation-Vendor"   : "TheCrackrSnackr",
            "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
    ])
}
}

jar.finalizedBy('reobfJar')

And if this changes anything, I added a pack.mcmeta, (for some reason the mod making software didn't generate it) and my project has a gradle.properties, and a settings.gradle.

I am using the latest version of Intellij Community Edition and used the Minecraft Development Plugin to setup my forge 1.12.2 workspace.

By the way, I forgot to add this, my console throws an IllegalArgumentException when I run the game client.

  • If it is the problem, I'm struggling with, then try to compile the mod, open the created jar (located in `build/libs/`) with a file archiver and look whats inside `/mcmod.info`. I guess we have to tell ForgeGradle to pass every resource file to Minecraft. When you're using translations (lang files in `src/main/resources/assets`) they'll be missing too. However, I'll let you know when I find anything out. – Lukas Mar 25 '22 at 19:28

1 Answers1

0

The solution for our problem:

https://stackoverflow.com/a/70151634/14769872

I've edited it because I don't want to edit 3 files when I update the Mod's version or Minecraft version. Because it's related, here is my code:

build.gradle - replaced (line 11-14)

version = '1.0'
group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'modid'

with

// +SETTINGS
def domain = 'com.yourname' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
def modid = 'modid'
def mcversion = '1.12.2'
version = '1.0'
// -SETTINGS

group = "${domain}.${modid}"
archivesBaseName = "${modid}_${mcversion}" // add Minecraft version to jar for better user friendliness

build.gradle - at the end

apply plugin: 'idea'
idea {
    module {
        inheritOutputDirs = true
    }
}
subprojects {
    apply plugin: 'idea'
}


task prepareAssets(type: Copy) {
    group = 'build'
    from(sourceSets.main.resources.srcDirs) {
        include 'mcmod.info'

        // replace version and mcversion
        expand 'version':project.version, 'mcversion':mcversion
    }
    from project.file('src/main/resources')
    into project.file('build/classes/java/main')
}

classes.dependsOn(prepareAssets)

// replace values in mcmod.info before packing in jar
processResources {
    // replace stuff in mcmod.info, nothing else
    from(sourceSets.main.resources.srcDirs) {
        include 'mcmod.info'

        // replace version and mcversion
        expand 'version':project.version, 'mcversion':mcversion
    }

    // copy everything else, thats not the mcmod.info
    from(sourceSets.main.resources.srcDirs) {
        exclude 'mcmod.info'
    }
}

My build.gradle may be everything but performant (since the versions are overwritten twice when building or running) but I don't like to spend too much time in learning how to use Gradle for now (Especially for a no longer developed version of Forge).

To never have to change my Main class again, I changed the mod annotation:

`@Mod(modid = "modid", useMetadata = true)`

useMetadata takes alle required information from the mcmod.info file (Docs).

Lukas
  • 96
  • 2
  • 6