Skip to content

Commit

Permalink
stupid workaround to make a functional forge jar, because arch loom s…
Browse files Browse the repository at this point in the history
…eems to not want to fix it completely
  • Loading branch information
fayer3 committed Jul 8, 2024
1 parent 4bed35c commit cdc7329
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 5 deletions.
61 changes: 60 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.7-SNAPSHOT" apply false
id 'io.github.juuxel.loom-quiltflower' version '1.8.0' apply false
}

Expand Down Expand Up @@ -56,6 +56,65 @@ subprojects {
}
}

tasks.register('fixForge', Zip) {
if (gradle.startParameter.taskNames.contains(name)) {
if (!file('./build/libs/' + archives_base_name +
'-' + minecraft_version +
'-' + mod_version +
'-forge_nonfunctional_without_changes.jar').exists() ||
!file('./build/libs/' + archives_base_name +
'-' + minecraft_version +
'-' + mod_version +
'-neoforge.jar').exists()) {
throw new GradleException("forge and neoforge need to be built to run this task")
}
doFirst {
println('unzipping jars')
}
copy {
// extract all forge files
from zipTree('./build/libs/' + archives_base_name +
'-' + minecraft_version +
'-' + mod_version +
'-forge_nonfunctional_without_changes.jar')
into './build/tmp/forge'
// remove any refmap
exclude "**/*-refmap.json"
// remove the refmap from the mixin jsons
eachFile { fileCopyDetails ->
if (fileCopyDetails.name.endsWith('.json')) {
filter {
line -> line.contains('"refmap": "vivecraft-common-refmap.json"') ? '"dummy": ""' : line
}
}
}
}
copy {
// override the general classes with the neoforge ones, since those are mapped correctly
from zipTree('./build/libs/' + archives_base_name +
'-' + minecraft_version +
'-' + mod_version +
'-neoforge.jar')
into './build/tmp/forge'
include '/org/vivecraft/**'
exclude '**/neoforge/**', '**/Xplat*.class', '**/Xevents*.class'
}

// zip up the combined jar again
archiveFileName = archives_base_name +
'-' + minecraft_version +
'-' + mod_version +
'-forge.jar'
destinationDirectory = file('./build/libs/')
from './build/tmp/forge'

doLast {
println('removing temp files')
delete './build/tmp/forge'
}
}
}

allprojects {
apply plugin: "architectury-plugin"
apply plugin: "maven-publish"
Expand Down
5 changes: 2 additions & 3 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,11 @@ shadowJar {
]
archiveClassifier.set("dev-shadow")
}
// TODO remove that once archloom fixes forge
remapJar.onlyIf { false }

remapJar {
input.set shadowJar.archiveFile
dependsOn shadowJar
archiveClassifier.set('forge')
archiveClassifier.set('forge_nonfunctional_without_changes')
}

jar {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit cdc7329

Please sign in to comment.