Jump to content

Recommended Posts

Posted (edited)

mods.toml file:

# This is the mods.toml file. It contains the data relating to the loading mods.
# There are several mandatory fields (#mandatory), and many more that are optional (#optional).
# The overall format is standard TOML format, v0.5.0.
# Note that there are a couple of TOML lists in this file.
# Find more information on toml format here:  https://github.com/toml-lang/toml
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
modLoader="javafml" #mandatory
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
loaderVersion="[32,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
license="All rights reserved"
# A URL to refer people to when problems occur with this mod
issueTrackerURL="https://intosanctuary.com/" #optional
# A list of mods - how many allowed here is determined by the individual mod loader
[[mods]] #mandatory
# The modid of the mod
modId="exmod" #mandatory
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
version="1.16.1-0.0.1" #mandatory
 # A display name for the mod
displayName="Example Mod" #mandatory
# A URL to query for updates for this mod. See the JSON update specification <here>
updateJSONURL="http://myurl.me/" #optional
# A URL for the "homepage" for this mod, displayed in the mod UI
displayURL="https://intosanctuary.com/" #optional
# A file name (in the root of the mod JAR) containing a logo for display
logoFile="" #optional
# A text field displayed in the mod UI
credits="Thanks goes to all who have made outstanding Minecraft modding tutorials!" #optional
# A text field displayed in the mod UI
authors="Arnox" #optional
# The description text for the mod (multi line!) (#mandatory)
description='''
Does stuff.'''
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
[[dependencies.exmod]] #optional
    # the modid of the dependency
    modId="forge" #mandatory
    # Does this dependency have to exist - if not, ordering below must be specified
    mandatory=true #mandatory
    # The version range of the dependency
    versionRange="[32,)" #mandatory
    # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
    ordering="NONE"
    # Side this dependency is applied on - BOTH, CLIENT or SERVER
    side="BOTH"
# Here's another dependency
[[dependencies.exmod]]
    modId="minecraft"
    mandatory=true
    versionRange="[1.16.1]"
    ordering="NONE"
    side="BOTH"

 

ExampleMod.java file:

package com.Arnox.ExampleMod;

import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

// The value here should match an entry in the META-INF/mods.toml file
@Mod("exmod")
public class ExampleMod
{
    // Directly reference a log4j logger.
    private static final Logger LOGGER = LogManager.getLogger();

    public ExampleMod() {
        // Register the setup method for modloading
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
        // Register the doClientStuff method for modloading
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);
        // Register ourselves for server and other game events we are interested in
        MinecraftForge.EVENT_BUS.register(this);
    }

    private void setup(final FMLCommonSetupEvent event)
    {
        // some preinit code
    }

    private void doClientStuff(final FMLClientSetupEvent event) 
    {
        // do something that can only be done on the client
    }
}

 

As  you can see, there isn't anything here at all. Yet, even though there's only these two files, no matter what I do, I can't get it to run properly. There is no "examplemod" modid anywhere in these files, and yet, it still complains about it. For the love of everything, please help me get this to work. This is insanely frustrating. I haven't even written anything yet.

 

Working on 1.16.1, Forge version 32.0.106. Using the Eclipse Java IDE, AdoptOpenJDK 8.0.265.01-Hotspot, and JRE 1.8.

Edited by Arnox
Posted
buildscript {
    repositories {
        maven { url = 'https://files.minecraftforge.net/maven' }
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
    }
}
apply plugin: 'net.minecraftforge.gradle'
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

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

sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.

println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
minecraft {
    // 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 channel: 'snapshot', version: '20200514-1.16'
    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
    
    // 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
            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'

            // Recommended logging level for the console
            property 'forge.logging.console.level', 'debug'

            mods {
                exmod {
                    source sourceSets.main
                }
            }
        }

        server {
            workingDirectory project.file('run')

            // Recommended logging data for a userdev environment
            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'

            // Recommended logging level for the console
            property 'forge.logging.console.level', 'debug'

            mods {
                exmod {
                    source sourceSets.main
                }
            }
        }

        data {
            workingDirectory project.file('run')

            // Recommended logging data for a userdev environment
            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'

            // Recommended logging level for the console
            property 'forge.logging.console.level', 'debug'

            args '--mod', 'exmod', '--all', '--output', file('src/generated/resources/')

            mods {
                exmod {
                    source sourceSets.main
                }
            }
        }
    }
}

dependencies {
    // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
    // that the dep is a ForgeGradle 'patcher' dependency. And it's 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.16.1-32.0.106'

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

    // These dependencies get remapped to your current MCP mappings
    // deobf '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

}

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

// Example configuration to allow publishing using the maven-publish task
// This is the preferred method to reobfuscate your jar file
jar.finalizedBy('reobfJar') 
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
//publish.dependsOn('reobfJar')

publishing {
    publications {
        mavenJava(MavenPublication) {
            artifact jar
        }
    }
    repositories {
        maven {
            url "file:///${project.projectDir}/mcmodsrepo"
        }
    }
}

 

I also took the time to replace all instances of "examplemod" (lowercase only) as well with "exmod". Still no difference.

Posted

A small bit of good news. Looking through the console log, I found this:

 

Quote

[m[36m[10:27:33] [pool-2-thread-1/DEBUG] [ne.mi.fm.lo.mo.Scanner/SCAN]: Scanning C:\Users\User1\Desktop\minecraftTestMod\build\resources\main with language loader javafml
[m[36m[10:27:33] [pool-2-thread-1/DEBUG] [ne.mi.fm.ja.FMLJavaModLanguageProvider/SCAN]: Found @Mod class com.Arnox.ExampleMod.ExampleMod with id exmod
[m[36m[10:27:33] [pool-2-thread-1/DEBUG] [ne.mi.fm.ja.FMLJavaModLanguageProvider/SCAN]: Found @Mod class com.example.examplemod.ExampleMod with id examplemod

 

I have no idea where the hell it's finding that though. There's nothing in the above directory besides mods.toml and pack.mcmeta. The plot thickens too when I build the project and then look into the libs folder, open "modid-1.0.jar" and then I get this:

 

com

      Arnox

            examplemod

                  ExampleMod.class

      example

            examplemod

                  ExampleMod$RegistryEvents.class

                  ExampleMod.class

META-INF

      MANIFEST.MF

      mods.toml

pack.mcmeta

Posted (edited)

You should also change those in your build.gradle

Quote

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

to the values specific to your mod. If you use "exmod" as your modid, your package name also has to reflect that. So, your com.arnox.ExampleMod should become com.arnox.exmod (you should really put your package names all in lowercase). So change the 'group' and 'archivesBaseName' fields respectively with 'com.arnox.exmod' an 'exmod'. Setup your build.gradle again after changing anything inside it to refresh it with the new values

Edited by Beethoven92

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

Posted (edited)
23 minutes ago, Beethoven92 said:

You should also change those in your build.gradle

to the values specific to your mod. If you use "exmod" as your modid, your package name also has to reflect that. So, your com.arnox.ExampleMod should become com.arnox.exmod (you should really put your package names all in lowercase). So change the 'group' and 'archivesBaseName' fields respectively with 'com.arnox.exmod' an 'exmod'. Setup your build.gradle again after changing anything inside it to refresh it with the new values

 

Refactored com.Arnox.ExampleMod to com.arnox.exmod.

 

Edited the specified part in the build.gradle file to this:

version = '0.0.1'
group = 'com.arnox.exmod' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'exmod'

 

Executed the build setup "init" and "wrapper" gradle tasks.

 

Still erroring out with the same error.

 

Assembled jar file (exmod-0.0.1) now looks like this:

com

      Arnox

            exmod

                  ExampleMod.class

            examplemod

                  ExampleMod.class

      example

            examplemod

                  ExampleMod$RegistryEvents.class

                  ExampleMod.class

META-INF

      MANIFEST.MF

      mods.toml

pack.mcmeta

Edited by Arnox
Posted (edited)
7 minutes ago, Beethoven92 said:

Sorry, by "setup your build.gradle" i meant, re run genEclipseRuns. Should have specified that

Done. Still erroring out with the same error. Jar still has the same folders and files as listed in the last post.

 

More and more, I'm starting to think this is a gradle bug or something.

Edited by Arnox
Posted
10 minutes ago, Crazzy4999 said:

Just simply delete the whole example directory in your main directory it should fix it, you won't need that directory anyway

In the src/main/java directory? I'm afraid there's only what is shown in the screenshot. src/main/java/com/arnox/exmod/ExampleMod.java to be exact.

Posted
41 minutes ago, Arnox said:

In the src/main/java directory? I'm afraid there's only what is shown in the screenshot. src/main/java/com/arnox/exmod/ExampleMod.java to be exact.

Sorry i didn't see your pic i only read the first and last comment to see if you was able to solve this issue. I usually setup a new directory rather than using the Example one that's why i said to just delete it.

Posted (edited)

Deleted and reinstalled Eclipse entirely. Deleted the entire project files and redownloaded them (1.16.2 this time). Imported the Gradle Project. Did a test Client run before editing. Works just fine. Edited the package name to "com.arnox.exmod". Edited the modid in the ExampleMod.java file and all the modid's in the mods.toml file.

 

Still errors out in the exact same way.

 

Editing the build.gradle file to remove examplemod and then rerunning genEclipseruns and then another test Client run STILL gives the same error. Guys, I really think this is a bug...

 

EDIT: I tried just deleting the original mod package wholesale and creating it entirely from scratch (com.arnox.exmod2) and copied the contents of the old Java file to the new one. STILL THE SAME ERROR. WHAT THE HELL? It always sees com.example.examplemod. It never goes away! Please tell me other people are getting this error too.

Edited by Arnox
Posted

Show the contents of the "bin" folder? It might be that eclipse is duplicating the examplemod from a sourceset somewhere.

Posted
14 minutes ago, hiotewdew said:

Show the contents of the "bin" folder? It might be that eclipse is duplicating the examplemod from a sourceset somewhere.

bin

     main

          com

               arnox

                    exmod2

                         ExampleMod2$RegistryEvents.class

                         ExampleMod2.class

          META-INF

          pack.mcmeta

Posted

Try running "gradlew clean eclipse genEclipseRuns" and then refresh your gradle project (F5 when selecting project in package viewer)

Posted

It's also possible the examplemod is somehow included in the classpath. Check "Project and External Dependencies", your "run/mods" folder, and the build path (rclick project and external dependencies -> Build Path -> Configure Build Path... look for examplemod

Posted (edited)
31 minutes ago, hiotewdew said:

Try running "gradlew clean eclipse genEclipseRuns" and then refresh your gradle project (F5 when selecting project in package viewer)

FINALLYYYYYYYYY

 

The Hell is over. It's done. It works now. Finally... Thank you so much. ❤️

 

I guess my only question now is... Why is the command different when I run it in the command prompt as opposed to in the IDE?

Edited by Arnox

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.