diff options
57 files changed, 885 insertions, 400 deletions
diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 5342d39..0000000 --- a/build.gradle +++ /dev/null @@ -1,182 +0,0 @@ -//file:noinspection UnnecessaryQualifiedReference -//file:noinspection GroovyAssignabilityCheck -//file:noinspection GradlePackageUpdate -import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar - -plugins { - id "dev.architectury.architectury-pack200" version "0.1.3" - id "com.github.johnrengelman.shadow" version "7.1.2" - id "cc.woverflow.loom" version "0.10.6" - id "net.kyori.blossom" version "1.3.0" - id "java" -} - -version = mod_version -group = "cc.polyfrost" -archivesBaseName = mod_name - -blossom { - String className = "src/main/java/cc/polyfrost/oneconfig/OneConfig.java" - replaceToken("@VER@", project.version, className) - replaceToken("@NAME@", mod_name, className) - replaceToken("@ID@", mod_id, className) -} - -sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8 -compileJava.options.encoding = 'UTF-8' - -loom { - launchConfigs { - client { - property("fml.coreMods.load", "cc.polyfrost.oneconfig.lwjgl.plugin.LoadingPlugin") - property("mixin.debug.export", "true") - } - } - runConfigs { - client { - ideConfigGenerated = true - } - } - forge { - pack200Provider = new dev.architectury.pack200.java.Pack200Adapter() - mixinConfig("mixins.oneconfig.json") - mixin.defaultRefmapName.set("mixins.oneconfig.refmap.json") - } -} - -configurations { - include - implementation.extendsFrom(include) - lwjgl - lwjglNative { - transitive = false - } -} - -sourceSets.main.runtimeClasspath += configurations.lwjglNative - -repositories { - maven { url 'https://repo.woverflow.cc/' } -} - -task lwjglJar(type: ShadowJar) { - group = "shadow" - archiveClassifier.set("lwjgl") - configurations = [project.configurations.lwjgl] - exclude "META-INF/versions/**" - exclude "**/module-info.class" - exclude "**/package-info.class" - relocate("org.lwjgl", "org.lwjgl3") { - include "org.lwjgl.PointerBuffer" - include "org.lwjgl.BufferUtils" - } -} - -dependencies { - minecraft("com.mojang:minecraft:1.8.9") - mappings("de.oceanlabs.mcp:mcp_stable:22-1.8.9") - forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9") - - include("gg.essential:universalcraft-1.8.9-forge:209") { - transitive = false - } - - // for other mods and universalcraft - include("org.jetbrains.kotlin:kotlin-stdlib:1.6.21") - include("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21") - include("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21") - include("org.jetbrains.kotlin:kotlin-reflect:1.6.21") - include("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1") - include("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.1") - include("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.6.1") - include("org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.3.2") - include("org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.3.2") - include("org.jetbrains.kotlinx:kotlinx-serialization-cbor-jvm:1.3.2") - - include("org.spongepowered:mixin:0.7.11-SNAPSHOT") { - transitive = false - } - - lwjgl "org.lwjgl:lwjgl:3.3.1" - lwjgl "org.lwjgl:lwjgl-stb:3.3.1" - lwjgl "org.lwjgl:lwjgl-tinyfd:3.3.1" - lwjgl "org.lwjgl:lwjgl-nanovg:3.3.1" - lwjglNative "org.lwjgl:lwjgl:3.3.1:natives-windows" - lwjglNative "org.lwjgl:lwjgl-stb:3.3.1:natives-windows" - lwjglNative "org.lwjgl:lwjgl-tinyfd:3.3.1:natives-windows" - lwjglNative "org.lwjgl:lwjgl-nanovg:3.3.1:natives-windows" - lwjglNative "org.lwjgl:lwjgl:3.3.1:natives-linux" - lwjglNative "org.lwjgl:lwjgl-stb:3.3.1:natives-linux" - lwjglNative "org.lwjgl:lwjgl-tinyfd:3.3.1:natives-linux" - lwjglNative "org.lwjgl:lwjgl-nanovg:3.3.1:natives-linux" - lwjglNative "org.lwjgl:lwjgl:3.3.1:natives-macos" - lwjglNative "org.lwjgl:lwjgl-stb:3.3.1:natives-macos" - lwjglNative "org.lwjgl:lwjgl-tinyfd:3.3.1:natives-macos" - lwjglNative "org.lwjgl:lwjgl-nanovg:3.3.1:natives-macos" - include lwjglJar.outputs.files -} - -processResources { - // this will ensure that this task is redone when the versions change. - inputs.property "version", version - inputs.property "name", mod_name - inputs.property "id", mod_id - - filesMatching("mcmod.info") { - expand( - "id": mod_id, - "name": mod_name, - "version": version - ) - } - - rename '(.+_at.cfg)', 'META-INF/$1' -} - -sourceSets { - main { - output.resourcesDir = java.outputDir - } -} - -shadowJar { - archiveClassifier.set('dev') - configurations = [project.configurations.include, project.configurations.lwjglNative] - duplicatesStrategy DuplicatesStrategy.EXCLUDE - - relocate("gg.essential.universalcraft", "cc.polyfrost.oneconfig.libs.universalcraft") - exclude( - "**/LICENSE.md", - "**/LICENSE.txt", - "**/LICENSE", - "**/NOTICE", - "**/NOTICE.txt", - "pack.mcmeta", - "dummyThing", - "**/module-info.class", - "META-INF/proguard/**", - "META-INF/maven/**", - "META-INF/versions/**", - "META-INF/com.android.tools/**", - "fabric.mod.json" - ) -} - -remapJar { - archiveClassifier.set('') - from(shadowJar.archiveFile) -} - -jar { - manifest.attributes( - 'ModSide': 'CLIENT', - 'ForceLoadAsMod': true, - "TweakOrder": "0", - "MixinConfigs": "mixins.oneconfig.json", - "FMLCorePlugin": "cc.polyfrost.oneconfig.lwjgl.plugin.LoadingPlugin", - 'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker', - "FMLCorePluginContainsFMLMod": "lol" - ) - enabled = false -} -jar.dependsOn(shadowJar) diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..a6a59db --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,257 @@ +import gg.essential.gradle.util.noServerRunConfigs +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import gg.essential.gradle.util.RelocationTransform.Companion.registerRelocationAttribute +import gg.essential.gradle.util.prebundle + +plugins { + id("gg.essential.multi-version") + id("gg.essential.defaults.repo") + id("gg.essential.defaults.java") + id("gg.essential.defaults.loom") + id("com.github.johnrengelman.shadow") + id("net.kyori.blossom") version "1.3.0" + id("io.github.juuxel.loom-quiltflower-mini") + java +} + +java { + withJavadocJar() + withSourcesJar() +} + +val mod_name: String by project +val mod_version: String by project +val mod_id: String by project + +preprocess { + vars.put("MODERN", if (project.platform.mcMinor >= 16) 1 else 0) +} + +blossom { + replaceToken("@VER@", mod_version) + replaceToken("@NAME@", mod_name) + replaceToken("@ID@", mod_id) +} + +version = mod_version +group = "cc.polyfrost" +base { + archivesName.set(mod_name) +} + +loom.noServerRunConfigs() +loom { + if (project.platform.isLegacyForge) { + launchConfigs.named("client") { + property("fml.coreMods.load", "cc.polyfrost.oneconfig.plugin.LoadingPlugin") + property("mixin.debug.export", "true") + } + } + if (project.platform.isForge) { + forge { + mixinConfig("mixins.${mod_id}.json") + } + } + mixin.defaultRefmapName.set("mixins.${mod_id}.refmap.json") +} + +repositories { + maven("https://repo.woverflow.cc/") +} + +val relocated = registerRelocationAttribute("relocate") { + relocate("gg.essential", "cc.polyfrost.oneconfig.libs") +} + +val shadeRelocated: Configuration by configurations.creating { + attributes { attribute(relocated, true) } +} + +val shade: Configuration by configurations.creating { + configurations.implementation.get().extendsFrom(this) +} + +val lwjgl: Configuration by configurations.creating + +val lwjglNative: Configuration by configurations.creating { + isTransitive = false +} + +val dummyImpl: Configuration by configurations.creating { + configurations.implementation.get().extendsFrom(this) +} + +sourceSets { + val dummy by creating { + compileClasspath += dummyImpl + } + main { + compileClasspath += dummy.output + runtimeClasspath += lwjglNative + output.setResourcesDir(java.classesDirectory) + } +} + +val lwjglJar by tasks.registering(ShadowJar::class) { + group = "shadow" + archiveClassifier.set("lwjgl") + configurations = listOf(lwjgl) + exclude ("META-INF/versions/**") + exclude ("**/module-info.class") + exclude ("**/package-info.class") + relocate("org.lwjgl", "org.lwjgl3") { + include ("org.lwjgl.PointerBuffer") + include ("org.lwjgl.BufferUtils") + } +} + +dependencies { + dummyImpl("gg.essential:vigilance-1.8.9-forge:222") { + isTransitive = false + } + + shadeRelocated("gg.essential:universalcraft-1.8.9-forge:209") { + isTransitive = false + } + + // for other mods and universalcraft + shade("org.jetbrains.kotlin:kotlin-stdlib:1.6.21") + shade("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21") + shade("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21") + shade("org.jetbrains.kotlin:kotlin-reflect:1.6.21") + shade("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1") + shade("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.1") + shade("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.6.1") + shade("org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.3.3") + shade("org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.3.3") + shade("org.jetbrains.kotlinx:kotlinx-serialization-cbor-jvm:1.3.3") + + shade("org.spongepowered:mixin:0.7.11-SNAPSHOT") { + isTransitive = false + } + + lwjgl ("org.lwjgl:lwjgl:3.3.1") + lwjgl ("org.lwjgl:lwjgl-stb:3.3.1") + lwjgl ("org.lwjgl:lwjgl-tinyfd:3.3.1") + lwjgl ("org.lwjgl:lwjgl-nanovg:3.3.1") + lwjglNative ("org.lwjgl:lwjgl:3.3.1:natives-windows") + lwjglNative ("org.lwjgl:lwjgl-stb:3.3.1:natives-windows") + lwjglNative ("org.lwjgl:lwjgl-tinyfd:3.3.1:natives-windows") + lwjglNative ("org.lwjgl:lwjgl-nanovg:3.3.1:natives-windows") + lwjglNative ("org.lwjgl:lwjgl:3.3.1:natives-linux") + lwjglNative ("org.lwjgl:lwjgl-stb:3.3.1:natives-linux") + lwjglNative ("org.lwjgl:lwjgl-tinyfd:3.3.1:natives-linux") + lwjglNative ("org.lwjgl:lwjgl-nanovg:3.3.1:natives-linux") + lwjglNative ("org.lwjgl:lwjgl:3.3.1:natives-macos") + lwjglNative ("org.lwjgl:lwjgl-stb:3.3.1:natives-macos") + lwjglNative ("org.lwjgl:lwjgl-tinyfd:3.3.1:natives-macos") + lwjglNative ("org.lwjgl:lwjgl-nanovg:3.3.1:natives-macos") + shade(lwjglJar.get().outputs.files) + shade(prebundle(shadeRelocated)) +} + +tasks.processResources { + inputs.property("id", mod_id) + inputs.property("name", mod_name) + val java = if (project.platform.mcMinor >= 18) { + 17 + } else { + if (project.platform.mcMinor == 17) 16 else 8 + } + val compatLevel = "JAVA_${java}" + inputs.property("java", java) + inputs.property("java_level", compatLevel) + inputs.property("version", mod_version) + inputs.property("mcVersionStr", project.platform.mcVersionStr) + filesMatching(listOf("mcmod.info", "mixins.${mod_id}.json", "mods.toml")) { + expand( + mapOf( + "id" to mod_id, + "name" to mod_name, + "java" to java, + "java_level" to compatLevel, + "version" to mod_version, + "mcVersionStr" to project.platform.mcVersionStr + ) + ) + } + filesMatching("fabric.mod.json") { + expand( + mapOf( + "id" to mod_id, + "name" to mod_name, + "java" to java, + "java_level" to compatLevel, + "version" to mod_version, + "mcVersionStr" to project.platform.mcVersionStr.substringBeforeLast(".") + ".x" + ) + ) + } +} + +tasks { + withType(Jar::class.java) { + if (project.platform.isFabric) { + exclude("mcmod.info", "mods.toml") + } else { + exclude("fabric.mod.json") + if (project.platform.isLegacyForge) { + exclude("mods.toml") + } else { + exclude("mcmod.info") + } + } + } + named<ShadowJar>("shadowJar") { + archiveClassifier.set("dev") + configurations = listOf(shade, lwjglNative) + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + } + remapJar { + input.set(shadowJar.get().archiveFile) + archiveClassifier.set("") + } + jar { + manifest { + attributes( + mapOf( + "ModSide" to "CLIENT", + "ForceLoadAsMod" to true, + "TweakOrder" to "0", + "MixinConfigs" to "mixins.oneconfig.json", + "FMLCorePlugin" to "cc.polyfrost.oneconfig.plugin.LoadingPlugin", + "TweakClass" to "org.spongepowered.asm.launch.MixinTweaker", + "FMLCorePluginContainsFMLMod" to "lol" + ) + ) + } + dependsOn(shadowJar) + archiveClassifier.set("") + enabled = false + } +} + +afterEvaluate { + val checkFile = file(".gradle/loom-cache/SETUP") + val lwjglJarDelayed by tasks.creating { + dependsOn(lwjglJar) + } + + @Suppress("UNUSED_VARIABLE") + val setupGradle by tasks.creating { + dependsOn(lwjglJarDelayed) + val genSourcesWithQuiltflower = tasks.named("genSourcesWithQuiltflower").get() + dependsOn(genSourcesWithQuiltflower) + genSourcesWithQuiltflower.mustRunAfter(lwjglJarDelayed) + doLast { + checkFile.parentFile.mkdirs() + checkFile.createNewFile() + } + } + + if (!checkFile.exists()) { + logger.error("--------------") + logger.error("PLEASE RUN THE `setupGradle` TASK, OR ELSE UNEXPECTED THING MAY HAPPEN!") + logger.error("--------------") + } +}
\ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 527e3ee..2954b27 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,4 +3,5 @@ mod_name = OneConfig mod_id = oneconfig mod_version = 1.0.0 -loom.platform = forge
\ No newline at end of file +loom.platform = forge +essential.defaults.loom=0
\ No newline at end of file diff --git a/root.gradle.kts b/root.gradle.kts new file mode 100644 index 0000000..73e3461 --- /dev/null +++ b/root.gradle.kts @@ -0,0 +1,10 @@ +plugins { + kotlin("jvm") version "1.6.21" apply false + id("gg.essential.multi-version.root") + id("com.github.johnrengelman.shadow") version "7.1.2" apply false + id("io.github.juuxel.loom-quiltflower-mini") version "171a6e2e49" apply false +} + +preprocess { + "1.8.9-forge"(10809, "srg") {} +}
\ No newline at end of file diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 4f8d00d..0000000 --- a/settings.gradle +++ /dev/null @@ -1,8 +0,0 @@ -pluginManagement { - repositories { - gradlePluginPortal() - maven { url = "https://repo.woverflow.cc" } - } -} - -rootProject.name = mod_name
\ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..8cbfd4e --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,34 @@ +pluginManagement { + repositories { + gradlePluginPortal() + mavenCentral() + maven("https://repo.woverflow.cc") + } + plugins { + val egtVersion = "0.1.7" + id("gg.essential.multi-version.root") version egtVersion + } + resolutionStrategy { + eachPlugin { + if (requested.id.id == "io.github.juuxel.loom-quiltflower-mini") { + useModule("com.github.wyvest:loom-quiltflower-mini:${requested.version}") + } + } + } +} + +val mod_name: String by settings + +rootProject.name = mod_name +rootProject.buildFileName = "root.gradle.kts" + +listOf( + "1.8.9-forge" +).forEach { version -> + include(":$version") + project(":$version").apply { + projectDir = file("versions/$version") + buildFileName = "../../build.gradle.kts" + } + +}
\ No newline at end of file diff --git a/src/main/java/cc/polyfrost/oneconfig/OneConfig.java b/src/main/java/cc/polyfrost/oneconfig/OneConfig.java index 3661c42..8812894 100644 --- a/src/main/java/cc/polyfrost/oneconfig/OneConfig.java +++ b/src/main/java/cc/polyfrost/oneconfig/OneConfig.java @@ -28,8 +28,8 @@ import java.util.List; @net.minecraftforge.fml.common.Mod(modid = "@ID@", name = "@NAME@", version = "@VER@") public class OneConfig { public static File jarFile; - public static File oneConfigDir = new File("./OneConfig/"); - public static File themesDir = new File(oneConfigDir, "themes/"); + public static File oneConfigDir = new File("./OneConfig"); + public static File themesDir = new File(oneConfigDir, "themes"); public static OneConfigConfig config; public static TestConfig testConfig; public static List<Mod> loadedMods = new ArrayList<>(); diff --git a/src/main/java/cc/polyfrost/oneconfig/command/OneConfigCommand.java b/src/main/java/cc/polyfrost/oneconfig/command/OneConfigCommand.java index f21e569..fac2112 100644 --- a/src/main/java/cc/polyfrost/oneconfig/command/OneConfigCommand.java +++ b/src/main/java/cc/polyfrost/oneconfig/command/OneConfigCommand.java @@ -4,7 +4,7 @@ import cc.polyfrost.oneconfig.gui.HudGui; import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.test.TestNanoVGGui; import cc.polyfrost.oneconfig.utils.TickDelay; -import gg.essential.universal.UScreen; +import cc.polyfrost.oneconfig.libs.universal.UScreen; import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; diff --git a/src/main/java/cc/polyfrost/oneconfig/config/OneConfigConfig.java b/src/main/java/cc/polyfrost/oneconfig/config/OneConfigConfig.java index a590536..407afdf 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/OneConfigConfig.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/OneConfigConfig.java @@ -89,7 +89,7 @@ public class OneConfigConfig extends Config { @Override public void load() { try (BufferedReader reader = new BufferedReader(new InputStreamReader(Files.newInputStream(Paths.get("OneConfig/" + configFile)), StandardCharsets.UTF_8))) { - deserializePart(new JsonParser().parse(reader).getAsJsonObject(), this.getClass()); + deserializePart(new JsonParser().parse(reader).getAsJsonObject(), this); } catch (IOException e) { e.printStackTrace(); } |
