Jump to content

[Solved] Mod Only Loads in IDE Server Environment and not an 'Actual' Server Environment


Jimmeh

Recommended Posts

Hi there! This is a weird one. I have some basic debug in the constructor and pre-init method of my mod. If I use the Gradle task "runServer", I see the debug being printed (so meaning my mod is seemingly being loaded) in IntelliJ's console. If I, however, "shadowJar" and then drop that new jar file into a test server I have locally on my pc, my mod is never loaded; the debug never prints in the server console nor do I see any sort of output at all containing my mod's name. I'm very confused by this, but if I had to take a guess, I'm thinking there might be something I'm doing wrong with my build.gradle for shading. In case you happen to think that might actually be what the problem is, I'll include my build.gradle below:

 

buildscript {
    repositories {
        // These repositories are only for Gradle plugins, put any other repositories in the repository block further below
        maven { url = 'https://maven.minecraftforge.net' }
        maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
        mavenCentral()
    }
    dependencies {
        classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
        classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
    }
}

plugins {
    id 'com.github.johnrengelman.shadow' version '7.1.2' //6.0.0
}

apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'com.github.johnrengelman.shadow'

group = "com.test"
version = "${mc_version}-${mod_version}"
archivesBaseName = "${mod_name}"

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

minecraft {
    mappings channel: 'snapshot', version: "${mappings_version}"
    // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')

    runs {
        client {
            workingDirectory project.file('run')

            property 'forge.logging.markers', 'REGISTRIES'
            property 'forge.logging.console.level', 'debug'

            mods {
                tesseract {
                    source sourceSets.main
                }
            }
        }

        server {
            workingDirectory project.file('run')

            property 'forge.logging.markers', 'REGISTRIES'
            property 'forge.logging.console.level', 'debug'

            mods {
                tesseract {
                    source sourceSets.main
                }
            }
        }

        data {
            workingDirectory project.file('run')

            property 'forge.logging.markers', 'REGISTRIES'
            property 'forge.logging.console.level', 'debug'

            args '--mod', 'tesseract', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')

            mods {
                tesseract {
                    source sourceSets.main
                }
            }
        }
    }
}

mixin {
    add sourceSets.main, "Tesseract.refmap.json"

    config "Tesseract.mixins.json"
}

// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }

tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
}

repositories {
    maven { url 'https://jitpack.io' }
}

ext {
    rxjava = 'io.reactivex.rxjava3:rxjava:3.1.3'
    lombok = 'org.projectlombok:lombok:1.18.22'
    math = "org.spongepowered:math:2.0.1"
    config = 'com.electronwill.night-config:toml:3.6.5'
    caffeine = 'com.github.ben-manes.caffeine:caffeine:2.9.3' //3.0.5 when no longer on Java 8
    mongo = 'org.mongodb:mongodb-driver-sync:4.4.1'
}

dependencies {
    minecraft "net.minecraftforge:forge:${forge_version}"

//    deobfProvided "mezz.jei:jei_${mc_version}:${jei_version}:api"
//    runtime "mezz.jei:jei_${mc_version}:${jei_version}"
//    compile "org.apache.httpcomponents:fluent-hc:${httpclient_version}"

    // Examples using mod jars from ./libs
    // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")

    annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
    implementation math

    implementation rxjava

    compileOnly lombok
    annotationProcessor lombok
    testCompileOnly lombok
    testAnnotationProcessor lombok

    implementation config

    implementation caffeine

    //implementation guice
    //implementation violet

    implementation mongo
}

/*shadowJar {
    archiveName("${mod_name}-${mc_version}-${mod_version}.jar")

    // Only shadow fluent-hc
    dependencies {
        include('org.apache.httpcomponents:fluent-hc:.*')
        include(config)
        include(mongo)
        include(rxjava)
    }

    // Relocate fluent-hc to prevent conflicts with other mods that include it
    relocate 'org.apache.http.client.fluent', "${shawdow_dir}.org.apache.http.client.fluent"
    relocate rxjava, "${shawdow_dir}.${rxjava}"

    classifier '' // Replace the default JAR
}*/

/*reobf {
    shadowJar {} // Reobfuscate the shadowed JAR
}*/

shadowJar.finalizedBy(reobf)

The commented-out shadowJar parts at the bottom were my attempts at adapting Choonster's example that he provided in another forum post that was asking about obfuscating a shadowed jar. With that commendted out shadowJar task, I tried so many different 'combinations' and ideas, and frankly it never really made much of a difference in terms of my problem here. Thank you for any advice or help!

Edited by Jimmeh
Solved
Link to comment
Share on other sites

  • Jimmeh changed the title to [Solved] Mod Only Loads in IDE Server Environment and not an 'Actual' Server Environment

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.



×
×
  • Create New...

Important Information

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