Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Issues with JDA shadow in 1.16.5 - Forge: 36.1.35


Recommended Posts

Hello, I'm trying to make a Forge mod with JDA. (Java Discord)
I've been able to use the gradle shadow plugin to include the dependencies. And my mod loads properly and functions in the dev environment.
But once compiled into the shadow jar, (yes I am using the shadowJar task in gradle) it crashes in production on a Forge server.

Here is my build.gradle file

buildscript {
    repositories {
        maven { url = 'https://maven.minecraftforge.net' }
        mavenCentral()
    }
    dependencies {
        classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '4.1.+', changing: true
    }
}

plugins {
    id 'com.github.johnrengelman.shadow' version '6.1.0'
}

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

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

java.toolchain.languageVersion = JavaLanguageVersion.of(8)

println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
minecraft {
    mappings channel: 'official', version: '1.16.5'

    runs {
        client {
            workingDirectory project.file('run')
            property 'forge.logging.markers', 'REGISTRIES'
            property 'forge.logging.console.level', 'debug'

            mods {
                discordallowlist {
                    source sourceSets.main
                }
            }
        }

        server {
            workingDirectory project.file('run')
            property 'forge.logging.markers', 'REGISTRIES'
            property 'forge.logging.console.level', 'debug'

            mods {
                discordallowlist {
                    source sourceSets.main
                }
            }
        }

        data {
            workingDirectory project.file('run')
            property 'forge.logging.markers', 'REGISTRIES'
            property 'forge.logging.console.level', 'debug'
            args '--mod', 'discordallowlist', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')

            mods {
                discordallowlist {
                    source sourceSets.main
                }
            }
        }
    }
}

sourceSets.main.resources { srcDir 'src/generated/resources' }

repositories {
    mavenCentral()
    maven {
        name 'm2-dv8tion'
        url 'https://m2.dv8tion.net/releases'
    }
}

dependencies {
    minecraft 'net.minecraftforge:forge:1.16.5-36.1.35'
    shadow('mysql:mysql-connector-java:8.0.25')
    shadow('net.dv8tion:JDA:4.3.0_298') {
        exclude module: 'opus-java'
    }
}

shadowJar {
    classifier ''
    configurations = [project.configurations.shadow]
}

reobf {
    shadowJar {}
}
shadowJar.finalizedBy('reobfShadowJar')

jar {
    manifest {
        attributes([
                "Specification-Title"     : "discordallowlist",
                "Specification-Vendor"    : "DBKynd",
                "Specification-Version"   : "1", // We are version 1 of ourselves
                "Implementation-Title"    : project.name,
                "Implementation-Version"  : project.version,
                "Implementation-Vendor"   : "DBKynd",
                "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
        ])
    }
}

jar.finalizedBy('reobfJar')

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


The Forge server crashes on startup with this error: java.lang.NoClassDefFoundError: gnu/trove/set/TLongSet
Though I can clearly see it in the jar file.
I believe I am shadowing correctly because the mysql connector is added and I can see a successful mysql connection being established before the crash.

 

Thanks for any and all help.

chrome_gz47oyILwG.png

7zFM_YLeZGvFUZE.png

7zFM_8cW1DdpBnA.png

Link to post
Share on other sites

I guess it's a part of the JDA library that get's shadowed in. I didn't add it myself for anything specific.
I tried to relocate all the added libs from JDA to com.dbkynd.discordallowlist.relocated.* but was still having issues.

I didn't know trove was a part of Minecraft though. I guess that makes sense.
Maybe I should try to exclude it with the shadow plugin??

 

Link to post
Share on other sites

I think we got it!

Relocating trove got me past that error, but then it was complaining about apache
I had to boil down into apache and only relocate org.apache.commons.collections4
 

shadowJar {
    classifier ''
    configurations = [project.configurations.shadow]

    relocate('gnu.trove', 'com.dbkynd.discordallowlist.relocated.gnu.trove')
    relocate('org.apache.commons.collections4', 'com.dbkynd.discordallowlist.relocated.org.apache.commons.collections4')
}


But now it's starting with no errors.
Thanks for the help. Much appreciated!

Edited by DBKynd
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.   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.



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • I don't even have Optifine installed and the game doesn't start, it crashes right away
    • public enum ModArmorMaterial implements IArmorMaterial { ARGENTITE(Alcamod.ModID + ":argentite", 40, new int[] { 3, 6, 8, 3 }, 12, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 3.5F, 0.15F, () -> { return Ingredient.fromItems(ModItems.ARGENTITE_INGOT.get()); }), AZURITE(Alcamod.ModID + ":azurite", 45, new int[] { 3, 6, 8, 3 }, 10, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 3.7F, 0.16F, () -> { return Ingredient.fromItems(ModItems.AZURITE_INGOT.get()); }), EMATITE(Alcamod.ModID + ":ematite", 50, new int[] { 3, 6, 8, 3 }, 8, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 4.0F, 0.17F, () -> { return Ingredient.fromItems(ModItems.EMATITE_INGOT.get()); }), BARITE(Alcamod.ModID + ":barite", 60, new int[] { 3, 6, 8, 3 }, 6, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 4.2F, 0.19F, () -> { return Ingredient.fromItems(ModItems.BARITE_INGOT.get()); }), UNPOWERED_NETHER_STAR(Alcamod.ModID + ":unpowered_nether_star", 70, new int[] { 3, 6, 8, 3 }, 6, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 4.0F, 0.21F, () -> { return Ingredient.fromItems(Items.NETHER_STAR.getItem()); }), NETHER_STAR(Alcamod.ModID + ":nether_star", 80, new int[] { 3, 6, 8, 3 }, 2, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 5.0F, 0.35F, () -> { return Ingredient.fromItems(ModItems.POWERED_NETHER_STAR.get()); }), INVERTED_NETHER_STAR(Alcamod.ModID + ":inverted_nether_star", 100, new int[] { 3, 6, 8, 3 }, 2, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 6.0F, 0.60F, () -> { return Ingredient.fromItems(ModItems.INVERTED_NETHER_STAR.get()); }); private static final int[] MAX_DAMAGE_ARRAY = new int[] { 11, 16, 15, 13 }; private final String name; private final int maxDamageFactor; private final int[] damageReductionAmountArray; private final int enchantability; private final SoundEvent soundEvent; private final float toughness; private final float knockBackResistance; private final Supplier<Ingredient> repairMaterial; ModArmorMaterial(String name, int maxDamageFactor, int[] damageReductionAmountArray, int enchantability, SoundEvent soundEvent, float toughness, float knockbackResistance, Supplier<Ingredient> repairMaterial) { this.name = name; this.maxDamageFactor = maxDamageFactor; this.damageReductionAmountArray = damageReductionAmountArray; this.enchantability = enchantability; this.soundEvent = soundEvent; this.toughness = toughness; this.repairMaterial = repairMaterial; this.knockBackResistance = knockbackResistance; } @Override public int getDurability(EquipmentSlotType slotIn) { return MAX_DAMAGE_ARRAY[slotIn.getIndex()] * this.maxDamageFactor; } @Override public int getDamageReductionAmount(EquipmentSlotType slotIn) { return this.damageReductionAmountArray[slotIn.getIndex()]; } @Override public int getEnchantability() { return this.enchantability; } @Override public SoundEvent getSoundEvent() { return this.soundEvent; } @Override public Ingredient getRepairMaterial() { return this.repairMaterial.get(); } @Override public String getName() { return this.name; } @OnlyIn( Dist.CLIENT ) @Override public float getToughness() { return this.toughness; } public float getKnockbackResistance() { return this.knockBackResistance; } }  
    • Just upload it here or use pastbin.
    • And how to show the debug.log?  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.