Jump to content

Recommended Posts

Posted
  On 8/13/2020 at 7:04 PM, DaemonUmbra said:

Does your library use any Minecraft code?

Expand  

Yes, i am extending net.minecraft.block.OreBlock and overwrite getExperience which returns a different int value depending on the block that calls the method, because I want that my ores drop xp too.

  • Maxi07 changed the title to [1.16.1] Library Mod / Dependencies
Posted

You know reobfJar doesn't prevent you from decompiling your mod and it doesn't completely obfuscate your mod, right?

It only reobfuscates what you use that is obfuscated in Minecraft.

  • Thanks 1

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.

  Reveal hidden contents

 

Posted
  On 8/16/2020 at 6:48 PM, DaemonUmbra said:

You know reobfJar doesn't prevent you from decompiling your mod and it doesn't completely obfuscate your mod, right?

It only reobfuscates what you use that is obfuscated in Minecraft.

Expand  

Thanks! This makes sense and it also clears the question why my mod has to be mapped with fg.deobf

Posted

This is what I get:

image.thumb.png.9ffb68234306408d5c4f016f21bf382d.png

 

After I ran "gradlew --refresh-dependencies" and "gradlew genEclipseRuns eclipse" (which usually fixes this whenever I have this error with default minecraft code) a few times again and refreshed eclipse the problem stays.

Posted

iirc that is usually fixed by refreshing the Gradle in the IDE, I'm not getting that issue

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.

  Reveal hidden contents

 

Posted

  

  On 8/17/2020 at 7:06 PM, DaemonUmbra said:

iirc that is usually fixed by refreshing the Gradle in the IDE, I'm not getting that issue

Expand  

Yes this is what I experienced too. I ran gradlew --refresh-dependencies, gradlew clean, gradlew genEclipseRuns eclipse and refreshed my IDE three times more, but it did not solve my problem.

 

Then I did some research on forum topics I remember. At the last comment on each of this posts:

In particular this:

  And you also said this:

  On 8/12/2020 at 3:40 PM, DaemonUmbra said:

Well you'll still have the issue of do you want to reobf with build or do you want to reobf with publish?

Expand  

 

But the issues described at the end of the topics I quoted were not the one I have.

I dont think it is a problem the jar is reobf, because it gets mapped again via fg.deobf

Posted

Running the command doesn't refresh the project in your IDE

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.

  Reveal hidden contents

 

Posted

Yes, I know. I run gradlew --refresh-dependencies, then gradlew genEclipseRuns eclipse, and then I refresh my IDE. This is what I have done five times

Posted
  On 8/18/2020 at 11:03 AM, Maxi07 said:

Then I did some research on forum topics I remember. At the last comment on each of this posts:

In particular this:

  And you also said this:

  On 8/12/2020 at 3:40 PM, DaemonUmbra said:

Well you'll still have the issue of do you want to reobf with build or do you want to reobf with publish?

Expand  

 

But the issues described at the end of the topics I quoted were not the one I have.

I dont think it is a problem the jar is reobf, because it gets mapped again via fg.deobf

Expand  

What about this?

Posted (edited)

I may found a solution:

The error was: Source not found

So I thought: Where could eclipse find the source? Only IntelliJ has a decompiler - I am using Eclipse.

And then I realized: I have the source on my hard drive! So I clicked on "attach source" and selected the src folder of my lib mod, and it worked.

 

However I am not sure this is the right way to fix this problem.

Edited by Maxi07
Posted

Can you give me screenshots of how you're refreshing the project in your IDE?

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.

  Reveal hidden contents

 

Posted

You don't have the project registered as a Gradle project.

 

Go to Properties -> Project Natures -> Add  -> Gradle Project Nature -> Apply and Close

Then Right Click -> Gradle -> Refresh Gradle Project

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.

  Reveal hidden contents

 

Posted

Thanks, I will do as so as possible. I thougt I have to select general project because I already run the gradlew eclipse task.

Howerver, I have already clicked „attach source“ and selected the src folder of my other project. What should I do now?

Posted

I fused my source code to a new blank mdk (to make sure all mdk file are up to date) and run .\gradlew genEclipseRuns in PowerShell. And then I imported the folder as "existing gradle project" in eclipse. (I did this for both projects, and I also build a new jar of my lib mod with gradlew build)

 

It does still not work. Here are the build.gradle files of both mods:

The lib mod:

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.16.1-1.1'
group = 'maxi.simpledev' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'simpledev'

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: '20200723-1.16.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 {
                simpledev {
                    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 {
                simpledev {
                    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', 'simpledev', '--all', '--output', file('src/generated/resources/')

            mods {
                simpledev {
                    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.108'

    // 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": "simpledev",
            "Specification-Vendor": "simpledev",
            "Specification-Version": "1", // We are version 1 of ourselves
            "Implementation-Title": project.name,
            "Implementation-Version": "${version}",
            "Implementation-Vendor" :"simpledev",
            "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"
        }
    }
}

 

The mod which need the lib mod:

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.16.1-1.0'
group = 'maxi.extended_resources' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'extended_resources'

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: '20200723-1.16.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 {
                extended_resources {
                    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 {
                extended_resources {
                    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', 'extended_resources', '--all', '--output', file('src/generated/resources/')

            mods {
                extended_resources {
                    source sourceSets.main
                }
            }
        }
    }
}

repositories {
	flatDir { 
		dir 'libs' 
	}
}

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.108'

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

    compile fg.deobf('maxi.simpledev:simpledev:1.16.1-1.1')

    // 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": "extended_resources",
            "Specification-Vendor": "extended_resources",
            "Specification-Version": "1", // We are version 1 of ourselves
            "Implementation-Title": project.name,
            "Implementation-Version": "${version}",
            "Implementation-Vendor" :"extended_resources",
            "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"
        }
    }
}

 

Also my problem is bit different now:

"Reffrecend Libaries" is now called "Project and External Dependencies", I think it is because it's now a gradle project instead of a normal java project

image.png.4015ed25f6298191948060d0f7f5b65e.png

Posted

I've recently learned that this was broken some time ago and I apparently just never noticed because intellij has its own decompiler to cover missing classes

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.

  Reveal hidden contents

 

Posted

So, do you have any idea what I should do now? I think I have to get the source inside the jar (or something like this). Or is this still a forge bug?

Posted (edited)

I think, now I have finally got the solution!

 

After I saw the topic "[1.14.4] How add JEI to own mod?", I focused on trying to find out how other mods do this.

The problem is clear: eclipse has found no source code. And I think this is not a bug, there is just no source code.

As far as I know, the faltDir behaves like a regular maven repository. At any mod I have looked (forge too), there is either a [jar name]-sources.jar (it is like the regular jar, but every .class file is the .java file) or the jar not only contains the .class file, but also the .java files. For example the mezz.jei repo at https://dvs1.progwml6.com/files/maven/

 

Lines from my build.gradle:

// 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: '20200723-1.16.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.

The is the comment "an Srg named sources jar is made by default". The fact that it is srg named should not matter, because it gets mapped. But the fact that a [jar name]-sources.jar is created is interesting.

 

If I were right right, I would just have to find this [jar name]-sources.jar.

And is where I need your help. Where is the sources.jar? Or do I have to add makeObfSourceJar = true (maybe the default is not working)

Edited by Maxi07
Posted

I'm going to back up here a little bit, to ensure that I'm understanding the goal correctly.

 

You want to add your own library as a dependency of your mod.  But you don't necessarily want to be able to edit both the library and the mod at the same time.  Building the library, and adding it in via gradle so it is available to the mod is sufficient?

 

Posted

OK.  In the build.gradle for the library, at the bottom, there is a section for 'publishing'.  Within that section is:

 

repositories {
    maven {
        url "file:///${project.projectDir}/mcmodsrepo"
    }
}

 

Make note of the location.  Or change it to something you like better.  Or change it AND make note of it.

 

I have to do a bit of hand-waving here, as I understand you are using Eclipse, and I don't know the Eclipse way of doing things.  In IntelliJ there is a Gradle panel with a publishing section, command named 'publish'.  Publish the library using this command.  That will put the library into what amounts to a local Maven repository.

 

In your mod, ADD that location to the mod's repositories section, keeping in mind you won't be able to use ${project.projectDir}.  (This is why you might want to change it to a known convenient location.)  THEN, under dependencies,

compile fg.deobf("[path to library jar]")

and that's it.  The path matches how it appears under the mcmodsrepo folder. 

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.