Skip to content

Commit

Permalink
Add waila support (#42)
Browse files Browse the repository at this point in the history
* Remove pneumaticCraft API

* Add WAILA support.
* Mix of backport from 1.12 + I'm Looking At Blood mod (MIT)
  • Loading branch information
mitchej123 authored Feb 13, 2023
1 parent 33f1f1b commit b0c07eb
Show file tree
Hide file tree
Showing 57 changed files with 735 additions and 2,361 deletions.
185 changes: 179 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//version: 1675110695
//version: 1676031737
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
Expand All @@ -9,11 +9,15 @@
import com.diffplug.blowdryer.Blowdryer
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.gtnewhorizons.retrofuturagradle.ObfuscationAttribute
import com.gtnewhorizons.retrofuturagradle.mcp.ReobfuscatedJar
import com.gtnewhorizons.retrofuturagradle.minecraft.RunMinecraftTask
import com.matthewprenger.cursegradle.CurseArtifact
import com.matthewprenger.cursegradle.CurseRelation
import com.modrinth.minotaur.dependencies.ModDependency
import com.modrinth.minotaur.dependencies.VersionDependency
import cpw.mods.fml.relauncher.Side
import org.gradle.api.tasks.options.Option;
import org.gradle.internal.logging.text.StyledTextOutput.Style
import org.gradle.internal.logging.text.StyledTextOutputFactory
import org.jetbrains.gradle.ext.*
Expand All @@ -23,6 +27,7 @@ import java.nio.file.Paths
import java.util.concurrent.TimeUnit
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream
import javax.inject.Inject

buildscript {
repositories {
Expand Down Expand Up @@ -66,7 +71,7 @@ plugins {
id 'com.diffplug.spotless' version '6.7.2' apply false
id 'com.modrinth.minotaur' version '2.+' apply false
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
id 'com.gtnewhorizons.retrofuturagradle' version '1.1.2'
id 'com.gtnewhorizons.retrofuturagradle' version '1.1.6'
}
boolean settingsupdated = verifySettingsGradle()
settingsupdated = verifyGitAttributes() || settingsupdated
Expand Down Expand Up @@ -186,11 +191,21 @@ configurations {
}

if (enableModernJavaSyntax.toBoolean()) {
repositories {
mavenCentral {
mavenContent {
includeGroup("me.eigenraven.java8unsupported")
}
}
}

dependencies {
annotationProcessor 'com.github.bsideup.jabel:jabel-javac-plugin:1.0.0'
compileOnly('com.github.bsideup.jabel:jabel-javac-plugin:1.0.0') {
transitive = false // We only care about the 1 annotation class
}
// Allow using jdk.unsupported classes like sun.misc.Unsafe in the compiled code, working around JDK-8206937.
patchedMinecraft('me.eigenraven.java8unsupported:java-8-unsupported-shim:1.0.0')
}

tasks.withType(JavaCompile).configureEach {
Expand Down Expand Up @@ -401,6 +416,16 @@ configurations.configureEach {
}
}
}
def obfuscationAttr = it.attributes.getAttribute(ObfuscationAttribute.OBFUSCATION_ATTRIBUTE)
if (obfuscationAttr != null && obfuscationAttr.name == ObfuscationAttribute.SRG) {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
// Remap CoFH core cursemaven dev jar to the obfuscated version for runObfClient/Server
if (details.requested.group == 'curse.maven' && details.requested.name.endsWith('-69162') && details.requested.version == '2388751') {
details.useVersion '2388750'
details.because 'Pick obfuscated jar'
}
}
}
}

// Ensure tests have access to minecraft classes
Expand Down Expand Up @@ -520,20 +545,20 @@ dependencies {
annotationProcessor('org.ow2.asm:asm-debug-all:5.0.3')
annotationProcessor('com.google.guava:guava:24.1.1-jre')
annotationProcessor('com.google.code.gson:gson:2.8.6')
annotationProcessor('com.gtnewhorizon:gtnhmixins:2.1.10:processor')
annotationProcessor('com.gtnewhorizon:gtnhmixins:2.1.12:processor')
if (usesMixinDebug.toBoolean()) {
runtimeOnlyNonPublishable('org.jetbrains:intellij-fernflower:1.2.1.16')
}
}
if (usesMixins.toBoolean() || forceEnableMixins.toBoolean()) {
implementation('com.gtnewhorizon:gtnhmixins:2.1.10')
implementation('com.gtnewhorizon:gtnhmixins:2.1.12')
}
}

pluginManager.withPlugin('org.jetbrains.kotlin.kapt') {
if (usesMixins.toBoolean()) {
dependencies {
kapt('com.gtnewhorizon:gtnhmixins:2.1.10:processor')
kapt('com.gtnewhorizon:gtnhmixins:2.1.12:processor')
}
}
}
Expand Down Expand Up @@ -633,9 +658,142 @@ tasks.named("processResources", ProcessResources).configure {

if (usesMixins.toBoolean()) {
from refMap
dependsOn("compileJava", "compileScala")
}
}

ext.java17Toolchain = (JavaToolchainSpec spec) -> {
spec.languageVersion.set(JavaLanguageVersion.of(17))
spec.vendor.set(JvmVendorSpec.matching("jetbrains"))
}

ext.java17DependenciesCfg = configurations.create("java17Dependencies")
ext.java17PatchDependenciesCfg = configurations.create("java17PatchDependencies")

dependencies {
def lwjgl3ifyVersion = '1.1.21'
def asmVersion = '9.4'
if (modId != 'lwjgl3ify') {
java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}")
}
if (modId != 'hodgepodge') {
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.0.31')
}

java17PatchDependencies('net.minecraft:launchwrapper:1.15') {transitive = false}
java17PatchDependencies("org.ow2.asm:asm:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-commons:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-tree:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-analysis:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-util:${asmVersion}")
java17PatchDependencies('org.ow2.asm:asm-deprecated:7.1')
java17PatchDependencies("org.apache.commons:commons-lang3:3.12.0")
java17PatchDependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}:forgePatches")
}

ext.java17JvmArgs = [
// Java 9+ support
"--illegal-access=warn",
"-Dfile.encoding=UTF-8",
"-Djava.security.manager=allow",
"--add-opens", "java.base/jdk.internal.loader=ALL-UNNAMED",
"--add-opens", "java.base/java.net=ALL-UNNAMED",
"--add-opens", "java.base/java.nio=ALL-UNNAMED",
"--add-opens", "java.base/java.io=ALL-UNNAMED",
"--add-opens", "java.base/java.lang=ALL-UNNAMED",
"--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED",
"--add-opens", "java.base/java.text=ALL-UNNAMED",
"--add-opens", "java.base/java.util=ALL-UNNAMED",
"--add-opens", "java.base/jdk.internal.reflect=ALL-UNNAMED",
"--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED",
"--add-opens", "java.desktop/sun.awt.image=ALL-UNNAMED",
"--add-modules", "jdk.dynalink",
"--add-opens", "jdk.dynalink/jdk.dynalink.beans=ALL-UNNAMED",
"--add-modules", "java.sql.rowset",
"--add-opens", "java.sql.rowset/javax.sql.rowset.serial=ALL-UNNAMED"
]

ext.hotswapJvmArgs = [
// DCEVM advanced hot reload
"-XX:+AllowEnhancedClassRedefinition",
"-XX:HotswapAgent=fatjar"
]

ext.setupHotswapAgentTask = tasks.register("setupHotswapAgent") {
group = "GTNH Buildscript"
description = "Installs a recent version of HotSwapAgent into the Java 17 JetBrains runtime directory"
def hsaUrl = 'https://github.com/HotswapProjects/HotswapAgent/releases/download/1.4.2-SNAPSHOT/hotswap-agent-1.4.2-SNAPSHOT.jar'
def targetFolderProvider = javaToolchains.launcherFor(java17Toolchain).map {it.metadata.installationPath.dir("lib/hotswap")}
def targetFilename = "hotswap-agent.jar"
onlyIf {
!targetFolderProvider.get().file(targetFilename).asFile.exists()
}
doLast {
def targetFolder = targetFolderProvider.get()
targetFolder.asFile.mkdirs()
download.run {
src hsaUrl
dest targetFolder.file(targetFilename).asFile
overwrite false
tempAndMove true
}
}
}

public abstract class RunHotswappableMinecraftTask extends RunMinecraftTask {
// IntelliJ doesn't seem to allow commandline arguments so we also support an env variable
private boolean enableHotswap = Boolean.valueOf(System.getenv("HOTSWAP"));

@Input
public boolean getEnableHotswap() { return enableHotswap }
@Option(option = "hotswap", description = "Enables HotSwapAgent for enhanced class reloading under a debugger")
public boolean setEnableHotswap(boolean enable) { enableHotswap = enable }

@Inject
public RunHotswappableMinecraftTask(Side side, String superTask) {
super(side)

this.lwjglVersion = 3
this.javaLauncher = project.javaToolchains.launcherFor(project.java17Toolchain)
this.extraJvmArgs.addAll(project.java17JvmArgs)
this.extraJvmArgs.addAll(project.provider(() -> enableHotswap ? project.hotswapJvmArgs : []))

this.classpath(project.java17PatchDependenciesCfg)
if (side == Side.CLIENT) {
this.classpath(project.minecraftTasks.lwjgl3Configuration)
}
// Use a raw provider instead of map to not create a dependency on the task
this.classpath(project.provider(() -> project.tasks.named(superTask, RunMinecraftTask).get().classpath))
this.classpath.filter { file ->
!file.path.contains("2.9.4-nightly-20150209") // Remove lwjgl2
}
this.classpath(project.java17DependenciesCfg)

if (!(project.usesMixins.toBoolean() || project.forceEnableMixins.toBoolean())) {
this.extraArgs.addAll("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker")
}
}
}

def runClient17Task = tasks.register("runClient17", RunHotswappableMinecraftTask, Side.CLIENT, "runClient")
runClient17Task.configure {
setup(project)
group = "Modded Minecraft"
description = "Runs the modded client using Java 17, lwjgl3ify and Hodgepodge"
dependsOn(setupHotswapAgentTask, mcpTasks.launcherSources.classesTaskName, minecraftTasks.taskDownloadVanillaAssets, mcpTasks.taskPackagePatchedMc, 'jar')
mainClass = "GradleStart"
}

def runServer17Task = tasks.register("runServer17", RunHotswappableMinecraftTask, Side.SERVER, "runServer")
runServer17Task.configure {
setup(project)
group = "Modded Minecraft"
description = "Runs the modded server using Java 17, lwjgl3ify and Hodgepodge"
dependsOn(setupHotswapAgentTask, mcpTasks.launcherSources.classesTaskName, minecraftTasks.taskDownloadVanillaAssets, mcpTasks.taskPackagePatchedMc, 'jar')
mainClass = "GradleStartServer"
extraArgs.add("nogui")
}

def getManifestAttributes() {
def manifestAttributes = [:]
if (!containsMixinsAndOrCoreModOnly.toBoolean() && (usesMixins.toBoolean() || coreModClass)) {
Expand Down Expand Up @@ -705,7 +863,7 @@ if (usesShadowedDependencies.toBoolean()) {
javaComponent.withVariantsFromConfiguration(configurations.shadowRuntimeElements) {
skip()
}
for (runTask in ["runClient", "runServer"]) {
for (runTask in ["runClient", "runServer", "runClient17", "runServer17"]) {
tasks.named(runTask).configure {
dependsOn("shadowJar")
}
Expand Down Expand Up @@ -743,6 +901,7 @@ idea {
module {
downloadJavadoc = true
downloadSources = true
inheritOutputDirs = true
}
project {
settings {
Expand All @@ -753,6 +912,20 @@ idea {
"2. Run Server"(Gradle) {
taskNames = ["runServer"]
}
"1a. Run Client (Java 17)"(Gradle) {
taskNames = ["runClient17"]
}
"2a. Run Server (Java 17)"(Gradle) {
taskNames = ["runServer17"]
}
"1b. Run Client (Java 17, Hotswap)"(Gradle) {
taskNames = ["runClient17"]
envs = ["HOTSWAP": "true"]
}
"2b. Run Server (Java 17, Hotswap)"(Gradle) {
taskNames = ["runServer17"]
envs = ["HOTSWAP": "true"]
}
"3. Run Obfuscated Client"(Gradle) {
taskNames = ["runObfClient"]
}
Expand Down
69 changes: 36 additions & 33 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
// Add your dependencies here
/*
* Add your dependencies here. Supported configurations:
* - api("group:name:version:classifier"): if you use the types from this dependency in the public API of this mod
* Available at runtime and compiletime for mods depending on this mod
* - implementation("g:n:v:c"): if you need this for internal implementation details of the mod, but none of it is visible via the public API
* Available at runtime but not compiletime for mods depending on this mod
* - compileOnly("g:n:v:c"): if the mod you're building doesn't need this dependency during runtime at all, e.g. for optional mods
* Not available at all for mods depending on this mod, only visible at compiletime for this mod
* - runtimeOnly("g:n:v:c"): if you don't need this at compile time, but want it to be present at runtime
* Available at runtime for mods depending on this mod
* - annotationProcessor("g:n:v:c"): mostly for java compiler plugins, if you know you need this, use it, otherwise don't worry
* - testCONFIG("g:n:v:c") - replace CONFIG by one of the above (except api), same as above but for the test sources instead of main
*
* - shadowImplementation("g:n:v:c"): effectively the same as API, but the dependency is included in your jar under a renamed package name
* Requires you to enable usesShadowedDependencies in gradle.properties
*
* - compile("g:n:v:c"): deprecated, replace with "api" (works like the old "compile") or "implementation" (can be more efficient)
*
* You can exclude transitive dependencies (dependencies of the chosen dependency) by appending { transitive = false } if needed,
* but use this sparingly as it can break using your mod as another mod's dependency if you're not careful.
*
* For more details, see https://docs.gradle.org/7.6/userguide/java_library_plugin.html#sec:java_library_configurations_graph
*/

dependencies {

compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.41.242:dev") {
transitive = false
}
api("com.github.GTNewHorizons:waila:1.5.22:dev")
api("com.github.GTNewHorizons:CodeChickenLib:1.1.5.7:dev")
api("com.github.GTNewHorizons:NotEnoughItems:2.3.21-GTNH:dev")

compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.41.242:dev") {transitive = false }

compileOnly("com.github.GTNewHorizons:Botania:1.9.14-GTNH:api") {
transitive = false
}
compileOnly("com.github.GTNewHorizons:ForestryMC:4.5.6:api") {
transitive = false
}
compileOnly("com.github.GTNewHorizons:ForgeMultipart:1.3.1:dev") {
transitive = false
}
compile("com.github.GTNewHorizons:CodeChickenLib:1.1.5.7:dev")
compileOnly("com.github.GTNewHorizons:Botania:1.9.14-GTNH:api") {transitive = false }
compileOnly("com.github.GTNewHorizons:ForestryMC:4.5.6:api") {transitive = false }
compileOnly("com.github.GTNewHorizons:ForgeMultipart:1.3.1:dev") {transitive = false }

compileOnly("com.github.GTNewHorizons:NotEnoughItems:2.3.21-GTNH:dev") {
transitive = false
}
compileOnly("com.github.GTNewHorizons:Chisel:2.10.16-GTNH:api") {
transitive = false
}
compileOnly("com.github.GTNewHorizons:Chisel:2.10.16-GTNH:api") {transitive = false }

compileOnly("com.github.GTNewHorizons:ZenScript:1.0.0-GTNH") {
transitive = false
}
compileOnly("com.github.GTNewHorizons:CraftTweaker:3.2.9:dev") {
transitive = false
}
compileOnly("com.github.GTNewHorizons:ZenScript:1.0.0-GTNH") {transitive = false }
compileOnly("com.github.GTNewHorizons:CraftTweaker:3.2.9:dev") {transitive = false }

compileOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev") {
transitive = false
}
compileOnly("curse.maven:guide-api-228832:2287185") {
transitive = false
}
compileOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev") {transitive = false }
compileOnly("curse.maven:guide-api-228832:2287185") {transitive = false }
}
Loading

0 comments on commit b0c07eb

Please sign in to comment.