Jump to content

Recommended Posts

Posted

I'm trying to create a mod alongside with my main mod that stores some of the most used Forge methods (ie methods involving item creation, block creation, etc.). I'm also trying to avoid having the two mods complied together under the same zip folder whenever I compile the mods. I'm currently using the Eclipse IDE and Forge 1.12.2-14.23.2.2615.

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

I haven't made the actual library yet. Do I add in another package and specify it in the build.gradle to separate them into two different zip files?

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted (edited)

Ok so, this bit here (redacted for simplicity):

from zipTree(jar.outputs.getFiles().getSingleFile()).matching {
    exclude 'com/draco18s/ores/**', 'com/draco18s/industry/**'
}

This removes my "actual mod" from being included in a compiled jar file. In this case, it excludes the folder com/draco18s/ores and com/draco18s/industry, as we only want the library in this jar.

 

Then this bit here:

from zipTree(jar.outputs.getFiles().getSingleFile()).matching {
    include 'com/draco18s/ores/**', 'assets/harderores/**', 'cog_config/**'
    exclude '**.xcf'
}

Makes sure to only include com/draco18s/ores, and its associated assets. The exclude line makes sure not to include large, layered, GIMP image files that aren't actually used by the mod (it's a template for the icons actually used). Your gradle file will already have one task that builds everything. You can rename it and modify the include/exclude as appropriate, then duplicate and modify again, using a new task name.

 

At the bottom, these bits:

oresJar.dependsOn('reobfJar')

set up to make sure that gradle does all of the appropriate compilation tasks in the proper order.

 

Lastly, this is a task that does a full compile (builds all the jars, redacted slightly for simplicity):

task releaseJars(type: Copy) {
    from coreJarNoCog
    from oresJar
    rename '-(.*)jar', '.jar'
    rename '-(.*)zip', '.zip'
    into '.'
}

This task will already exist in your gradle file, you just need to add the from lines so that a full build builds all of your other jar tasks.

Edited by Draco18s
  • Like 2

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

I did something like this:

 

buildscript {
    repositories {
        jcenter()
        maven { url = "http://files.minecraftforge.net/maven" }
    }
    dependencies {
        classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
    }
}
apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.

def libVersion      = "1"
def majorVersion    = "0"
def minorVersion    = "1"
//bug patch or testing versions
def tkcraftVersion  = "f"
def prePend = "1.12.2-"
def packageVersion  = libVersion+"."+majorVersion+"."+minorVersion+tkcraftVersion

tkcraftVersion = libVersion+"."+majorVersion+"."+minorVersion+tkcraftVersion

version = ""
group= "com.novaviper.ecore" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = prePend+"EclipseCore"+packageVersion

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

minecraft {
    version = "1.12.2-14.23.2.2615"
    runDir = "run"
    
    // 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 = "snapshot_20171003"
    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
    replace "{@version:lib}":libVersion,"{@version:tkcraft}":tkcraftVersion,"required-after:ecore":("required-after:ecore@["+libVersion+",]"),"/*{uncomment}":"","{uncomment}*/":""
}

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

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

    // the deobf configurations:  'deobfCompile' and 'deobfProvided' are the same as the normal compile and provided,
    // except that these dependencies get remapped to your current MCP mappings
    //deobfCompile 'com.mod-buildcraft:buildcraft:6.0.8:dev'
    //deobfProvided '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

}

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

task eCoreJar(type: Jar) {
    baseName = prePend+'EclipseCore-v'+libVersion

    from('etc/lib') {
        include '*.info'
        expand 'version': libVersion, 'mcversion': project.minecraft.version
    }

    from zipTree(jar.outputs.getFiles().getSingleFile()).matching {
        exclude 'com/novaviper/terrakoncraft/**', 'mcmod.info', 'TODO.txt', 'assets/**', 'config/**'
    }
}

task terrakonCraftJar(type: Jar) {
    baseName = prePend+'TerrakonCraft-'+tkcraftVersion

    from('etc/tkcraft') {
        include '*.info'
        expand 'version': tkcraftVersion, 'mcversion': project.minecraft.version
    }

    from zipTree(jar.outputs.getFiles().getSingleFile()).matching {
        include 'com/novaviper/terrakoncraft/**', 'assets/terrakoncraft/**'
    }
}

eCoreJar.dependsOn('reobfJar')
terrakonCraftJar.dependsOn('reobfJar')

task releaseJars(type: Copy) {
    from eCoreJar
    from terrakonCraftJar
    //one of these lines crashes it?
    rename '-(.*)jar', '.jar'
    rename '-(.*)zip', '.zip'
    into '.'
}

task fullBuild(type: Delete) {
    delete jar
}

fullBuild.dependsOn('releaseJars')

 

I haven't gotten the chance to try it out, since I've been busy with school work. But something like this would suffice, right?

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted

Looks correct.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
  On 2/14/2018 at 10:35 PM, NovaViper said:

What about the mcmod.info file? Is there a way to generate multiple versions for each mod?

Expand  

I created a folder (called etc/) that I then created subfolders for and used those...let me grab how that works...

https://github.com/Draco18s/ReasonableRealism/blob/master/build.gradle#L99-L102

I never included the etc/ folder on my repo, but you should be able to work that part out yourself:

 

Capture.PNG

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Ah, that's what that's for. Hm.. Would it be possible to have that in the assets folder (src/main/resources) so I don't have to clone each file into the etc/ folder?

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted

Also, when I want to build the project, do I run the normal gradlew build  command or run one of the newly defined tasks in the build.gradle?

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted
  On 2/15/2018 at 3:26 AM, NovaViper said:

Ah, that's what that's for. Hm.. Would it be possible to have that in the assets folder (src/main/resources) so I don't have to clone each file into the etc/ folder?

Expand  

You could. But you'd have to put them in subfolders, because otherwise you would have multiple files with the same name in the same directory.

 

  On 2/15/2018 at 3:36 AM, NovaViper said:

Also, when I want to build the project, do I run the normal gradlew build  command or run one of the newly defined tasks in the build.gradle?

Expand  

gradlew build fullBuild

or

gradlew build terrakonCraftJar

or

gradlew build eCoreJar

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
  On 2/15/2018 at 3:56 AM, Draco18s said:

You could. But you'd have to put them in subfolders, because otherwise you would have multiple files with the same name in the same directory.

Expand  

I just placed them in subfolders, but Minecraft/Forge didn't seem to pick them up at all D: 

 

Here's the directory: https://imgur.com/rNUlJPw

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted (edited)

The build commands seem to fail for some reason when it gets to releaseJars.. with this error

And I get 4 files: two of them (1.12.2-TerrakonCraft-1.0.1f.jar and 1.12.2-EclipseCore-v1.jar) are each of the mods, and the other two (1.12.2-EclipseCore1.0.1f.jar and 1.12.2-EclipseCore1.0.1f-sources.jar) have stuff for both of the mods. Another strange thing is that 1.12.2-EclipseCore-v1.jar has the code for Eclipse Core only, but still has the etc/ subfolders of both mods.

 

Finally.. I'm not sure if this is normal but several new folders (along with the libs folder, which the mods appear in) appeared after running the command. These folders are classes, dependency-cache, libs, resources, retromaping,sources, taskLogs, and tmp. From the very last time I made mods, these folders didn't appear, but merely the jars of the mod did (and not grouped in a folder)

Edited by NovaViper
Mentioned the build items that appered

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted
  Quote

> The process cannot access the file because another process has locked a portion of the file

Expand  

One of the files is locked and can't be edited. Its in use (or incorrectly locked).

 

As for your files, you need to tell the build task where to take the files from and where to put them. It's not automagic.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

I'm kinda at a lost.. How can I get Forge to look into the subfolders for the mcmod.info files when the game loads up?

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted
  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

That helped alot there, thanks! :D Now I have another issue, whenever I build, the etc folder ends up in the EclipseCore jar but not in the Terrakon jar (I dont want that in either folder). And I still have that locked gradle error, despite I (supposedly) not using gradle anywhere else (expect Eclipse, maybe that's causing the issue?)

 

What my build.gradle looks like currently:

 

buildscript {
    repositories {
        jcenter()
        maven { url = "http://files.minecraftforge.net/maven" }
    }
    dependencies {
        classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
    }
}
apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.

def libVersion      = "1"
def majorVersion    = "0"
def minorVersion    = "1"
//bug patch or testing versions
def tkcraftVersion  = "f"
def prePend = "1.12.2-"
def packageVersion  = libVersion+"."+majorVersion+"."+minorVersion+tkcraftVersion

tkcraftVersion = libVersion+"."+majorVersion+"."+minorVersion+tkcraftVersion

version = ""
group= "com.novaviper.ecore" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = prePend+"NovaCraft"+packageVersion

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

minecraft {
    version = "1.12.2-14.23.2.2615"
    runDir = "run"
    
    // 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 = "snapshot_20171003"
    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
}

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

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

    // the deobf configurations:  'deobfCompile' and 'deobfProvided' are the same as the normal compile and provided,
    // except that these dependencies get remapped to your current MCP mappings
    //deobfCompile 'com.mod-buildcraft:buildcraft:6.0.8:dev'
    //deobfProvided '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

}

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

task eCoreJar(type: Jar) {
    baseName = 'EclipseCore-'+prePend+libVersion

    from('src/main/resources/etc/lib') {
        include '*.info'
        expand 'version': libVersion, 'mcversion': project.minecraft.version
    }

    from zipTree(jar.outputs.getFiles().getSingleFile()).matching {
        exclude 'com/novaviper/terrakoncraft/**', 'mcmod.info', 'assets/terrakoncraft/**'
    }
}

task terrakonCraftJar(type: Jar) {
    baseName = 'TerrakonCraft-'+prePend+tkcraftVersion

    from('src/main/resources/etc/tkcraft') {
        include '*.info'
        expand 'version': tkcraftVersion, 'mcversion': project.minecraft.version
    }

    from zipTree(jar.outputs.getFiles().getSingleFile()).matching {
        include 'com/novaviper/terrakoncraft/**', 'assets/terrakoncraft/**'
    }
}

eCoreJar.dependsOn('reobfJar')
terrakonCraftJar.dependsOn('reobfJar')

task releaseJars(type: Copy) {
    from eCoreJar
    from terrakonCraftJar
    //one of these lines crashes it?
    rename '-(.*)jar', '.jar'
    rename '-(.*)zip', '.zip'
    into '.'
}

task fullBuild(type: Delete) {
    delete jar
}

fullBuild.dependsOn('releaseJars')

 

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted

Add an exclude entry for it.

*Shrug*

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)

I tried that but the etc folder still appears in the library jar

 

--Edit--

I did the include method like in the terrakonJar task and that made it go away

Edited by NovaViper

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

  • 2 weeks later...
Posted (edited)

Hey @Draco18s, I added in a dependency to the build, now eclipse says it can't find the library despite I ran the setup commands for Eclipse. It keeps saying unresolved dependency

 

--Edit--

I fixed it, but I still can't get Forge to look into the etc folder and find each mod's mcmod.info file

Edited by NovaViper

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted
  On 2/24/2018 at 1:41 PM, NovaViper said:

 

I fixed it, but I still can't get Forge to look into the etc folder and find each mod's mcmod.info file

Expand  

I'm not sure. I just know that what I have works. Show your folder structure and gradle.build file again?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Here you go.

 

//Thanks to Draco18s for the library/mod seperation!
buildscript {
    repositories {
        jcenter()
        maven { url = "http://files.minecraftforge.net/maven" }
    }
    dependencies {
        classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
    }
}
apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.

def libVersion      = "1"
def majorVersion    = "0"
def minorVersion    = "1"
//bug patch or testing versions
def tkcraftVersion  = "f"
def prePend = "1.12.2-"
def packageVersion  = libVersion+"."+majorVersion+"."+minorVersion+tkcraftVersion

tkcraftVersion = libVersion+"."+majorVersion+"."+minorVersion+tkcraftVersion

version = ""
group= "com.novaviper.ecore" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = prePend+"NovaCraft"+packageVersion

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

minecraft {
    version = "1.12.2-14.23.2.2615"
    runDir = "run"
    
    // 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 = "snapshot_20171003"
    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
}

repositories {
    maven {
        url "https://maven.mcmoddev.com/"
    }
}

dependencies {
    compile "net.ilexiconn:llibrary:1.7.9-1.12.2:dev"
}

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

task eCoreJar(type: Jar) {
    baseName = 'EclipseCore-'+prePend+libVersion

    from('src/main/resources/etc/lib') {
        include '*.info'
        expand 'version': libVersion, 'mcversion': project.minecraft.version
    }

    from zipTree(jar.outputs.getFiles().getSingleFile()).matching {
        include 'com/novaviper/eclipsecore/**', 'assets/eclipsecore/**'
    }
}

task terrakonCraftJar(type: Jar) {
    baseName = 'TerrakonCraft-'+prePend+tkcraftVersion

    from('src/main/resources/etc/tkcraft') {
        include '*.info'
        expand 'version': tkcraftVersion, 'mcversion': project.minecraft.version
    }

    from zipTree(jar.outputs.getFiles().getSingleFile()).matching {
        include 'com/novaviper/terrakoncraft/**', 'assets/terrakoncraft/**'
    }
}

eCoreJar.dependsOn('reobfJar')
terrakonCraftJar.dependsOn('reobfJar')

task releaseJars(type: Copy) {
    from eCoreJar
    from terrakonCraftJar
    //one of these lines crashes it?
    rename '-(.*)jar', '.jar'
    rename '-(.*)zip', '.zip'
    into '.'
}

task fullBuild(type: Delete) {
    delete jar
}

fullBuild.dependsOn('releaseJars')

 

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted
  On 2/24/2018 at 5:59 PM, Draco18s said:

Show your folder structure

Expand  

 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

To TerrakonCraft: C:\Users\novag\eclipse-workspace\Minecraft\TerrakonCraft\src\main\resources\etc\tkcraft\mcmod.info

To EclipseCore: C:\Users\novag\eclipse-workspace\Minecraft\TerrakonCraft\src\main\resources\etc\lib\mcmod.info

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted

I'm not sure :\

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hi here is an update. I was able to fix the code so my mod does not crash Minecraft. Please understand that I am new to modding but I honestly am having a hard time understanding how anyone can get this to work without having extensive programming and debugging experience as well as searching across the Internet, multiple gen AI bots (claude, grok, openai), and examining source code hidden in the gradle directory and in various github repositories. I guess I am wrong because clearly there are thousands of mods so maybe I am just a newbie. Ok, rant over, here is a step by step summary so others can save the 3 days it took me to figure this out.   1. First, I am using forge 54.1.0 and Minecraft 1.21.4 2. I am creating a mod to add a shotgun to Minecraft 3. After creating the mod and compiling it, I installed the .jar file to the proper directory in Minecraft and used 1.21.4-forge-54.1.0 4. The mod immediately crashed with the error: Caused by: java.lang.NullPointerException: Item id not set 5. Using the stack trace, I determined that the Exception was being thrown from the net.minecraft.world.item.Item.Properties class 6. It seems that there are no javadocs for this class, so I used IntelliJ which was able to provide a decompiled version of the class, which I then examined to see the source of the error. Side question: Are there javadocs? 7. This method, specifically, was the culprit: protected String effectiveDescriptionId() {      return this.descriptionId.get(Objects.requireNonNull(this.id, "Item id not set"));  } 8. Now my quest was to determine how to set this.id. Looking at the same source file, I determined there was another method:  public Item.Properties setId(ResourceKey<Item> pId) {             this.id = pId;             return this;   } 9. So now, I need to figure out how to call setId(). This required working backwards a bit. Starting from the constructor, I stubbed out the variable p which is of type Item.Properties public static final RegistryObject<Item> SHOTGUN = ITEMS.register("shotgun", () -> new ShotgunItem(p)); Rather than putting this all on one line, I split it up for readability like this: private static final Item.Properties p = new Item.Properties().useItemDescriptionPrefix().setId(rk); Here is was the missing function, setId(), which takes a type of ResourceKey<Item>. My next problem is that due to the apparent lack of documentation (I tried searching the docs on this site) I could not determine the full import path to ResourceKey. I did some random searching on the Internet and stumbled across a Github repository which gave two clues: import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; Then I created the rk variable like this: private static ResourceKey<Item> rk = ResourceKey.create(Registries.ITEM, ResourceLocation.parse("modid:shotgunmod")); And now putting it all together in order: private static ResourceKey<Item> rk = ResourceKey.create(Registries.ITEM, ResourceLocation.parse("modid:shotgunmod")); private static final Item.Properties p = new Item.Properties().useItemDescriptionPrefix().setId(rk); public static final RegistryObject<Item> SHOTGUN = ITEMS.register("shotgun", () -> new ShotgunItem(p)); This compiled and the mod no longer crashes. I still have more to do on it, but hopefully this will save someone hours. I welcome any feedback and if I missed some obvious modding resource or tutorial that has this information. If not, I might suggest we add it somewhere for people trying to write a mod that doesn't crash. Thank you !!!  
    • I will keep adding to this thread with more information in case anyone can help, or at the very least I can keep my troubleshooting organized. I decided to downgrade to 54.1.0 in the hopes that this would fix the issue but it didn't. At least now I am on a "recommended" version. The crash report did confirm my earlier post that the Exception is coming from effectiveDescriptionId(). I'll continue to see if I can find a way to set the ID manually.   Caused by: java.lang.NullPointerException: Item id not set         at java.base/java.util.Objects.requireNonNull(Objects.java:259) ~[?:?]         at TRANSFORMER/minecraft@1.21.4/net.minecraft.world.item.Item$Properties.effectiveDescriptionId(Item.java:465) ~[forge-1.21.4-54.1.0-client.jar!/:?]         at TRANSFORMER/minecraft@1.21.4/net.minecraft.world.item.Item.<init>(Item.java:111) ~[forge-1.21.4-54.1.0-client.jar!/:?]         at TRANSFORMER/shotgunmod@1.0.0/com.example.shotgunmod.ShotgunItem.<init>(ShotgunItem.java:19) ~[shotgunmod-1.0.0.jar!/:1.0.0]         at TRANSFORMER/shotgunmod@1.0.0/com.example.shotgunmod.ModItems.lambda$static$0(ModItems.java:15) ~[shotgunmod-1.0.0.jar!/:1.0.0]         at TRANSFORMER/net.minecraftforge.forge@54.1.0/net.minecraftforge.registries.DeferredRegister$EventDispatcher.lambda$handleEvent      
    • It just randomly stop working after a rebooted my dedicated server PLEASE HELP!   com.google.gson   Failed to start the minecraft server com.google.gson.JsonSyntaxException: Expected a com.google.gson.JsonObject but was com.google.gson.JsonPrimitive; at path $  
    • It was working perfectly fine last night but now I'm getting an exit code -1 with the textbox: The game crashed: rendering overlay Error: net.minecraftforge.fml.ModLoadingException: Supplementaries (supplementaries) encountered an error during the done event phase Here's the crash log: https://pastebin.com/KmesArYS Any help is apricated
    • Link to Crashlog: https://pastebin.com/bKqH9fx2 Trying to set up a custom mod pack, was going smoothly up until recently as the WorldLoader screen, (the one that appears when you select "create new world" in Singleplayer), was clicked to test that it was running fine. Most Recent Few mods added were; - Create (+ its addons) - Immersive Weathering [Forge] I've tried all I could think of since loading up the game worked fine and I've never had this issue before.  Any help is appreciated.  
  • Topics

×
×
  • Create New...

Important Information

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