如何修复未加载的mcmod.info文件



我对修改很陌生,根本不知道forge,而且由于某种原因,我的mcmod.info文件将无法加载。上面写着:

未找到mod信息。请让你的mod作者提供一个mcmod.info文件。

我已经设置了一个mcmod.info文件。我已经研究了其他类似的问题,但他们提出的解决方案并没有帮助。

我的Main.java看起来像这样:

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 {
}
*/
}

我已经重置了mcmod.info文件,所以它看起来很基本。(是的,在我重置它之前,它更具体地针对我的mod,信息文件仍然无法加载。(现在看起来是这样的:

[
{
"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": []
}
]

我的build.gradle看起来是这样的:

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')

如果这改变了什么,我添加了一个pack.mcmeta(由于某种原因,mod制作软件没有生成它(,我的项目有一个grade.properties和一个settings.grade.

我使用的是Intellij社区版的最新版本,并使用Minecraft开发插件来设置我的forge 1.12.2工作区。

顺便说一句,我忘了添加这个,当我运行游戏客户端时,我的控制台抛出了一个IllegalArgumentException。

我们问题的解决方案:

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

我编辑了它,因为我不想在更新Mod的版本或Minecraft版本时编辑3个文件。因为它是相关的,这是我的代码:

build.gradle-已更换(11-14行(

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

带有

// +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-末端

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'
}
}

我的build.gradle可能一点也不性能(因为在构建或运行时版本会被覆盖两次(,但我现在不喜欢花太多时间学习如何使用gradle(尤其是对于不再开发的Forge版本(。

为了不再需要更改我的Main类,我更改了mod注释:

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

useMetadatamcmod.info文件(Docs(中获取所有必需的信息。

最新更新