diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 406ffe1..65fadb2 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -12,7 +12,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: Setup JDK 21 uses: actions/setup-java@v5 with: @@ -24,19 +24,15 @@ jobs: - name: Build run: ./gradlew build - name: Upload Artifact - uses: actions/upload-artifact@v4.0.0 + uses: actions/upload-artifact@v7.0.0 with: - name: 1.21.5 - path: build/libs/*-1.21.5.jar - - uses: actions/upload-artifact@v4.0.0 - with: - name: 1.21.8 - path: build/libs/*-1.21.8.jar - - uses: actions/upload-artifact@v4.0.0 - with: - name: 1.21.10 + archive: false path: build/libs/*-1.21.10.jar - - uses: actions/upload-artifact@v4.0.0 + - uses: actions/upload-artifact@v7.0.0 with: - name: 1.21.11 + archive: false path: build/libs/*-1.21.11.jar + - uses: actions/upload-artifact@v7.0.0 + with: + archive: false + path: build/libs/*-26.1.jar diff --git a/annotations/build.gradle.kts b/annotations/build.gradle.kts index f141e69..af9a867 100644 --- a/annotations/build.gradle.kts +++ b/annotations/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - kotlin("jvm") version "2.2.0" + kotlin("jvm") } repositories { diff --git a/build.gradle.kts b/build.gradle.kts index 6b0e823..05c2f1d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,199 +1,4 @@ -import net.fabricmc.loom.task.ValidateAccessWidenerTask -import org.gradle.kotlin.dsl.withType -import org.jetbrains.kotlin.gradle.dsl.JvmTarget -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - plugins { - idea - id("fabric-loom") - `versioned-catalogues` - kotlin("jvm") version "2.2.0" - alias(libs.plugins.meowdding.auto.mixins) - alias(libs.plugins.kotlin.symbol.processor) + id("net.fabricmc.fabric-loom") + `cs-setup` } - -repositories { - fun scopedMaven(url: String, vararg paths: String) = maven(url) { content { paths.forEach(::includeGroupAndSubgroups) } } - - scopedMaven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1", "me.djtheredstoner") - scopedMaven("https://repo.hypixel.net/repository/Hypixel", "net.hypixel") - scopedMaven("https://maven.parchmentmc.org/", "org.parchmentmc") - scopedMaven("https://api.modrinth.com/maven", "maven.modrinth") - scopedMaven( - "https://maven.teamresourceful.com/repository/maven-public/", - "earth.terrarium", - "com.teamresourceful", - "tech.thatgravyboat", - "me.owdding", - "com.terraformersmc" - ) - scopedMaven("https://maven.nucleoid.xyz/", "eu.pb4") - scopedMaven(url = "https://maven.shedaniel.me/", "me.shedaniel", "dev.architectury") - mavenCentral() -} - -tasks.withType().configureEach { - compilerOptions.jvmTarget.set(JvmTarget.JVM_21) - compilerOptions.optIn.add("kotlin.time.ExperimentalTime") - compilerOptions.freeCompilerArgs.addAll( - "-Xcontext-parameters", - "-Xcontext-sensitive-resolution", - "-Xnullability-annotations=@org.jspecify.annotations:warn" - ) -} - -evaluationDependsOn(":annotations") - -dependencies { - minecraft(versionedCatalog["minecraft"]) - mappings(loom.layered { - officialMojangMappings() - parchment(variantOf(versionedCatalog["parchment"]) { - artifactType("zip") - }) - }) - modImplementation(libs.fabric.loader) - modImplementation(libs.fabric.language.kotlin) - modImplementation(versionedCatalog["fabric.api"]) - - modRuntimeOnly(versionedCatalog["placeholders"]) - modCompileOnly(versionedCatalog["scoreboard.overhaul"]) - - api(libs.skyblockapi) { - capabilities { requireCapability("tech.thatgravyboat:skyblock-api-${stonecutter.current.version}") } - } - include(libs.skyblockapi) { - capabilities { requireCapability("tech.thatgravyboat:skyblock-api-${stonecutter.current.version}-remapped") } - } - api(libs.meowdding.lib) { - capabilities { requireCapability("me.owdding.meowdding-lib:meowdding-lib-${stonecutter.current.version}") } - } - include(libs.meowdding.lib) { - capabilities { requireCapability("me.owdding.meowdding-lib:meowdding-lib-${stonecutter.current.version}-remapped") } - } - compileOnly(project(":annotations")) - ksp(project(":annotations")) - - compileOnly(libs.meowdding.ktmodules) - ksp(libs.meowdding.ktmodules) - - modImplementation(libs.hypixelapi) - modImplementation(libs.mixinconstraints) - - includeImplementation(versionedCatalog["resourceful.lib"]) - includeImplementation(versionedCatalog["resourceful.config"]) - includeImplementation(versionedCatalog["olympus"]) - includeImplementation(libs.resourcefulkt.config) -} - -fun DependencyHandler.includeImplementation(dep: Any) { - include(dep) - modImplementation(dep) -} - - -val mcVersion = stonecutter.current.version.replace(".", "") -val accessWidenerFile = rootProject.file("src/customscoreboard.accesswidener") -loom { - runConfigs["client"].apply { - ideConfigGenerated(true) - runDir = "../../run" - vmArg("-Dfabric.modsFolder=" + '"' + rootProject.projectDir.resolve("run/${mcVersion}Mods").absolutePath + '"') - } - - if (accessWidenerFile.exists()) { - accessWidenerPath.set(accessWidenerFile) - } - - mixin { - defaultRefmapName = "customscoreboard-refmap.json" - } -} - -ksp { - arg("meowdding.project_name", "CustomScoreboard") - arg("meowdding.package", "me.owdding.customscoreboard.generated") -} - -java { - toolchain.languageVersion = JavaLanguageVersion.of(21) - withSourcesJar() -} - -tasks.withType().configureEach { - options.encoding = "UTF-8" - options.release.set(21) -} - -tasks.withType().configureEach { - compilerOptions.jvmTarget.set(JvmTarget.JVM_21) - compilerOptions.optIn.add("kotlin.time.ExperimentalTime") - compilerOptions.freeCompilerArgs.add( - "-Xnullability-annotations=@org.jspecify.annotations:warn" - ) -} - -tasks.processResources { - val replacements = mapOf( - "version" to version, - "minecraft_start" to versionedCatalog.versions.getOrFallback("minecraft.start", "minecraft"), - "minecraft_end" to versionedCatalog.versions.getOrFallback("minecraft.end", "minecraft"), - "fabric_lang_kotlin" to libs.versions.fabric.language.kotlin.get(), - "rlib" to versionedCatalog.versions["resourceful-lib"], - "olympus" to versionedCatalog.versions["olympus"], - "sbapi" to libs.versions.skyblockapi.get(), - "mlib" to libs.versions.meowdding.lib.get(), - "rconfigkt" to libs.versions.rconfigkt.get(), - "rconfig" to versionedCatalog.versions["resourceful-config"], - ) - inputs.properties(replacements) - - filesMatching("fabric.mod.json") { - expand(replacements) - } -} - -autoMixins { - mixinPackage = "me.owdding.customscoreboard.mixins" - projectName = "customscoreboard" - plugin = "com.moulberry.mixinconstraints.ConstraintsMixinPlugin" -} - -idea { - module { - isDownloadJavadoc = true - isDownloadSources = true - - excludeDirs.add(file("run")) - } -} - -tasks.withType().configureEach { - duplicatesStrategy = DuplicatesStrategy.INCLUDE - filesMatching(listOf("**/*.fsh", "**/*.vsh")) { - filter { if (it.startsWith("//!moj_import")) "#${it.substring(3)}" else it } - } - with(copySpec { - from(rootProject.file("src/lang")).include("*.json").into("assets/customscoreboard/lang") - }) - with(copySpec { - from(accessWidenerFile) - }) -} - -val archiveName = "CustomScoreboard" - -base { - archivesName.set("$archiveName-${archivesName.get()}") -} - -tasks.named("build") { - doLast { - val sourceFile = rootProject.projectDir.resolve("versions/${project.name}/build/libs/${archiveName}-${stonecutter.current.version}-$version.jar") - val targetFile = rootProject.projectDir.resolve("build/libs/${archiveName}-$version-${stonecutter.current.version}.jar") - targetFile.parentFile.mkdirs() - targetFile.writeBytes(sourceFile.readBytes()) - } -} - -tasks.withType { enabled = false } diff --git a/build.obf.gradle.kts b/build.obf.gradle.kts new file mode 100644 index 0000000..cae0231 --- /dev/null +++ b/build.obf.gradle.kts @@ -0,0 +1,13 @@ +plugins { + id("net.fabricmc.fabric-loom-remap") + `cs-setup` +} + +dependencies { + mappings(loom.layered { + officialMojangMappings() + parchment(variantOf(versionedCatalog["parchment"]) { + artifactType("zip") + }) + }) +} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 46dccd1..de65250 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -8,8 +8,20 @@ repositories { maven("https://maven.teamresourceful.com/repository/maven-public/") } +fun plugin(provider: Provider): Provider = provider.map { + "${it.pluginId}:${it.pluginId}.gradle.plugin:${it.version}" +} + dependencies { implementation("net.peanuuutz.tomlkt:tomlkt:0.5.0") implementation("org.jetbrains.kotlin:kotlin-stdlib") implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.1") + implementation(libs.kotlin.stdlib) + implementation(libs.kotlin.gradle.plugin) + implementation(libs.kotlin.gradle.plugin.api) + implementation(plugin(libs.plugins.kotlin.symbol.processor)) + implementation(plugin(libs.plugins.meowdding.auto.mixins)) + implementation(plugin(libs.plugins.fabric.loom.asProvider())) + implementation(plugin(libs.plugins.fabric.loom.remap)) + implementation("dev.kikugie.stonecutter:dev.kikugie.stonecutter.gradle.plugin:0.8.3") } diff --git a/buildSrc/src/main/kotlin/cs-setup.gradle.kts b/buildSrc/src/main/kotlin/cs-setup.gradle.kts new file mode 100644 index 0000000..93216a4 --- /dev/null +++ b/buildSrc/src/main/kotlin/cs-setup.gradle.kts @@ -0,0 +1,216 @@ +import net.fabricmc.loom.task.ValidateAccessWidenerTask +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + id("idea") + id("fabric-loom") + id("versioned-catalogues") + kotlin("jvm") + id("me.owdding.auto-mixins") + id("com.google.devtools.ksp") +} + + +private val stonecutter = project.extensions.getByName("stonecutter") as dev.kikugie.stonecutter.build.StonecutterBuildExtension +fun isUnobfuscated() = stonecutter.eval(stonecutter.current.version, ">=26.1") + +repositories { + fun scopedMaven(url: String, vararg paths: String) = maven(url) { content { paths.forEach(::includeGroupAndSubgroups) } } + + scopedMaven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1", "me.djtheredstoner") + scopedMaven("https://repo.hypixel.net/repository/Hypixel", "net.hypixel") + scopedMaven("https://maven.parchmentmc.org/", "org.parchmentmc") + scopedMaven("https://api.modrinth.com/maven", "maven.modrinth") + scopedMaven( + "https://maven.teamresourceful.com/repository/maven-public/", + "earth.terrarium", + "com.teamresourceful", + "tech.thatgravyboat", + "me.owdding", + "com.terraformersmc" + ) + scopedMaven("https://maven.nucleoid.xyz/", "eu.pb4") + scopedMaven(url = "https://maven.shedaniel.me/", "me.shedaniel", "dev.architectury") + mavenCentral() +} + +fun makeAlias(configuration: String) = if (isUnobfuscated()) configuration else "mod" + configuration.replaceFirstChar { it.uppercase() } + +val maybeModImplementation = makeAlias("implementation") +val maybeModCompileOnly = makeAlias("compileOnly") +val maybeModRuntimeOnly = makeAlias("runtimeOnly") +val maybeModApi = makeAlias("api") + + +tasks.withType().configureEach { + compilerOptions.jvmTarget.set(if (isUnobfuscated()) JvmTarget.JVM_25 else JvmTarget.JVM_21) + compilerOptions.optIn.add("kotlin.time.ExperimentalTime") + compilerOptions.freeCompilerArgs.addAll( + "-Xcontext-parameters", + "-Xcontext-sensitive-resolution", + "-Xnullability-annotations=@org.jspecify.annotations:warn" + ) +} + +evaluationDependsOn(":annotations") + + +val mcVersion = stonecutter.current.version.replace(".", "") +val accessWidenerFile = rootProject.file("src/customscoreboard${".obf".takeUnless { isUnobfuscated() } ?: ""}.accesswidener") +loom { + runConfigs["client"].apply { + ideConfigGenerated(true) + runDir = "../../run" + vmArg("-Dfabric.modsFolder=" + '"' + rootProject.projectDir.resolve("run/${mcVersion}Mods").absolutePath + '"') + } + + if (accessWidenerFile.exists()) { + accessWidenerPath.set(accessWidenerFile) + } + + mixin { + defaultRefmapName = "customscoreboard-refmap.json" + } +} + +ksp { + arg("meowdding.project_name", "CustomScoreboard") + arg("meowdding.package", "me.owdding.customscoreboard.generated") +} + +java { + toolchain.languageVersion = JavaLanguageVersion.of(if (isUnobfuscated()) 25 else 21) + withSourcesJar() +} + +tasks.withType().configureEach { + options.encoding = "UTF-8" + options.release.set(if (isUnobfuscated()) 25 else 21) +} + +tasks.withType().configureEach { + compilerOptions.jvmTarget.set(if (isUnobfuscated()) JvmTarget.JVM_25 else JvmTarget.JVM_21) + compilerOptions.optIn.add("kotlin.time.ExperimentalTime") + compilerOptions.freeCompilerArgs.add( + "-Xnullability-annotations=@org.jspecify.annotations:warn" + ) +} + +tasks.processResources { + val range = if (versionedCatalog.versions.has("minecraft.range")) { + versionedCatalog.versions.get("minecraft.range").toString() + } else { + val start = versionedCatalog.versions.getOrFallback("minecraft.start", "minecraft") + val end = versionedCatalog.versions.getOrFallback("minecraft.end", "minecraft") + ">=$start <=$end" + } + + val replacements = mapOf( + "version" to version, + "minecraft_range" to range, + "fabric_lang_kotlin" to versionedCatalog.versions["fabric.language.kotlin"], + "rlib" to versionedCatalog.versions["resourceful-lib"], + "olympus" to versionedCatalog.versions["olympus"], + "sbapi" to versionedCatalog.versions["skyblockapi"], + "mlib" to versionedCatalog.versions["meowdding.lib"], + "rconfigkt" to versionedCatalog.versions["rconfigkt"], + "rconfig" to versionedCatalog.versions["resourceful-config"], + ) + inputs.properties(replacements) + + filesMatching("fabric.mod.json") { + expand(replacements) + } +} + +autoMixins { + mixinPackage = "me.owdding.customscoreboard.mixins" + projectName = "customscoreboard" + plugin = "com.moulberry.mixinconstraints.ConstraintsMixinPlugin" +} + +idea { + module { + isDownloadJavadoc = true + isDownloadSources = true + + excludeDirs.add(file("run")) + } +} + +tasks.withType().configureEach { + duplicatesStrategy = DuplicatesStrategy.INCLUDE + filesMatching(listOf("**/*.fsh", "**/*.vsh")) { + filter { if (it.startsWith("//!moj_import")) "#${it.substring(3)}" else it } + } + with(copySpec { + from(rootProject.file("src/lang")).include("*.json").into("assets/customscoreboard/lang") + }) + with(copySpec { + from(accessWidenerFile) + rename { it.replace(".obf", "") } + }) +} + +val archiveName = "CustomScoreboard" + +base { + archivesName.set("$archiveName-${archivesName.get()}") +} + +tasks.named("build") { + doLast { + val sourceFile = rootProject.projectDir.resolve("versions/${project.name}/build/libs/${archiveName}-${stonecutter.current.version}-$version.jar") + val targetFile = rootProject.projectDir.resolve("build/libs/${archiveName}-$version-${stonecutter.current.version}.jar") + targetFile.parentFile.mkdirs() + targetFile.writeBytes(sourceFile.readBytes()) + } +} + +tasks.withType { enabled = false } + +dependencies { + minecraft(versionedCatalog["minecraft"]) + + maybeModImplementation(versionedCatalog["fabric.loader"]) + maybeModImplementation(versionedCatalog["fabric.language.kotlin"]) + maybeModImplementation(versionedCatalog["fabric.api"]) + + if (!isUnobfuscated()) maybeModRuntimeOnly(versionedCatalog["hypixel.modapi.fabric"]) + + maybeModRuntimeOnly(versionedCatalog["placeholders"]) + if (versionedCatalog.has("scoreboard.overhaul")) { + maybeModCompileOnly(versionedCatalog["scoreboard.overhaul"]) + } + + api(versionedCatalog["skyblockapi"]) { + capabilities { requireCapability("tech.thatgravyboat:skyblock-api-${stonecutter.current.version}") } + } + "include"(versionedCatalog["skyblockapi"]) { + capabilities { requireCapability("tech.thatgravyboat:skyblock-api-${stonecutter.current.version}${"-remapped".takeUnless { isUnobfuscated() } ?: ""}") } + } + api(versionedCatalog["meowdding.lib"]) { + capabilities { requireCapability("me.owdding.meowdding-lib:meowdding-lib-${stonecutter.current.version}") } + } + "include"(versionedCatalog["meowdding.lib"]) { + capabilities { requireCapability("me.owdding.meowdding-lib:meowdding-lib-${stonecutter.current.version}${"-remapped".takeUnless { isUnobfuscated() } ?: ""}") } + } + "compileOnly"(project(":annotations")) + "ksp"(project(":annotations")) + + "compileOnly"(versionedCatalog["meowdding.ktmodules"]) + "ksp"(versionedCatalog["meowdding.ktmodules"]) + + maybeModImplementation(versionedCatalog["mixinconstraints"]) + + includeImplementation(versionedCatalog["resourceful.lib"]) + includeImplementation(versionedCatalog["resourceful.config"]) + includeImplementation(versionedCatalog["olympus"]) + includeImplementation(versionedCatalog["resourcefulkt.config"]) +} + +fun DependencyHandlerScope.includeImplementation(dep: Any) { + include(dep) + maybeModImplementation(dep) +} diff --git a/buildSrc/src/main/kotlin/root.kt b/buildSrc/src/main/kotlin/root.kt index 6dfef80..688d515 100644 --- a/buildSrc/src/main/kotlin/root.kt +++ b/buildSrc/src/main/kotlin/root.kt @@ -12,9 +12,12 @@ data class ForwardingVersionCatalog( ) { constructor(vararg catalogs: VersionCatalog) : this(listOf(*catalogs)) - private fun first(name: String, lookup: VersionCatalog.(String) -> Optional): T { + private fun first(name: String, lookup: VersionCatalog.(String) -> Optional): T = runCatching { return catalogs.firstNotNullOf { it.lookup(name).orElse(null) } + }.getOrElse { + throw RuntimeException("Failed to find any entry for $name", it) } + fun has(name: String) = libraries.has(name) val libraries: ForwardingProperty> = ForwardingProperty(this, VersionCatalog::findLibrary) val bundles: ForwardingProperty> = ForwardingProperty(this, VersionCatalog::findBundle) @@ -33,6 +36,7 @@ data class ForwardingVersionCatalog( val lookup: VersionCatalog.(String) -> Optional, ) { operator fun get(name: String): T = parent.first(name, lookup) + fun has(name: String): Boolean = runCatching { get(name) }.map { true }.getOrDefault(false) fun getOrFallback( name: String, fallbackName: String, diff --git a/gradle/1_21_10.versions.toml b/gradle/1_21_10.versions.toml index 865465e..c110cc3 100644 --- a/gradle/1_21_10.versions.toml +++ b/gradle/1_21_10.versions.toml @@ -10,7 +10,7 @@ resourceful-config = "3.9.2" olympus = "1.6.3" placeholders = "2.8.1+1.21.10" -scoreboard-overhaul = "1.4.1-mc1.21.6" +scoreboard-overhaul = "1.4.2-mc1.21.9" [libraries] minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" } @@ -24,4 +24,4 @@ iris = { module = "maven.modrinth:iris", version = "1.9.1+1.21.7-fabric" } olympus = { module = "earth.terrarium.olympus:olympus-fabric-1.21.9", version.ref = "olympus" } placeholders = { module = "eu.pb4:placeholder-api", version.ref = "placeholders" } -scoreboard-overhaul = { module = "maven.modrinth:scoreboard-overhaul", version.ref = "scoreboard-overhaul" } # todo correct version +scoreboard-overhaul = { module = "maven.modrinth:scoreboard-overhaul", version.ref = "scoreboard-overhaul" } diff --git a/gradle/1_21_11.versions.toml b/gradle/1_21_11.versions.toml index ce791b3..8f93613 100644 --- a/gradle/1_21_11.versions.toml +++ b/gradle/1_21_11.versions.toml @@ -11,7 +11,7 @@ resourceful-config = "3.11.0" olympus = "1.7.1" placeholders = "2.8.1+1.21.10" -scoreboard-overhaul = "1.4.1-mc1.21.6" +scoreboard-overhaul = "1.4.2-mc1.21.9" [libraries] minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" } diff --git a/gradle/26_1.versions.toml b/gradle/26_1.versions.toml new file mode 100644 index 0000000..6f2eb3f --- /dev/null +++ b/gradle/26_1.versions.toml @@ -0,0 +1,29 @@ +[versions] +minecraft-range = "26.1.x" +minecraft = "26.1" + +sbapi-mc-version = "26.1" +fabric-api = "0.145.1+26.1" + +resourceful-lib = "4.0.0" +resourceful-config = "4.0.0" +olympus = "1.8.0" +placeholders = "3.0.0-beta.2+26.1" + +rconfigkt = "4.0.0-beta.1" + +scoreboard-overhaul = "1.4.2-mc26.1" + +[libraries] +minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" } + +fabric-api = { module = "net.fabricmc.fabric-api:fabric-api", version.ref = "fabric-api" } + +resourcefulkt-config = { module = "com.teamresourceful.resourcefulconfigkt:resourcefulconfigkt-26.1-rc-1", version.ref = "rconfigkt" } + +resourceful-lib = { module = "com.teamresourceful.resourcefullib:resourcefullib-fabric-26.1", version.ref = "resourceful-lib" } +resourceful-config = { module = "com.teamresourceful.resourcefulconfig:resourcefulconfig-fabric-26.1", version.ref = "resourceful-config" } +olympus = { module = "earth.terrarium.olympus:olympus-fabric-26.1", version.ref = "olympus" } +placeholders = { module = "eu.pb4:placeholder-api", version.ref = "placeholders" } + +#scoreboard-overhaul = { module = "maven.modrinth:scoreboard-overhaul", version.ref = "scoreboard-overhaul" } # todo correct version diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 870d289..a4f918a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,31 +2,35 @@ fabric-loader = "0.17.3" fabric-language-kotlin = "1.13.4+kotlin.2.2.0" -fabric-api = "0.133.4" -kotlin-symbol-processor = "2.2.0-2.0.2" +kotlin = "2.3.0" +kotlin-gradle-plugin = "2.3.0" +kotlin-symbol-processor = "2.3.5" + kotlin_poet = "1.0.1" kotlin_poet_ksp = "1.0.1" -skyblockapi = "4.0.12" -hypixelapi = "1.0.1+build.1+mc1.21" +hypixel-modapi-fabric = "1.0.1+build.1+mc1.21" + +skyblockapi = "4.1.3" mixinconstraints = "1.0.7" rconfigkt = "3.5.16" -meowdding-lib = "4.0.4" +meowdding-lib = "4.1.2" meowdding-ktmodules = "1.0.8" meowdding-auto-mixins = "1.0.5" -terrarium-cloche = "0.13.5" +fabric-loom = "1.15-SNAPSHOT" [libraries] fabric-loader = { module = "net.fabricmc:fabric-loader", version.ref = "fabric-loader" } fabric-language-kotlin = { module = "net.fabricmc:fabric-language-kotlin", version.ref = "fabric-language-kotlin" } +hypixel-modapi-fabric = { module = "maven.modrinth:hypixel-mod-api", version.ref = "hypixel-modapi-fabric" } + skyblockapi = { module = "tech.thatgravyboat:skyblock-api", version.ref = "skyblockapi" } -hypixelapi = { module = "maven.modrinth:hypixel-mod-api", version.ref = "hypixelapi" } resourcefulkt-config = { module = "com.teamresourceful.resourcefulconfigkt:resourcefulconfigkt-fabric-1.21.5", version.ref = "rconfigkt" } @@ -35,6 +39,11 @@ meowdding-ktmodules = { module = "me.owdding.ktmodules:KtModules", version.ref = mixinconstraints = { module = "com.moulberry:mixinconstraints", version.ref = "mixinconstraints" } +kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" } + +kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin-gradle-plugin" } +kotlin-gradle-plugin-api = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin-api", version.ref = "kotlin-gradle-plugin" } + # Codegen kotlin_poet = { module = "me.owdding.kotlinpoet:kotlinpoet-jvm", version.ref = "kotlin_poet" } kotlin_poet_ksp = { module = "me.owdding.kotlinpoet:ksp", version.ref = "kotlin_poet_ksp" } @@ -44,3 +53,6 @@ ksp = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = meowdding-auto-mixins = { id = "me.owdding.auto-mixins", version.ref = "meowdding-auto-mixins" } kotlin-symbol-processor = { id = "com.google.devtools.ksp", version.ref = "kotlin-symbol-processor" } + +fabric-loom-remap = { id = "net.fabricmc.fabric-loom-remap", version.ref = "fabric-loom" } +fabric-loom = { id = "net.fabricmc.fabric-loom", version.ref = "fabric-loom" } diff --git a/gradle/replacements.toml b/gradle/replacements.toml index 6ec44ff..3072495 100644 --- a/gradle/replacements.toml +++ b/gradle/replacements.toml @@ -38,3 +38,11 @@ type = "string" condition = "< 1.21.11" from = "net.minecraft.util.Util" to = "net.minecraft.Util" + +[gui_graphics_unnamed] +type = "regex" +condition = "< 26.1" +regex = "import net.minecraft.client.gui.GuiGraphicsExtractor(?!;)" +to = "import net.minecraft.client.gui.GuiGraphics as GuiGraphicsExtractor" +reverseRegex = "import net.minecraft.client.gui.GuiGraphics as GuiGraphicsExtractor" +reverse = "import net.minecraft.client.gui.GuiGraphicsExtractor" diff --git a/settings.gradle.kts b/settings.gradle.kts index b57787e..9538b7e 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -11,14 +11,16 @@ pluginManagement { plugins { id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" - id("dev.kikugie.stonecutter") version "0.7.10" + id("dev.kikugie.stonecutter") version "0.9" } -val versions = listOf("1.21.11", "1.21.10") +val versions = listOf("26.1", "1.21.11", "1.21.10") stonecutter { create(rootProject) { - versions(versions) + versions.forEach { + version(it).buildscript = if (stonecutter.eval(it, "<=1.21.11")) "build.obf.gradle.kts" else "build.gradle.kts" + } vcsVersion = versions.first() } } diff --git a/src/customscoreboard.accesswidener b/src/customscoreboard.accesswidener index 4f5a9fc..2dce05f 100644 --- a/src/customscoreboard.accesswidener +++ b/src/customscoreboard.accesswidener @@ -1,3 +1,3 @@ -accessWidener v2 named +accessWidener v2 official accessible class net/minecraft/client/gui/render/GuiRenderer$Draw diff --git a/src/customscoreboard.obf.accesswidener b/src/customscoreboard.obf.accesswidener new file mode 100644 index 0000000..4f5a9fc --- /dev/null +++ b/src/customscoreboard.obf.accesswidener @@ -0,0 +1,3 @@ +accessWidener v2 named + +accessible class net/minecraft/client/gui/render/GuiRenderer$Draw diff --git a/src/main/java/me/owdding/customscoreboard/hooks/CommandEncoderHook.java b/src/main/java/me/owdding/customscoreboard/hooks/CommandEncoderHook.java new file mode 100644 index 0000000..fcc0edf --- /dev/null +++ b/src/main/java/me/owdding/customscoreboard/hooks/CommandEncoderHook.java @@ -0,0 +1,6 @@ +package me.owdding.customscoreboard.hooks; + +public interface CommandEncoderHook { + + void cs$setInRenderPass(boolean inRenderPass); +} diff --git a/src/main/java/me/owdding/customscoreboard/mixins/blur/CommandEncoderMixin.java b/src/main/java/me/owdding/customscoreboard/mixins/blur/CommandEncoderMixin.java new file mode 100644 index 0000000..1c87f21 --- /dev/null +++ b/src/main/java/me/owdding/customscoreboard/mixins/blur/CommandEncoderMixin.java @@ -0,0 +1,25 @@ +package me.owdding.customscoreboard.mixins.blur; + +//? if >= 26.1 { +import com.mojang.blaze3d.systems.CommandEncoder; +import com.mojang.blaze3d.systems.CommandEncoderBackend; +import me.owdding.customscoreboard.hooks.CommandEncoderHook; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(CommandEncoder.class) +public class CommandEncoderMixin implements CommandEncoderHook { + + @Final + @Shadow + private CommandEncoderBackend backend; + + @Override + public void cs$setInRenderPass(boolean inRenderPass) { + if (this.backend instanceof CommandEncoderHook hook) { + hook.cs$setInRenderPass(inRenderPass); + } + } +} +//? } diff --git a/src/main/java/me/owdding/customscoreboard/mixins/blur/GlCommandEncoderAccessor.java b/src/main/java/me/owdding/customscoreboard/mixins/blur/GlCommandEncoderAccessor.java deleted file mode 100644 index d4c90a9..0000000 --- a/src/main/java/me/owdding/customscoreboard/mixins/blur/GlCommandEncoderAccessor.java +++ /dev/null @@ -1,12 +0,0 @@ -package me.owdding.customscoreboard.mixins.blur; - -import com.mojang.blaze3d.opengl.GlCommandEncoder; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(GlCommandEncoder.class) -public interface GlCommandEncoderAccessor { - - @Accessor("inRenderPass") - void cs$setInRenderPass(boolean inRenderPass); -} diff --git a/src/main/java/me/owdding/customscoreboard/mixins/blur/GlCommandEncoderMixin.java b/src/main/java/me/owdding/customscoreboard/mixins/blur/GlCommandEncoderMixin.java new file mode 100644 index 0000000..0d75422 --- /dev/null +++ b/src/main/java/me/owdding/customscoreboard/mixins/blur/GlCommandEncoderMixin.java @@ -0,0 +1,16 @@ +package me.owdding.customscoreboard.mixins.blur; + +import me.owdding.customscoreboard.hooks.CommandEncoderHook; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(targets = "com.mojang.blaze3d.opengl.GlCommandEncoder") +public class GlCommandEncoderMixin implements CommandEncoderHook { + + @Shadow private boolean inRenderPass; + + @Override + public void cs$setInRenderPass(boolean inRenderPass) { + this.inRenderPass = inRenderPass; + } +} diff --git a/src/main/java/me/owdding/customscoreboard/mixins/blur/GuiRendererMixin.java b/src/main/java/me/owdding/customscoreboard/mixins/blur/GuiRendererMixin.java index 6051711..b6804aa 100644 --- a/src/main/java/me/owdding/customscoreboard/mixins/blur/GuiRendererMixin.java +++ b/src/main/java/me/owdding/customscoreboard/mixins/blur/GuiRendererMixin.java @@ -9,6 +9,7 @@ import com.mojang.blaze3d.vertex.VertexFormat; import earth.terrarium.olympus.client.pipelines.uniforms.RoundedTextureUniform; import me.owdding.customscoreboard.feature.customscoreboard.BlurredBackground; +import me.owdding.customscoreboard.hooks.CommandEncoderHook; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.navigation.ScreenRectangle; import net.minecraft.client.gui.render.GuiRenderer; @@ -40,9 +41,9 @@ private void copyBackground(GuiRenderer.Draw draw, RenderPass pass, GpuBuffer bu var target = Minecraft.getInstance().getMainRenderTarget(); var uniform = BlurredBackground.getUniform(); - if (!(encoder instanceof GlCommandEncoderAccessor accessor)) return; + if (!(encoder instanceof CommandEncoderHook hook)) return; - accessor.cs$setInRenderPass(false); + hook.cs$setInRenderPass(false); encoder.copyTextureToTexture( target.getColorTexture(), @@ -54,7 +55,7 @@ private void copyBackground(GuiRenderer.Draw draw, RenderPass pass, GpuBuffer bu ); var uniformBuffer = uniform != null ? RoundedTextureUniform.STORAGE.get().writeUniform(uniform) : null; - accessor.cs$setInRenderPass(true); + hook.cs$setInRenderPass(true); if (uniformBuffer != null) { pass.setUniform(RoundedTextureUniform.NAME, uniformBuffer); diff --git a/src/main/java/me/owdding/customscoreboard/mixins/blur/MinecraftMixin.java b/src/main/java/me/owdding/customscoreboard/mixins/blur/MinecraftMixin.java index 3b6aa21..8f9443c 100644 --- a/src/main/java/me/owdding/customscoreboard/mixins/blur/MinecraftMixin.java +++ b/src/main/java/me/owdding/customscoreboard/mixins/blur/MinecraftMixin.java @@ -22,7 +22,12 @@ private void onInit(CallbackInfo ci) { BlurredBackground.init(this.window.getWidth(), this.window.getHeight()); } - @Inject(method = "resizeDisplay", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GameRenderer;resize(II)V")) + @Inject( + //~ if >= 26.1 'resizeDisplay' -> 'resizeGui' + method = "resizeGui", + //~ if >= 26.1 'Lnet/minecraft/client/renderer/GameRenderer;resize(II)V' -> 'Lcom/mojang/blaze3d/platform/Window;setGuiScale(I)V' + at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/Window;setGuiScale(I)V") + ) private void onResize(CallbackInfo ci) { BlurredBackground.init(this.window.getWidth(), this.window.getHeight()); } diff --git a/src/main/java/me/owdding/customscoreboard/mixins/compat/ScoreboardConfigMixin.java b/src/main/java/me/owdding/customscoreboard/mixins/compat/ScoreboardConfigMixin.java index 9e89e63..a76166b 100644 --- a/src/main/java/me/owdding/customscoreboard/mixins/compat/ScoreboardConfigMixin.java +++ b/src/main/java/me/owdding/customscoreboard/mixins/compat/ScoreboardConfigMixin.java @@ -1,4 +1,5 @@ -package me.owdding.customscoreboard.mixins.compat; +//? scoreboard_overhaul { +/*package me.owdding.customscoreboard.mixins.compat; import com.llamalad7.mixinextras.injector.ModifyReturnValue; import com.moulberry.mixinconstraints.annotations.IfModLoaded; @@ -20,3 +21,4 @@ public class ScoreboardConfigMixin { } } +*///? } diff --git a/src/main/java/me/owdding/customscoreboard/mixins/compat/ScoreboardOverhaulDrawServiceMixin.java b/src/main/java/me/owdding/customscoreboard/mixins/compat/ScoreboardOverhaulDrawServiceMixin.java index 96b6cac..22ec0ce 100644 --- a/src/main/java/me/owdding/customscoreboard/mixins/compat/ScoreboardOverhaulDrawServiceMixin.java +++ b/src/main/java/me/owdding/customscoreboard/mixins/compat/ScoreboardOverhaulDrawServiceMixin.java @@ -1,4 +1,5 @@ -package me.owdding.customscoreboard.mixins.compat; +//? scoreboard_overhaul { +/*package me.owdding.customscoreboard.mixins.compat; import com.llamalad7.mixinextras.sugar.Local; import com.llamalad7.mixinextras.sugar.ref.LocalRef; @@ -35,3 +36,4 @@ public void setColorTint(CallbackInfo ci, @Local(argsOnly = true) LocalRef= 26.1 'drawCenteredString' -> 'centeredText' + graphics.centeredText(McFont.self, text, centerX, context.y, -1) } it.withCallback { if (BackgroundConfig.customImageFile.isNotEmpty()) { diff --git a/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/BlurredBackground.kt b/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/BlurredBackground.kt index 7f4d110..e88502e 100644 --- a/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/BlurredBackground.kt +++ b/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/BlurredBackground.kt @@ -14,10 +14,11 @@ import com.mojang.blaze3d.vertex.VertexFormat import earth.terrarium.olympus.client.pipelines.uniforms.RoundedTextureUniform import me.owdding.customscoreboard.Main import net.fabricmc.loader.api.FabricLoader -import net.minecraft.client.gui.GuiGraphics +import net.minecraft.client.gui.GuiGraphicsExtractor import net.minecraft.client.gui.navigation.ScreenRectangle import net.minecraft.client.gui.render.TextureSetup -import net.minecraft.client.gui.render.state.GuiElementRenderState +//~ if >= 26.1 'gui.render.state' -> 'renderer.state.gui' +import net.minecraft.client.renderer.state.gui.GuiElementRenderState import net.minecraft.client.renderer.RenderPipelines import org.joml.Matrix3x2f import org.joml.Vector2f @@ -73,7 +74,7 @@ object BlurredBackground { setup = TextureSetup.singleTexture( RenderSystem.getDevice().createTextureView(target!!.colorTexture!!), - //? if =1.21.11 { + //? if >=1.21.11 { RenderSystem.getSamplerCache().getSampler( AddressMode.CLAMP_TO_EDGE, AddressMode.CLAMP_TO_EDGE, FilterMode.NEAREST, FilterMode.NEAREST, @@ -83,7 +84,7 @@ object BlurredBackground { ) } - fun render(graphics: GuiGraphics, x: Int, y: Int, width: Int, height: Int, radius: Int) { + fun render(graphics: GuiGraphicsExtractor, x: Int, y: Int, width: Int, height: Int, radius: Int) { if (this._uniform != null) { if (!this.multiUseError) Main.warn("BlurredBackground.render was called multiple times in the same frame!") this.multiUseError = true @@ -98,7 +99,8 @@ object BlurredBackground { Vector2f(x * scale + scaledWidth / 2f, y * scale + scaledHeight / 2f), scale, ) - graphics.guiRenderState.submitGuiElement( + //~ if >= 26.1 'submit' -> 'add' + graphics.guiRenderState.addGuiElement( State(Matrix3x2f(graphics.pose()), ScreenRectangle(x, y, width, height), graphics.scissorStack.peek()) ) } diff --git a/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/CustomScoreboardRenderer.kt b/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/CustomScoreboardRenderer.kt index 9bbd1d8..3297768 100644 --- a/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/CustomScoreboardRenderer.kt +++ b/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/CustomScoreboardRenderer.kt @@ -87,9 +87,11 @@ object CustomScoreboardRenderer { setPosition(position.first, position.second) }.visitWidgets { widget -> if (isAllowedScreen()) { - widget.render(event.graphics, mouseX.toInt(), mouseY.toInt(), 0f) + //~ if >= 26.1 'render' -> 'extractRenderState' + widget.extractRenderState(event.graphics, mouseX.toInt(), mouseY.toInt(), 0f) } else { - widget.render(event.graphics, 0, 0, 0f) + //~ if >= 26.1 'render' -> 'extractRenderState' + widget.extractRenderState(event.graphics, 0, 0, 0f) } } } diff --git a/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/ScoreboardLine.kt b/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/ScoreboardLine.kt index c4c8445..562292c 100644 --- a/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/ScoreboardLine.kt +++ b/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/ScoreboardLine.kt @@ -41,7 +41,8 @@ data class ScoreboardLine( button.withTexture(null) button.withRenderer { graphics, ctx, ticks -> graphics.translated(button.x, button.y) { - layout.render(graphics, ctx.mouseX, ctx.mouseY, ticks) + //~ if >= 26.1 'render' -> 'extractRenderState' + layout.extractRenderState(graphics, ctx.mouseX, ctx.mouseY, ticks) } } diff --git a/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementBank.kt b/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementBank.kt index c7977f7..b2d21ec 100644 --- a/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementBank.kt +++ b/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementBank.kt @@ -8,7 +8,7 @@ import me.owdding.customscoreboard.utils.ScoreboardElement import me.owdding.customscoreboard.utils.Utils.hasCookieActive import me.owdding.lib.extensions.shorten import tech.thatgravyboat.skyblockapi.api.location.SkyBlockIsland -import tech.thatgravyboat.skyblockapi.api.profile.CurrencyAPI +import tech.thatgravyboat.skyblockapi.api.profile.currency.CurrencyAPI import tech.thatgravyboat.skyblockapi.api.profile.profile.ProfileAPI @ScoreboardElement diff --git a/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementBits.kt b/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementBits.kt index 07a548b..dc099f6 100644 --- a/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementBits.kt +++ b/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementBits.kt @@ -7,8 +7,8 @@ import me.owdding.customscoreboard.feature.customscoreboard.ScoreboardLine.Compa import me.owdding.customscoreboard.utils.NumberUtils.format import me.owdding.customscoreboard.utils.ScoreboardElement import tech.thatgravyboat.skyblockapi.api.location.SkyBlockIsland -import tech.thatgravyboat.skyblockapi.api.profile.CurrencyAPI import tech.thatgravyboat.skyblockapi.api.profile.community.CommunityCenterAPI +import tech.thatgravyboat.skyblockapi.api.profile.currency.CurrencyAPI @ScoreboardElement object ElementBits : NumberTrackingElement("§b") { diff --git a/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementCookieBuff.kt b/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementCookieBuff.kt index d7c4015..4ea2e81 100644 --- a/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementCookieBuff.kt +++ b/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementCookieBuff.kt @@ -5,7 +5,7 @@ import me.owdding.customscoreboard.feature.customscoreboard.ScoreboardLine.Compa import me.owdding.customscoreboard.utils.ScoreboardElement import me.owdding.customscoreboard.utils.Utils.toFormatYears import tech.thatgravyboat.skyblockapi.api.profile.effects.EffectsAPI -import tech.thatgravyboat.skyblockapi.utils.time.until +import tech.thatgravyboat.skyblockapi.utils.extentions.until @ScoreboardElement object ElementCookieBuff : Element() { diff --git a/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementCopper.kt b/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementCopper.kt index 0472c04..cae19e3 100644 --- a/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementCopper.kt +++ b/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementCopper.kt @@ -6,7 +6,7 @@ import me.owdding.customscoreboard.feature.customscoreboard.ScoreboardLine.Compa import me.owdding.customscoreboard.utils.NumberUtils.format import me.owdding.customscoreboard.utils.ScoreboardElement import tech.thatgravyboat.skyblockapi.api.location.SkyBlockIsland -import tech.thatgravyboat.skyblockapi.api.profile.CurrencyAPI +import tech.thatgravyboat.skyblockapi.api.profile.currency.CurrencyAPI @ScoreboardElement object ElementCopper : NumberTrackingElement("§c") { diff --git a/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementGems.kt b/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementGems.kt index a9f4cf1..2617267 100644 --- a/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementGems.kt +++ b/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementGems.kt @@ -5,7 +5,7 @@ import me.owdding.customscoreboard.feature.customscoreboard.NumberTrackingElemen import me.owdding.customscoreboard.utils.NumberUtils.format import me.owdding.customscoreboard.utils.ScoreboardElement import tech.thatgravyboat.skyblockapi.api.location.SkyBlockIsland -import tech.thatgravyboat.skyblockapi.api.profile.CurrencyAPI +import tech.thatgravyboat.skyblockapi.api.profile.currency.CurrencyAPI @ScoreboardElement object ElementGems : NumberTrackingElement("§a") { diff --git a/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementMayor.kt b/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementMayor.kt index 6aff9fc..198eae0 100644 --- a/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementMayor.kt +++ b/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementMayor.kt @@ -4,7 +4,8 @@ import me.owdding.customscoreboard.config.categories.LinesConfig import me.owdding.customscoreboard.utils.ScoreboardElement import me.owdding.lib.extensions.toReadableTime import tech.thatgravyboat.skyblockapi.api.area.hub.ElectionAPI -import tech.thatgravyboat.skyblockapi.api.data.Candidate +import tech.thatgravyboat.skyblockapi.api.data.MayorCandidate +import tech.thatgravyboat.skyblockapi.api.data.MayorCandidates import tech.thatgravyboat.skyblockapi.api.datetime.SkyBlockInstant import tech.thatgravyboat.skyblockapi.api.location.SkyBlockIsland import tech.thatgravyboat.skyblockapi.utils.extentions.until @@ -14,14 +15,14 @@ import kotlin.time.Duration @ScoreboardElement object ElementMayor : Element() { override fun getDisplay() = buildList { - val jerryActive = Candidate.JERRY.isActive && LinesConfig.showJerryInMinister && ElectionAPI.jerryCandidate != null - val mayor = ElectionAPI.currentMayor ?: return@buildList + val jerryActive = MayorCandidates.JERRY.isActive && LinesConfig.showJerryInMinister && ElectionAPI.currentJerryCandidate != null + val mayor = ElectionAPI.mayor ?: return@buildList val perksDisplay = LinesConfig.mayorPerksDisplay val count = if (perksDisplay == PerkDisplay.COUNT) " §e(${mayor.activePerks.size})" else "" val ministerDisplay = LinesConfig.ministerDisplay - val minister = ElectionAPI.currentMinister ?: if (jerryActive) ElectionAPI.jerryCandidate?.first else null + val minister = ElectionAPI.minister ?: if (jerryActive) ElectionAPI.currentJerryCandidate?.first else null val ministerCompact = if (ministerDisplay == MinisterDisplay.COMPACT && minister != null) { "§7, ${minister.formatName()}" } else "" @@ -67,7 +68,7 @@ object ElementMayor : Element() { } } - private fun MutableList.addPerks(candidate: Candidate) { + private fun MutableList.addPerks(candidate: MayorCandidate) { val color = candidateColor[candidate] ?: "§e" candidate.activePerks.forEach { perk -> add(" §7- $color${perk.perkName}") { @@ -76,7 +77,7 @@ object ElementMayor : Element() { } } - private fun MutableList.addHoverPerks(candidate: Candidate) { + private fun MutableList.addHoverPerks(candidate: MayorCandidate) { val color = candidateColor[candidate] ?: "§e" candidate.activePerks.forEachIndexed { i, perk -> if (i != 0) add("") @@ -87,7 +88,7 @@ object ElementMayor : Element() { override fun showIsland() = !SkyBlockIsland.inAnyIsland(SkyBlockIsland.THE_RIFT) - override fun showWhen() = ElectionAPI.currentMayor != null + override fun showWhen() = ElectionAPI.mayor != null override val configLine = "Mayor" override val id = "MAYOR" @@ -96,7 +97,7 @@ object ElementMayor : Element() { private const val ELECTION_MONTH = 3 private const val ELECTION_DAY = 27 - private fun timeUntilJerryMayor(): Duration? = ElectionAPI.jerryCandidate?.second?.until() + private fun timeUntilJerryMayor(): Duration? = ElectionAPI.currentJerryCandidate?.second?.until() private fun timeUntilNextMayor(): Duration { val instant = SkyBlockInstant.now() @@ -110,20 +111,20 @@ object ElementMayor : Element() { return SkyBlockInstant(mayorYear, 3, 27) - instant } - private fun Candidate.formatName(): String = (candidateColor[this] ?: "§e") + candidateName + private fun MayorCandidate.formatName(): String = (candidateColor[this] ?: "§e") + candidateName private val candidateColor = mapOf( - Candidate.AATROX to "§3", - Candidate.COLE to "§e", - Candidate.DIANA to "§2", - Candidate.DIAZ to "§6", - Candidate.FINNEGAN to "§c", - Candidate.FOXY to "§d", - Candidate.MARINA to "§b", - Candidate.PAUL to "§c", - Candidate.SCORPIUS to "§d", - Candidate.JERRY to "§d", - Candidate.DERPY to "§d", + MayorCandidates.AATROX to "§3", + MayorCandidates.COLE to "§e", + MayorCandidates.DIANA to "§2", + MayorCandidates.DIAZ to "§6", + MayorCandidates.FINNEGAN to "§c", + MayorCandidates.FOXY to "§d", + MayorCandidates.MARINA to "§b", + MayorCandidates.PAUL to "§c", + MayorCandidates.SCORPIUS to "§d", + MayorCandidates.JERRY to "§d", + MayorCandidates.DERPY to "§d", ) enum class PerkDisplay(private val display: String) { diff --git a/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementNorthStars.kt b/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementNorthStars.kt index 7e2c7d5..42e2381 100644 --- a/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementNorthStars.kt +++ b/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementNorthStars.kt @@ -5,7 +5,7 @@ import me.owdding.customscoreboard.feature.customscoreboard.NumberTrackingElemen import me.owdding.customscoreboard.utils.NumberUtils.format import me.owdding.customscoreboard.utils.ScoreboardElement import tech.thatgravyboat.skyblockapi.api.location.SkyBlockIsland -import tech.thatgravyboat.skyblockapi.api.profile.CurrencyAPI +import tech.thatgravyboat.skyblockapi.api.profile.currency.CurrencyAPI @ScoreboardElement object ElementNorthStars : NumberTrackingElement("§d") { diff --git a/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementSoulflow.kt b/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementSoulflow.kt index 16d3029..f81c701 100644 --- a/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementSoulflow.kt +++ b/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementSoulflow.kt @@ -11,7 +11,7 @@ import tech.thatgravyboat.skyblockapi.api.events.base.predicates.OnlyWidget import tech.thatgravyboat.skyblockapi.api.events.info.TabWidget import tech.thatgravyboat.skyblockapi.api.events.info.TabWidgetChangeEvent import tech.thatgravyboat.skyblockapi.api.location.SkyBlockIsland -import tech.thatgravyboat.skyblockapi.api.profile.CurrencyAPI +import tech.thatgravyboat.skyblockapi.api.profile.currency.CurrencyAPI @Module @ScoreboardElement diff --git a/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementTime.kt b/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementTime.kt index 391d2b3..566da26 100644 --- a/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementTime.kt +++ b/src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/elements/ElementTime.kt @@ -39,14 +39,14 @@ object ElementTime : Element() { if (rawHour >= 12) append("pm") else append("am") } - val (symbol, color) = if (McLevel.hasLevel) { + val (symbol, color) = McLevel.selfOrNull?.let { when { - McLevel.self.isRaining -> "☔" to TextColor.DARK_AQUA - McLevel.self.isThundering -> "⚡" to TextColor.YELLOW + it.isRaining -> "☔" to TextColor.DARK_AQUA + it.isThundering -> "⚡" to TextColor.YELLOW DateTimeAPI.isDay -> "☀" to TextColor.YELLOW else -> "☽" to TextColor.AQUA } - } else "⚠" to TextColor.RED + } ?: ("⚠" to TextColor.RED) append(" $symbol", color) } diff --git a/src/main/kotlin/me/owdding/customscoreboard/utils/ScoreboardOverhaulUtils.kt b/src/main/kotlin/me/owdding/customscoreboard/utils/ScoreboardOverhaulUtils.kt index 85d1c96..978309f 100644 --- a/src/main/kotlin/me/owdding/customscoreboard/utils/ScoreboardOverhaulUtils.kt +++ b/src/main/kotlin/me/owdding/customscoreboard/utils/ScoreboardOverhaulUtils.kt @@ -1,4 +1,5 @@ -package me.owdding.customscoreboard.utils +//? scoreboard_overhaul { +/*package me.owdding.customscoreboard.utils import me.jfenn.scoreboardoverhaul.common.data.ScoreInfo import net.minecraft.network.chat.Component @@ -9,3 +10,4 @@ object ScoreboardOverhaulUtils { fun createInfo(string: String, component: Component, int: Int): ScoreInfo = ScoreInfo(string, component, int) } +*///? } diff --git a/src/main/kotlin/me/owdding/customscoreboard/utils/Utils.kt b/src/main/kotlin/me/owdding/customscoreboard/utils/Utils.kt index c449fc6..207499a 100644 --- a/src/main/kotlin/me/owdding/customscoreboard/utils/Utils.kt +++ b/src/main/kotlin/me/owdding/customscoreboard/utils/Utils.kt @@ -7,12 +7,12 @@ import me.owdding.customscoreboard.feature.customscoreboard.CustomScoreboardRend import me.owdding.ktmodules.AutoCollect import net.minecraft.network.chat.Component import tech.thatgravyboat.skyblockapi.api.profile.effects.EffectsAPI +import tech.thatgravyboat.skyblockapi.utils.extentions.until import tech.thatgravyboat.skyblockapi.utils.regex.component.ComponentRegex import tech.thatgravyboat.skyblockapi.utils.text.Text import tech.thatgravyboat.skyblockapi.utils.text.Text.send import tech.thatgravyboat.skyblockapi.utils.text.TextColor import tech.thatgravyboat.skyblockapi.utils.text.TextProperties.stripped -import tech.thatgravyboat.skyblockapi.utils.time.until import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds diff --git a/src/main/kotlin/me/owdding/customscoreboard/utils/rendering/RenderUtils.kt b/src/main/kotlin/me/owdding/customscoreboard/utils/rendering/RenderUtils.kt index 37e24c7..95b8fd2 100644 --- a/src/main/kotlin/me/owdding/customscoreboard/utils/rendering/RenderUtils.kt +++ b/src/main/kotlin/me/owdding/customscoreboard/utils/rendering/RenderUtils.kt @@ -3,12 +3,12 @@ package me.owdding.customscoreboard.utils.rendering import earth.terrarium.olympus.client.pipelines.RoundedRectangle import earth.terrarium.olympus.client.pipelines.RoundedTexture import me.owdding.customscoreboard.config.categories.BackgroundConfig -import net.minecraft.client.gui.GuiGraphics +import net.minecraft.client.gui.GuiGraphicsExtractor import net.minecraft.resources.Identifier import net.minecraft.util.ARGB object RenderUtils { - fun GuiGraphics.drawRec(x: Int, y: Int, width: Int, height: Int) { + fun GuiGraphicsExtractor.drawRec(x: Int, y: Int, width: Int, height: Int) { with(BackgroundConfig) { if (imageBackground) { @@ -40,7 +40,7 @@ object RenderUtils { } } - fun GuiGraphics.drawTexture( + fun GuiGraphicsExtractor.drawTexture( x: Int, y: Int, width: Int, height: Int, texture: Identifier, alpha: Float = 1f, ) { diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 7d582d8..c53f082 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -18,8 +18,8 @@ }, "depends": { "fabricloader": ">=0.16.10", - "minecraft": ">=${minecraft_start} <=${minecraft_end}", - "fabric": "*", + "minecraft": "${minecraft_range}", + "fabric-api": "*", "fabric-language-kotlin": ">=${fabric_lang_kotlin}", "resourcefullib": ">=${rlib}", "olympus": ">=${olympus}", diff --git a/stonecutter.gradle.kts b/stonecutter.gradle.kts index eb5622e..3fd370d 100644 --- a/stonecutter.gradle.kts +++ b/stonecutter.gradle.kts @@ -1,9 +1,8 @@ plugins { id("dev.kikugie.stonecutter") - id("fabric-loom") version "1.14-SNAPSHOT" apply false } -stonecutter active "1.21.11" +stonecutter active "26.1" stonecutter parameters { swaps["mod_version"] = "\"" + property("version") + "\";" @@ -12,30 +11,30 @@ stonecutter parameters { direction = eval(current.version, "> 1.21.5") replace("// moj_import <", "//!moj_import <") } + stonecutter.versions.forEach { (_, v) -> + constants["scoreboard_overhaul"] = versionCatalogs.named("libs" + v.replace(".", "")).findLibrary("scoreboard.overhaul").isPresent + } filters.include("**/*.fsh", "**/*.vsh") Replacements.read(project).replacements.forEach { (name, replacement) -> when (replacement) { - is StringReplacement if replacement.named -> replacements.string(name) { - direction = eval(current.version, replacement.condition) - replace(replacement.from, replacement.to) - } - - is RegexReplacement if replacement.named -> replacements.regex(name) { - direction = eval(current.version, replacement.condition) - replace(replacement.regex, replacement.to) - reverse(replacement.reverseRegex, replacement.reverse) - } - is StringReplacement -> replacements.string { + if (replacement.named) { + id = name + } direction = eval(current.version, replacement.condition) replace(replacement.from, replacement.to) } is RegexReplacement -> replacements.regex { + if (replacement.named) { + id = name + } direction = eval(current.version, replacement.condition) - replace(replacement.regex, replacement.to) - reverse(replacement.reverseRegex, replacement.reverse) + replace( + replacement.regex to replacement.to, + replacement.reverseRegex to replacement.reverse + ) } } }