Skip to content

Instantly share code, notes, and snippets.

@WOSAJ
Created October 1, 2022 06:56
Show Gist options
  • Save WOSAJ/e1dc0d98dd36d27f11ef05b1b1bc08c7 to your computer and use it in GitHub Desktop.
Save WOSAJ/e1dc0d98dd36d27f11ef05b1b1bc08c7 to your computer and use it in GitHub Desktop.
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net' }
maven { url = 'https://maven.parchmentmc.org' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
classpath group: 'org.spongepowered', name: 'mixingradle', version: '0.7.+'
classpath 'org.parchmentmc:librarian:1.+'
}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'org.parchmentmc.librarian.forgegradle'
version = '1.0_ALPHA'
group = 'com.wosaj.zenhorizon'
archivesBaseName = 'zenhorizon'
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
minecraft {
mappings channel: 'parchment', version: '2022.09.04-1.18.2'
runs {
client {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
mods {
zenhorizon {
source sourceSets.main
}
}
}
server {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"
mods {
zenhorizon {
source sourceSets.main
}
}
}
data {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
args '--mod', 'zenhorizon', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
mods {
zenhrizon {
source sourceSets.main
}
}
}
}
accessTransformer = file('src/main/resources/META-INF/zenhorizon_at.cfg')
}
sourceSets.main.resources { srcDir 'src/generated/resources' }
repositories {
maven { url = 'https://maven.blamejared.com' }
maven { url = "https://maven.theillusivec4.top/" }
maven { url = 'https://cursemaven.com' }
}
dependencies {
minecraft 'net.minecraftforge:forge:1.18.2-40.1.52'
runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.18.2-5.0.7.1")
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.18.2-5.0.7.1:api")
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.18.2-71.1")
compileOnly fg.deobf("vazkii.patchouli:Patchouli:1.18.2-71.1:api")
runtimeOnly fg.deobf("curse.maven:jei-238222:3969092")
compileOnly fg.deobf("curse.maven:jei-238222:3969092")
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
}
jar {
manifest {
attributes([
"Specification-Title": "zenhorizon",
"Specification-Vendor": "zenhorizon",
"Specification-Version": "1",
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor" :"zenhorizon",
"MixinConfigs": "zenhorizon.mixins.json"
])
}
}
jar.finalizedBy('reobfJar')
mixin {
add sourceSets.main, "ars_nouveau.refmap.json"
reobfSrgFile = file("${buildDir}/fixMcpToSrg/output.tsrg")
}
// Generate a fixed tsrg file after generating the default tsrg file
createMcpToSrg {
outputs.upToDateWhen {false}
doLast {
fixFG5TsrgForMixinAP(output.get().asFile, file("${buildDir}/fixMcpToSrg/output.tsrg"))
}
}
// Function that actually fixes the TSRG file
static def fixFG5TsrgForMixinAP(File inFile, File outFile) {
// Make directory if needed
outFile.parentFile.mkdirs()
try (Scanner scanner = new Scanner(inFile); PrintWriter out = new PrintWriter(outFile)) {
boolean firstLine = true
while (scanner.hasNextLine()) {
String next = scanner.nextLine()
// Skip first 'tsrg left right' header line
if (firstLine) {
firstLine = false
continue
}
// Skip 'static' indicators
if (next.trim() == "static") {
continue
}
// Export line otherwise
out.println(next)
}
}
}
// Copied from Botania
if (System.getProperty("idea.sync.active") == "true") {
afterEvaluate {
tasks.withType(JavaCompile).all {
it.options.annotationProcessorPath = files()
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
artifact jar
}
}
repositories {
maven {
url "file:///${project.projectDir}/mcmodsrepo"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment