Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.15.2] Minecraft Registry Problem When Loading from Jar
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 0
Jack Richard

[1.15.2] Minecraft Registry Problem When Loading from Jar

By Jack Richard, January 25 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Jack Richard    0

Jack Richard

Jack Richard    0

  • Tree Puncher
  • Jack Richard
  • Members
  • 0
  • 30 posts
Posted January 25

I have multiple shadowed dependencies in my mod, and it seems that something isn't working correctly here...

 

When I look in the jar file, all of my dependencies are properly relocated and included, but I seem to have an issue with Minecraft recognizing it as a mod. The error says 

Quote

Mod (modid) encountered an error during the load_registries event phase.

AIR

Very strange. The debug.log shows the mod failed to load because of a

Quote

java.lang.NoSuchFieldError: AIR

 

Here's my build.gradle if that will be any help.

buildscript {
    repositories {
        maven { url = 'https://files.minecraftforge.net/maven' }
        maven { url = "https://plugins.gradle.org/m2/" }
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
    }
}

plugins {
    id "com.github.johnrengelman.shadow" version "2.0.4"
}

apply plugin: 'java'
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

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

sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
//Print out JVM information so that we know what version is running. Extreamly useful for people to know when helping you.
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.15.1'
    // 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 {
                examplemod {
                    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 {
                examplemod {
                    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', 'examplemod', '--all', '--output', file('src/generated/resources/')

            mods {
                examplemod {
                    source sourceSets.main
                }
            }
        }
    }
}

project.tasks.build.dependsOn project.tasks.shadowJar

repositories {
    jcenter()
}

configurations {
    provided
    compile.extendsFrom provided
}

dependencies {
    minecraft 'net.minecraftforge:forge:1.15.2-31.2.36'

    compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.11.2'
    compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.2'
    compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.141.59'

    shadow group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.11.2'
    shadow group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.2'
    shadow group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.141.59'
}

shadowJar {
    configurations = [project.configurations.shadow]

    classifier ''

    relocate('org.apache', 'com.mod.apache')
    relocate('com.google', 'com.mod.google')
}

processResources {
    inputs.property "version", project.version
    inputs.property "mcversion", "1.15.2-31.2.36"

    from(sourceSets.main.resources.srcDirs) {
        include 'mcmod.info'
        expand 'version':project.version, 'mcversion': "1.15.2-31.2.36"
    }

    from(sourceSets.main.resources.srcDirs) {
        exclude 'mcmod.info'
    }
}

jar {
    manifest {
        attributes([
                "Specification-Title": "mod",
                "Specification-Vendor": "mod",
                "Specification-Version": "1", // We are version 1 of ourselves
                "Implementation-Title": project.name,
                "Implementation-Version": "${version}",
                "Implementation-Vendor" :"mod",
                "Multi-Release": 'true',
                "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
                "ContainedDeps": "byte-buddy-1.8.15.jar client-combined-3.141.59.jar commons-exec-1.3.jar guava-25.0-jre.jar okhttp-3.11.0.jar okio-1.14.0.jar"
        ])
    }
}

// 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"
        }
    }
}

 

My guess is that it is an error with the "minecraft" dependancy, I just don't know where to start on fixing it.

 

Thanks in advance!

  • Quote

Share this post


Link to post
Share on other sites

DaemonUmbra    541

DaemonUmbra

DaemonUmbra    541

  • Reality Controller
  • DaemonUmbra
  • Forum Team
  • 541
  • 10340 posts
Posted January 25

First of all, why are you shadowing log4j? Minecraft already provides log4j2.

Second if build is running shadowjar instead of jar then you might need to tweak the line where it says jar.finalizedBy('reobfJar') to finalize shadowJar instead

  • Quote

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

Spoiler

Logs (Most issues require logs to diagnose):

Spoiler

Please post logs using one of the following sites (Thank you Lumber Wizard for the list):

https://gist.github.com/: 100MB Requires member (Free)

https://pastebin.com/: 512KB as guest, 10MB as Pro ($$$)

https://hastebin.com/: 400KB

Do NOT use sites like Mediafire, Dropbox, OneDrive, Google Drive, or a site that has a countdown before offering downloads.

 

What to provide:

...for Crashes and Runtime issues:

Minecraft 1.14.4 and newer:

Post debug.log

Older versions:

Please update...

 

...for Installer Issues:

Post your installer log, found in the same place you ran the installer

This log will be called either installer.log or named the same as the installer but with .log on the end

Note for Windows users:

Windows hides file extensions by default so the installer may appear without the .jar extension then when the .log is added the log will appear with the .jar extension

 

Where to get it:

Mojang Launcher: When using the Mojang launcher debug.log is found in .minecraft\logs.

 

Twitch Launcher: If you are using the Twitch Launcher, their configurations break Forge's log settings, fortunately there is an easier workaround than I originally thought, this works even with Twitch's installation of the Minecraft launcher as long as it is not launched THROUGH Twitch:

Spoiler
  1. Make sure you have the correct version of Forge installed (some packs are heavily dependent on one specific build of Forge)
  2. Make a launcher profile targeting this version of Forge.
  3. Set the launcher profile's GameDir property to the pack's instance folder (not the instances folder, the folder that has the pack's name on it).
  4. Now launch the pack through that profile and follow the "Mojang Launcher" instructions above.

Video:

Spoiler

 

 

 

or alternately, 

 

Fallback ("No logs are generated"):

If you don't see logs generated in the usual place, provide the launcher_log.txt from .minecraft

 

Server Not Starting:

Spoiler

If your server does not start or a command window appears and immediately goes away, run the jar manually and provide the output.

 

Reporting Illegal/Inappropriate Adfocus Ads:

Spoiler

Get a screenshot of the URL bar or copy/paste the whole URL into a thread on the General Discussion board with a description of the Ad.

Lex will need the Ad ID contained in that URL to report it to Adfocus' support team.

 

Posting your mod as a GitHub Repo:

Spoiler

When you have an issue with your mod the most helpful thing you can do when asking for help is to provide your code to those helping you. The most convenient way to do this is via GitHub or another source control hub.

When setting up a GitHub Repo it might seem easy to just upload everything, however this method has the potential for mistakes that could lead to trouble later on, it is recommended to use a Git client or to get comfortable with the Git command line. The following instructions will use the Git Command Line and as such they assume you already have it installed and that you have created a repository.

 

  1. Open a command prompt (CMD, Powershell, Terminal, etc).
  2. Navigate to the folder you extracted Forge’s MDK to (the one that had all the licenses in).
  3. Run the following commands:
    1. git init
    2. git remote add origin [Your Repository's URL]
      • In the case of GitHub it should look like: https://GitHub.com/[Your Username]/[Repo Name].git
    3. git fetch
    4. git checkout --track origin/master
    5. git stage *
    6. git commit -m "[Your commit message]"
    7. git push
  4. Navigate to GitHub and you should now see most of the files.
    • note that it is intentional that some are not synced with GitHub and this is done with the (hidden) .gitignore file that Forge’s MDK has provided (hence the strictness on which folder git init is run from)
  5. Now you can share your GitHub link with those who you are asking for help.

[Workaround line, please ignore]

 

Share this post


Link to post
Share on other sites

Jack Richard    0

Jack Richard

Jack Richard    0

  • Tree Puncher
  • Jack Richard
  • Members
  • 0
  • 30 posts
Posted January 25
16 minutes ago, DaemonUmbra said:

First of all, why are you shadowing log4j? Minecraft already provides log4j2.

Second if build is running shadowjar instead of jar then you might need to tweak the line where it says jar.finalizedBy('reobfJar') to finalize shadowJar instead

Thanks so much for your help!

I removed the log4j dependency, I honesty don't remember when I put that there. Once I fixed the jar.finalizedBy line, everything worked! (One small issue where I was relocating all of "com.google" when I just should've relocated "com.google.common," too)

 

Thanks again!

  • Quote

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • milkman69
      My game keeps crashing and I haven't even added any mods on yet

      By milkman69 · Posted 14 minutes ago

      curse launcher?
    • diesieben07
      My game keeps crashing and I haven't even added any mods on yet

      By diesieben07 · Posted 15 minutes ago

      Are you using the Curse Launcher?
    • milkman69
      My game keeps crashing and I haven't even added any mods on yet

      By milkman69 · Posted 19 minutes ago

    • diesieben07
      My game keeps crashing and I haven't even added any mods on yet

      By diesieben07 · Posted 20 minutes ago

      Show a screenshot of your logs folder.
    • milkman69
      My game keeps crashing and I haven't even added any mods on yet

      By milkman69 · Posted 20 minutes ago

      I dont see any logs for February 27
  • Topics

    • milkman69
      20
      My game keeps crashing and I haven't even added any mods on yet

      By milkman69
      Started Wednesday at 11:53 PM

    • Coloringgamer
      1
      Error

      By Coloringgamer
      Started 1 hour ago

    • NullDev
      3
      Detect Bottle use on fluid

      By NullDev
      Started 13 hours ago

    • NorthWestWind
      0
      [1.16.5] Make item render like bow in thirdperson

      By NorthWestWind
      Started 1 hour ago

    • ehbean
      3
      1.16.x Custom Furnace/Brewing Stand

      By ehbean
      Started 14 hours ago

  • Who's Online (See full list)

    • NullDev
    • Aecht_Rob
    • milkman69
    • ehbean
    • ItsGeNoxx
    • lliinnkk10
    • Fiopon
    • Th1Minecraft
    • IronLeDXY
    • Fred the Wizard
    • Abrynos
    • pitbox46
    • diesieben07
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.15.2] Minecraft Registry Problem When Loading from Jar
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community