Jump to content

External Dependency does not work in Normal MC


KingofGamesYami

Recommended Posts

I've found several posts in various places about this, but the syntax in every case is outdated.  I am shading JGit.  It and it's dependencies end up in my jar, but slf4j crashes on launch causing general horribleness.

 

Spoiler

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

version = "2.0"
group= "org.kingofgamesyami.ccgit" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "ccgit"

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

minecraft {
    version = "1.10.2-12.18.3.2316"
    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 allways work.
    // simply re-run your setup task after changing the mappings to update your workspace.
    mappings = "snapshot_20161111"
    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.

    //something that might help?
}

configurations {
    shade
    compile.extendsFrom shade
}

repositories {
    maven { url = "https://crzd.me/files/maven/" }
    maven { url = "https://dl.bintray.com/squiddev/maven" }
    maven { url = "https://repo.eclipse.org/content/groups/releases/" }
}

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"

    compile "dan200.computercraft:ComputerCraft:1.80pr0-build0"
    compile "org.squiddev:CCTweaks:1.10.2-1.5.0-pr0:dev"

    shade 'org.eclipse.jgit:org.eclipse.jgit:4.5.0.201609210915-r'

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

}

jar {
    configurations.shade.each { dep ->
        from(project.zipTree(dep)){
            exclude 'META-INF', 'META-INF/**'
        }
    }
}

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

 

 

Edited by KingofGamesYami
Link to comment
Share on other sites

Trying shadow out, gradlew build no longer functions.  Repeated "error: package org.eclipse.jgit.api does not exist" for all imports.  I have no idea what I'm doing wrong, as I followed the shadow introduction exactly and nothing seems to be wrong with my build.gradle...

 

Spoiler

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

version = "2.0"
group= "org.kingofgamesyami.ccgit" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "ccgit"

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

minecraft {
    version = "1.10.2-12.18.3.2316"
    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 allways work.
    // simply re-run your setup task after changing the mappings to update your workspace.
    mappings = "snapshot_20161111"
    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.

    //something that might help?
}

repositories {
    maven { url = "https://crzd.me/files/maven/" }
    maven { url = "https://dl.bintray.com/squiddev/maven" }
    maven { url = "https://repo.eclipse.org/content/groups/releases/" }
}

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"

    compile "dan200.computercraft:ComputerCraft:1.80pr0-build0"
    compile "org.squiddev:CCTweaks:1.10.2-1.5.0-pr0:dev"

    shadow 'org.eclipse.jgit:org.eclipse.jgit:4.5.0.201609210915-r'

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

}

/*jar {
    configurations.shade.each { dep ->
        from(project.zipTree(dep)){
            exclude 'META-INF', 'META-INF/**'
        }
    }
}*/

shadowJar {
    baseName = 'shadow'
    classifier = null
    version = null
    configurations = [project.configurations.compile]
}

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

build.dependsOn shadowJar

 

 

Link to comment
Share on other sites

2 minutes ago, diesieben07 said:

I did not say to not put it in dependencies. I said to not use a separate config.

Ah, so also use compile.  Tried that, it worked (well, compiled), but ended up with the same results as using "shade" : log4j crashes immediately, and nothing about my mod works.  Attempting to use any method I add results in an error referring to log4j.

Spoiler

2017-06-16 11:37:28,362 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
  <log4j:Event logger="LaunchWrapper" timestamp="1497631048388" level="INFO" thread="main">
    <log4j:Message><![CDATA[Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker]]></log4j:Message>
  </log4j:Event>
expected <
2017-06-16 11:37:31,559 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
2017-06-16 11:37:31,560 WARN Caught Exception while in Loader.getResource. This may be innocuous. java.lang.IllegalArgumentException: name
	at sun.misc.URLClassPath$Loader.findResource(URLClassPath.java:494)
	at sun.misc.URLClassPath.findResource(URLClassPath.java:176)
	at java.net.URLClassLoader$2.run(URLClassLoader.java:557)
	at java.net.URLClassLoader$2.run(URLClassLoader.java:555)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findResource(URLClassLoader.java:554)
	at java.lang.ClassLoader.getResource(ClassLoader.java:1093)
	at org.apache.logging.log4j.core.helpers.Loader.getResource(Loader.java:98)
	at org.apache.logging.log4j.core.config.ConfigurationFactory.getInputFromResource(ConfigurationFactory.java:300)
	at org.apache.logging.log4j.core.config.ConfigurationFactory.getInputFromString(ConfigurationFactory.java:280)
	at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:380)
	at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:377)
	at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:149)
	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:85)
	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:34)
	at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:387)
	at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:322)
	at net.minecraft.client.Minecraft.<clinit>(Minecraft.java:208)
	at net.minecraft.client.main.Main.main(SourceFile:39)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

2017-06-16 11:37:31,575 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
  <log4j:Event logger="net.minecraft.client.Minecraft" timestamp="1497631051742" level="INFO" thread="Client thread">
    <log4j:Message><![CDATA[Setting user: KingofGamesYami]]></log4j:Message>
  </log4j:Event>
expected <
MultiModel minecraft:builtin/missing is empty (no base model or parts were provided/resolved)

 

 

Link to comment
Share on other sites

Spoiler

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

version = "2.0"
group= "org.kingofgamesyami.ccgit" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "ccgit"

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

minecraft {
    version = "1.10.2-12.18.3.2316"
    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 allways work.
    // simply re-run your setup task after changing the mappings to update your workspace.
    mappings = "snapshot_20161111"
    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.

    //something that might help?
}

repositories {
    maven { url = "https://crzd.me/files/maven/" }
    maven { url = "https://dl.bintray.com/squiddev/maven" }
    maven { url = "https://repo.eclipse.org/content/groups/releases/" }
}

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"

    compile "dan200.computercraft:ComputerCraft:1.80pr0-build0"
    compile "org.squiddev:CCTweaks:1.10.2-1.5.0-pr0:dev"

    compile 'org.eclipse.jgit:org.eclipse.jgit:4.5.0.201609210915-r'

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

}

/*
jar {
    configurations.compile.each { dep ->
        from(project.zipTree( dep )){
            exclude 'META-INF', 'META-INF/**'
        }
    }
}
*/

shadowJar {
    dependencies {
        exclude( dependency( 'dan200.computercraft:ComputerCraft:1.80pr0-build0') )
        exclude( dependency( 'org.squiddev:CCTweaks:1.10.2-1.5.0-pr0: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'
    }
}

build.dependsOn shadowJar

 

 

Link to comment
Share on other sites

Done!  Apologies if anything is missing, I tired to exclude anything which wouldn't be needed.

 

Edit: Almost forgot, you're probably not familiar with ComputerCraft.  Once you have the game running, get an advanced computer, place it, right click to open the GUI.  Type in "lua" to enter the lua console.  Type "ccgit.init( "/test" )" to try to create a git repo.  It will show an error message.  If it doesn't, I want to know why it works for you and not me XD.

Edited by KingofGamesYami
Link to comment
Share on other sites

7 minutes ago, diesieben07 said:

The ComputerCraft dependency cannot be resolved.

Ah, the custom build server is down.  It was run by a member of the community, looks like he moved it or something. I'll PM some people about it.  You can get it here for 1.11.2 (which my mod is compatible with), though you'll need a newer version of CCTweaks for the mods folder (not to compile against). moved to here.

Edited by KingofGamesYami
Link to comment
Share on other sites

Reproduction Steps:

1. Clone repo

2. gradlew build

3. Add ccgit-2.0-all to mods folder with CCTweaks and ComputerCraft.

4. Launch game using minecraft launcher

5. Place an advanced computer

6. Open Lua console. (type lua)

7. Attempt to create repository (type ccgit.init( 'test' ))

8. Observe Java Exception Thrown: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory

9. Attempt to open repository (type ccgit.open( 'test'))

10. Observe Java Exception Thrown: java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.jgit.internal.storage.file.FileRepository

 

 

Edited by KingofGamesYami
Link was broken
Link to comment
Share on other sites

  • 1 year later...

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

    • I have done this now but have got the error:   'food(net.minecraft.world.food.FoodProperties)' in 'net.minecraft.world.item.Item.Properties' cannot be applied to                '(net.minecraftforge.registries.RegistryObject<net.minecraft.world.item.Item>)' public static final RegistryObject<Item> LEMON_JUICE = ITEMS.register( "lemon_juice", () -> new Item( new HoneyBottleItem.Properties().stacksTo(1).food( (new FoodProperties.Builder()) .nutrition(3) .saturationMod(0.25F) .effect(() -> new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 1500), 0.01f ) .build() ) )); The code above is from the ModFoods class, the one below from the ModItems class. public static final RegistryObject<Item> LEMON_JUICE = ITEMS.register("lemon_juice", () -> new Item(new Item.Properties().food(ModFoods.LEMON_JUICE)));   I shall keep going between them to try and figure out the cause. I am sorry if this is too much for you to help with, though I thank you greatly for your patience and all the effort you have put in to help me.
    • I have been following these exact tutorials for quite a while, I must agree that they are amazing and easy to follow. I have registered the item in the ModFoods class, I tried to do it in ModItems (Where all the items should be registered) but got errors, I think I may need to revert this and figure it out from there. Once again, thank you for your help! 👍 Just looking back, I have noticed in your code you added ITEMS.register, which I am guessing means that they are being registered in ModFoods, I shall go through the process of trial and error to figure this out.
    • ♈+2349027025197ஜ Are you a pastor, business man or woman, politician, civil engineer, civil servant, security officer, entrepreneur, Job seeker, poor or rich Seeking how to join a brotherhood for protection and wealth here’s is your opportunity, but you should know there’s no ritual without repercussions but with the right guidance and support from this great temple your destiny is certain to be changed for the better and equally protected depending if you’re destined for greatness Call now for enquiry +2349027025197☎+2349027025197₩™ I want to join ILLUMINATI occult without human sacrificeGREATORLDRADO BROTHERHOOD OCCULT , Is The Club of the Riches and Famous; is the world oldest and largest fraternity made up of 3 Millions Members. We are one Family under one father who is the Supreme Being. In Greatorldrado BROTHERHOOD we believe that we were born in paradise and no member should struggle in this world. Hence all our new members are given Money Rewards once they join in order to upgrade their lifestyle.; interested viewers should contact us; on. +2349027025197 ۝ஐℰ+2349027025197 ₩Greatorldrado BROTHERHOOD OCCULT IS A SACRED FRATERNITY WITH A GRAND LODGE TEMPLE SITUATED IN G.R.A PHASE 1 PORT HARCOURT NIGERIA, OUR NUMBER ONE OBLIGATION IS TO MAKE EVERY INITIATE MEMBER HERE RICH AND FAMOUS IN OTHER RISE THE POWERS OF GUARDIANS OF AGE+. +2349027025197   SEARCHING ON HOW TO JOIN THE Greatorldrado BROTHERHOOD MONEY RITUAL OCCULT IS NOT THE PROBLEM BUT MAKE SURE YOU'VE THOUGHT ABOUT IT VERY WELL BEFORE REACHING US HERE BECAUSE NOT EVERYONE HAS THE HEART TO DO WHAT IT TAKES TO BECOME ONE OF US HERE, BUT IF YOU THINK YOU'RE SERIOUS MINDED AND READY TO RUN THE SPIRITUAL RACE OF LIFE IN OTHER TO ACQUIRE ALL YOU NEED HERE ON EARTH CONTACT SPIRITUAL GRANDMASTER NOW FOR INQUIRY +2349027025197   +2349027025197 Are you a pastor, business man or woman, politician, civil engineer, civil servant, security officer, entrepreneur, Job seeker, poor or rich Seeking how to join
    • Hi, I'm trying to use datagen to create json files in my own mod. This is my ModRecipeProvider class. public class ModRecipeProvider extends RecipeProvider implements IConditionBuilder { public ModRecipeProvider(PackOutput pOutput) { super(pOutput); } @Override protected void buildRecipes(Consumer<FinishedRecipe> pWriter) { ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ModBlocks.COMPRESSED_DIAMOND_BLOCK.get()) .pattern("SSS") .pattern("SSS") .pattern("SSS") .define('S', ModItems.COMPRESSED_DIAMOND.get()) .unlockedBy(getHasName(ModItems.COMPRESSED_DIAMOND.get()), has(ModItems.COMPRESSED_DIAMOND.get())) .save(pWriter); ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ModItems.COMPRESSED_DIAMOND.get(),9) .requires(ModBlocks.COMPRESSED_DIAMOND_BLOCK.get()) .unlockedBy(getHasName(ModBlocks.COMPRESSED_DIAMOND_BLOCK.get()), has(ModBlocks.COMPRESSED_DIAMOND_BLOCK.get())) .save(pWriter); ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ModItems.COMPRESSED_DIAMOND.get()) .pattern("SSS") .pattern("SSS") .pattern("SSS") .define('S', Blocks.DIAMOND_BLOCK) .unlockedBy(getHasName(ModItems.COMPRESSED_DIAMOND.get()), has(ModItems.COMPRESSED_DIAMOND.get())) .save(pWriter); } } When I try to run the runData client, it shows an error:  Caused by: java.lang.IllegalStateException: Duplicate recipe compressed:compressed_diamond I know that it's caused by the fact that there are two recipes for the ModItems.COMPRESSED_DIAMOND. But I need both of these recipes, because I need a way to craft ModItems.COMPRESSED_DIAMOND_BLOCK and restore 9 diamond blocks from ModItems.COMPRESSED_DIAMOND. Is there a way to solve this?
  • Topics

×
×
  • Create New...

Important Information

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