Skip to content

Commit

Permalink
Little hack to make the game runnable with common-only NeoForge
Browse files Browse the repository at this point in the history
  • Loading branch information
Technici4n committed Jan 20, 2025
1 parent b315b9c commit 2343326
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
20 changes: 14 additions & 6 deletions projects/neoforge/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import net.neoforged.jarcompatibilitychecker.gradle.JCCPlugin
import net.neoforged.jarcompatibilitychecker.gradle.CompatibilityTask
import net.neoforged.jarcompatibilitychecker.gradle.ProvideNeoForgeJarTask
import net.neoforged.moddevgradle.dsl.ModModel
import net.neoforged.neodev.GenerateFinalizeSpawnTargets

plugins {
Expand Down Expand Up @@ -62,14 +63,17 @@ checkJarCompatibility {
baseJar = createCompatJar.flatMap { it.output }
}

// We don't want to include client in non-client runs,
// however the name of the ModModel must be minecraft for FML to work.
// Since we need both mods to be named minecraft we create them manually.
ext.commonMod = objects.newInstance(ModModel, "minecraft")
commonMod.sourceSet sourceSets.main
ext.joinedMod = objects.newInstance(ModModel, "minecraft")
joinedMod.sourceSet sourceSets.main
joinedMod.sourceSet sourceSets.client

neoDev {
mods {
// TODO: problem!!! we don't want to include client in non-client runs,
// TODO: but the name of the "mod" must be minecraft for FML to work :(
minecraft {
sourceSet sourceSets.main
sourceSet sourceSets.client
}
"neoforge-coremods" {
sourceSet project(":neoforge-coremods").sourceSets.main
}
Expand Down Expand Up @@ -157,18 +161,22 @@ neoDev {
client {
client()
sourceSet = sourceSets.client
loadedMods = [joinedMod, neoDev.mods."neoforge-coremods"]
}
server {
server()
loadedMods = [commonMod, neoDev.mods."neoforge-coremods"]
}
gameTestServer {
type = "gameTestServer"
loadedMods = [commonMod, neoDev.mods."neoforge-coremods"]
}
data {
// We perform client and server datagen in a single clientData run to avoid
// having to juggle two generated resources folders and two runs for no additional benefit.
clientData()
sourceSet = sourceSets.main
loadedMods = [joinedMod, neoDev.mods."neoforge-coremods"]
programArguments.addAll '--mod', 'neoforge', '--flat', '--all', '--validate',
'--existing', rootProject.file("src/main/resources").absolutePath,
'--output', rootProject.file("src/generated/resources").absolutePath
Expand Down
4 changes: 2 additions & 2 deletions tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ neoDev {

runs.configureEach {
// Add NeoForge and Minecraft (both under the "minecraft" mod), and exclude junit.
loadedMods = [neoforgeProject.neoDev.mods.minecraft, mods.neotests, mods.testframework, mods.coremods]
loadedMods = [neoforgeProject.joinedMod, mods.neotests, mods.testframework, mods.coremods]

gameDirectory.set project.file("runs/${it.name}") as File
}
}

neoDevTest {
loadedMods = [ project(":neoforge").neoDev.mods.minecraft, neoDev.mods.testframework, neoDev.mods.coremods, neoDev.mods.junit ]
loadedMods = [ neoforgeProject.joinedMod, neoDev.mods.testframework, neoDev.mods.coremods, neoDev.mods.junit ]
}

license {
Expand Down

0 comments on commit 2343326

Please sign in to comment.