From 6fff4737d748f11c36e70d41cd5b54299d5a23bd Mon Sep 17 00:00:00 2001 From: isxander Date: Fri, 5 Apr 2024 20:30:26 +0200 Subject: [PATCH] Move to stonecutter to support 1.20.1 as well as 1.20.4 --- .gitignore | 4 +- build.gradle.kts | 306 +++++++++++------- gradle.properties | 9 + gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle.kts | 18 +- .../mixins/spyglass/SpyglassItemMixin.java | 2 +- ...MouseMixin.java => MouseHandlerMixin.java} | 14 +- .../kotlin/dev/isxander/zoomify/Zoomify.kt | 17 +- .../zoomify/config/SettingsGuiFactory.kt | 34 +- .../isxander/zoomify/utils/MinecraftExt.kt | 21 ++ src/main/resources/fabric.mod.json | 6 +- src/main/resources/zoomify.mixins.json | 2 +- stonecutter.gradle.kts | 14 + versions/1.20.1/gradle.properties | 8 + versions/1.20.4/gradle.properties | 8 + 15 files changed, 306 insertions(+), 159 deletions(-) rename src/main/java/dev/isxander/zoomify/mixins/zoom/{MouseMixin.java => MouseHandlerMixin.java} (89%) create mode 100644 stonecutter.gradle.kts create mode 100644 versions/1.20.1/gradle.properties create mode 100644 versions/1.20.4/gradle.properties diff --git a/.gitignore b/.gitignore index bfeafdb..604f932 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ /.idea -/.gradle -/build +.gradle +build /run !*/.gitkeep /.fleet diff --git a/build.gradle.kts b/build.gradle.kts index a0ccba6..18e74f8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,172 +1,222 @@ plugins { java - alias(libs.plugins.kotlin.jvm) - alias(libs.plugins.kotlin.plugin.serialization) + kotlin("jvm") version "1.9.23" + kotlin("plugin.serialization") version "1.9.23" - alias(libs.plugins.loom) + id("fabric-loom") version "1.6.+" - id("com.modrinth.minotaur") version "2.7.+" - id("me.hypherionmc.cursegradle") version "2.+" - id("com.github.breadmoirai.github-release") version "2.4.+" + id("me.modmuss50.mod-publish-plugin") version "0.5.+" `maven-publish` - id("io.github.p03w.machete") version "2.0.+" + id("io.github.p03w.machete") version "2.+" + id("org.ajoberstar.grgit") version "5.0.+" } +val mcVersion = stonecutter.current.version +val mcDep = property("fmj.mcDep").toString() + group = "dev.isxander" -version = "2.13.2" +val versionWithoutMC = "2.14.0" +version = "$versionWithoutMC+${stonecutter.current.project}" +val isAlpha = "alpha" in version.toString() +val isBeta = "beta" in version.toString() + +base { + archivesName.set(property("modName").toString()) +} + +stonecutter.expression { + when (it) { + "controlify" -> isPropDefined("deps.controlify") + "mod-menu" -> isPropDefined("deps.modMenu") + else -> null + } +} + +loom { + if (stonecutter.current.isActive) { + runConfigs.all { + ideConfigGenerated(true) + runDir("../../run") + } + } + + mixin { + useLegacyMixinAp.set(false) + } +} repositories { mavenCentral() + maven("https://maven.terraformersmc.com") maven("https://maven.isxander.dev/releases") maven("https://maven.isxander.dev/snapshots") - maven("https://maven.shedaniel.me/") - maven("https://maven.terraformersmc.com/releases") - maven("https://jitpack.io") - maven("https://api.modrinth.com/maven") - maven("https://maven.quiltmc.org/repository/release/") + maven("https://maven.quiltmc.org/repository/release") maven("https://oss.sonatype.org/content/repositories/snapshots/") + maven("https://api.modrinth.com/maven") { + content { + includeGroup("maven.modrinth") + } + } } dependencies { - minecraft(libs.minecraft) + minecraft("com.mojang:minecraft:$mcVersion") + mappings(loom.layered { - val quiltMappings = libs.versions.quilt.mappings.get() - if (quiltMappings != "0") - mappings("org.quiltmc:quilt-mappings:${libs.versions.minecraft.get()}+build.$quiltMappings:intermediary-v2") + optionalProp("deps.quiltMappings") { + mappings("org.quiltmc:quilt-mappings:$mcVersion+build.$it:intermediary-v2") + } officialMojangMappings() }) - modImplementation(libs.fabric.loader) - modImplementation(libs.fabric.api) - modImplementation(libs.fabric.language.kotlin) + modImplementation("net.fabricmc:fabric-loader:${property("deps.fabricLoader")}") - implementation(libs.ktoml.core) - include(libs.ktoml.core) - - modApi(libs.yet.another.config.lib) + val fapiVersion = property("deps.fabricApi").toString() + listOf( + "fabric-resource-loader-v0", + "fabric-lifecycle-events-v1", + "fabric-key-binding-api-v1", + "fabric-command-api-v2", + ).forEach { + modImplementation(fabricApi.module(it, fapiVersion)) + } + modRuntimeOnly("net.fabricmc.fabric-api:fabric-api:$fapiVersion") + modImplementation("net.fabricmc:fabric-language-kotlin:${property("deps.flk")}") - implementation(libs.bundles.settxi) - include(libs.bundles.settxi) + modApi("dev.isxander.yacl:yet-another-config-lib-fabric:${property("deps.yacl")}") { + exclude(group = "net.fabricmc.fabric-api", module = "fabric-api") + } - modImplementation(libs.mod.menu) + optionalProp("deps.modMenu") { + modImplementation("com.terraformersmc:modmenu:$it") + } - modImplementation(libs.controlify) + optionalProp("deps.controlify") { + modImplementation("dev.isxander:controlify:$it") + } - libs.mixin.extras.let { - implementation(it) - annotationProcessor(it) - include(it) + listOf( + "settxi-core", + "settxi-kotlinx-serialization" + ).forEach { + implementation("dev.isxander.settxi:$it:${property("deps.settxi")}") + include("dev.isxander.settxi:$it:${property("deps.settxi")}") } + + implementation("com.akuleshov7:ktoml-core-jvm:${property("deps.ktoml")}") } java { withSourcesJar() + withJavadocJar() } tasks { - withType { - options.release.set(17) - } - - withType { - kotlinOptions { - jvmTarget = "17" + processResources { + val props = mutableMapOf( + "id" to findProperty("modId"), + "group" to project.group, + "name" to findProperty("modName"), + "description" to findProperty("modDescription"), + "version" to project.version, + "github" to findProperty("githubProject"), + "mc" to mcDep + ) + optionalProp("fmj.yaclDep") { + props["yacl"] = it } - } - processResources { - inputs.property("version", project.version) + props.forEach(inputs::property) + filesMatching("fabric.mod.json") { - expand( - "version" to project.version - ) + expand(props) } } register("releaseMod") { group = "mod" - dependsOn("modrinth") - dependsOn("modrinthSyncBody") - dependsOn("curseforge") - dependsOn("githubRelease") + dependsOn("publishMods") dependsOn("publish") } } -val changelogText = file("changelogs/${project.version}.md").takeIf { it.exists() }?.readText() ?: "No changelog provided" - -val modrinthId: String by project -if (modrinthId.isNotEmpty()) { - modrinth { - token.set(findProperty("modrinth.token")?.toString()) - projectId.set(modrinthId) - versionNumber.set("${project.version}") - versionType.set("release") - uploadFile.set(tasks["remapJar"]) - gameVersions.set(listOf("1.20.3", "1.20.2")) - loaders.set(listOf("fabric", "quilt")) - changelog.set(changelogText) - syncBodyFrom.set(file("README.md").readText()) - dependencies { - required.project("fabric-api") - required.project("fabric-language-kotlin") - required.project("yacl") - optional.project("modmenu") - } - } +machete { + json.enabled.set(false) } -val curseforgeId: String by project -if (hasProperty("curseforge.token") && curseforgeId.isNotEmpty()) { - curseforge { - apiKey = findProperty("curseforge.token") - project(closureOf { - mainArtifact(tasks["remapJar"], closureOf { - displayName = "${project.version}" - }) - - id = curseforgeId - releaseType = "release" - addGameVersion("1.20.3") - addGameVersion("1.20.2") - addGameVersion("Fabric") - addGameVersion("Quilt") - addGameVersion("Java 17") - - relations(closureOf { - requiredDependency("fabric-api") - requiredDependency("fabric-language-kotlin") - requiredDependency("yacl") - optionalDependency("modmenu") - }) - - changelog = changelogText - changelogType = "markdown" - }) - - options(closureOf { - forgeGradleIntegration = false - }) +publishMods { + displayName.set("Zoomify $versionWithoutMC for MC $mcVersion") + file.set(tasks.remapJar.get().archiveFile) + changelog.set( + rootProject.file("changelogs/${versionWithoutMC}.md") + .takeIf { it.exists() } + ?.readText() + ?: "No changelog provided." + ) + type.set(when { + isAlpha -> ALPHA + isBeta -> BETA + else -> STABLE + }) + modLoaders.add("fabric") + + // modrinth and curseforge use different formats for snapshots. this can be expressed globally + val stableMCVersions = listOf(stonecutter.current.project) + + val modrinthId: String by project + if (modrinthId.isNotBlank() && hasProperty("modrinth.token")) { + modrinth { + projectId.set(modrinthId) + accessToken.set(findProperty("modrinth.token")?.toString()) + minecraftVersions.addAll(stableMCVersions) + + requires { slug.set("fabric-api") } + requires { slug.set("yacl") } + optional { slug.set("modmenu") } + optional { slug.set("controlify") } + } + + tasks.getByName("publishModrinth") { + dependsOn("optimizeOutputsOfRemapJar") + } } -} -githubRelease { - token(findProperty("github.token")?.toString()) + val curseforgeId: String by project + if (curseforgeId.isNotBlank() && hasProperty("curseforge.token")) { + curseforge { + projectId.set(curseforgeId) + accessToken.set(findProperty("curseforge.token")?.toString()) + minecraftVersions.addAll(stableMCVersions) + + requires { slug.set("fabric-api") } + requires { slug.set("yacl") } + optional { slug.set("modmenu") } + optional { slug.set("controlify") } + } + + tasks.getByName("publishCurseforge") { + dependsOn("optimizeOutputsOfRemapJar") + } + } val githubProject: String by project - val split = githubProject.split("/") - owner(split[0]) - repo(split[1]) - tagName("${project.version}") - targetCommitish("1.20") - body(changelogText) - releaseAssets(tasks["remapJar"].outputs.files) + if (githubProject.isNotBlank() && hasProperty("github.token")) { + github { + repository.set(githubProject) + accessToken.set(findProperty("github.token")?.toString()) + commitish.set(grgit.branch.current().name) + } + + tasks.getByName("publishGithub") { + dependsOn("optimizeOutputsOfRemapJar") + } + } } publishing { publications { - register("zoomify") { + create("mod") { groupId = "dev.isxander" artifactId = "zoomify" @@ -175,17 +225,33 @@ publishing { } repositories { - if (hasProperty("XANDER_MAVEN_USER") && hasProperty("XANDER_MAVEN_PASS")) { - maven("https://maven.isxander.dev/releases") { + val username = "XANDER_MAVEN_USER".let { System.getenv(it) ?: findProperty(it) }?.toString() + val password = "XANDER_MAVEN_PASS".let { System.getenv(it) ?: findProperty(it) }?.toString() + if (username != null && password != null) { + maven(url = "https://maven.isxander.dev/releases") { + name = "XanderReleases" credentials { - username = findProperty("XANDER_MAVEN_USER")?.toString() - password = findProperty("XANDER_MAVEN_PASS")?.toString() + this.username = username + this.password = password } } - } else println("Cannot publish to https://maven.isxander.dev") + tasks.getByName("publishModPublicationToXanderReleasesRepository") { + dependsOn("optimizeOutputsOfRemapJar") + } + } else { + println("Xander Maven credentials not satisfied.") + } } } -tasks["githubRelease"].dependsOn("optimizeOutputsOfRemapJar") -tasks["modrinth"].dependsOn("optimizeOutputsOfRemapJar") -tasks["generateMetadataFileForZoomifyPublication"].dependsOn("optimizeOutputsOfRemapJar") +tasks.getByName("generateMetadataFileForModPublication") { + dependsOn("optimizeOutputsOfRemapJar") +} + +fun optionalProp(property: String, block: (String) -> T?) { + findProperty(property)?.toString()?.takeUnless { it.isBlank() }?.let(block) +} + +fun isPropDefined(property: String): Boolean { + return property(property)?.toString()?.isNotBlank() ?: false +} diff --git a/gradle.properties b/gradle.properties index 62da2a8..0e365c9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,3 +6,12 @@ systemProp.kotlinVersion=1.8.0 modrinthId=zoomify curseforgeId=574741 githubProject=isXander/Zoomify + +modId=zoomify +modName=Zoomify +modDescription=An advanced zoom key. + +deps.fabricLoader=0.15.9 +deps.flk=1.10.19+kotlin.1.9.23 +deps.settxi=2.10.6 +deps.ktoml=0.5.1 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fce403e..d951fac 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle.kts b/settings.gradle.kts index 796cbdb..f835347 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,15 +1,27 @@ +import dev.kikugie.stonecutter.gradle.StonecutterSettings + pluginManagement { repositories { mavenCentral() gradlePluginPortal() maven("https://maven.fabricmc.net") + maven("https://maven.quiltmc.org/repository/release") + maven("https://maven.kikugie.dev/releases") } } -dependencyResolutionManagement { - versionCatalogs { - create("libs") +plugins { + id("dev.kikugie.stonecutter") version "0.3.2" +} + +extensions.configure { + kotlinController(true) + centralScript("build.gradle.kts") + shared { + versions("1.20.1", "1.20.4") + vcsVersion("1.20.4") } + create(rootProject) } rootProject.name = "Zoomify" diff --git a/src/main/java/dev/isxander/zoomify/mixins/spyglass/SpyglassItemMixin.java b/src/main/java/dev/isxander/zoomify/mixins/spyglass/SpyglassItemMixin.java index 3fdea3e..498c61b 100644 --- a/src/main/java/dev/isxander/zoomify/mixins/spyglass/SpyglassItemMixin.java +++ b/src/main/java/dev/isxander/zoomify/mixins/spyglass/SpyglassItemMixin.java @@ -1,6 +1,6 @@ package dev.isxander.zoomify.mixins.spyglass; -import com.llamalad7.mixinextras.injector.WrapWithCondition; +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; import dev.isxander.zoomify.config.OverlayVisibility; import dev.isxander.zoomify.config.SoundBehaviour; import dev.isxander.zoomify.config.ZoomifySettings; diff --git a/src/main/java/dev/isxander/zoomify/mixins/zoom/MouseMixin.java b/src/main/java/dev/isxander/zoomify/mixins/zoom/MouseHandlerMixin.java similarity index 89% rename from src/main/java/dev/isxander/zoomify/mixins/zoom/MouseMixin.java rename to src/main/java/dev/isxander/zoomify/mixins/zoom/MouseHandlerMixin.java index 1e8b11f..88d96cc 100644 --- a/src/main/java/dev/isxander/zoomify/mixins/zoom/MouseMixin.java +++ b/src/main/java/dev/isxander/zoomify/mixins/zoom/MouseHandlerMixin.java @@ -1,7 +1,6 @@ package dev.isxander.zoomify.mixins.zoom; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import com.llamalad7.mixinextras.sugar.Local; import dev.isxander.zoomify.Zoomify; import dev.isxander.zoomify.config.SpyglassBehaviour; import dev.isxander.zoomify.config.ZoomifySettings; @@ -15,13 +14,22 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(MouseHandler.class) -public class MouseMixin { +public class MouseHandlerMixin { + /*? if <=1.20.1 {*/ + @Shadow + private double accumulatedScroll; + /*?}*/ + @Inject( method = "onScroll", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;isSpectator()Z"), cancellable = true ) - private void scrollStepCounter(CallbackInfo ci, @Local(ordinal = 1) int scrollY) { + private void scrollStepCounter(CallbackInfo ci/*?if >1.20.1 {*//*, @Local(ordinal = 1) int scrollY*//*?}*/) { + /*? if <=1.20.1 {*/ + int scrollY = (int) this.accumulatedScroll; + /*?}*/ + if (ZoomifySettings.INSTANCE.getScrollZoom() && Zoomify.INSTANCE.getZooming() && scrollY != 0 && !ZoomifySettings.INSTANCE.getKeybindScrolling()) { Zoomify.mouseZoom(scrollY); ci.cancel(); diff --git a/src/main/kotlin/dev/isxander/zoomify/Zoomify.kt b/src/main/kotlin/dev/isxander/zoomify/Zoomify.kt index cc8fd8d..7157b28 100644 --- a/src/main/kotlin/dev/isxander/zoomify/Zoomify.kt +++ b/src/main/kotlin/dev/isxander/zoomify/Zoomify.kt @@ -4,6 +4,7 @@ import com.mojang.blaze3d.platform.InputConstants import dev.isxander.zoomify.config.* import dev.isxander.zoomify.config.migrator.Migrator import dev.isxander.zoomify.integrations.constrainModVersionIfLoaded +import dev.isxander.zoomify.utils.toast import dev.isxander.zoomify.zoom.* import net.fabricmc.api.ClientModInitializer import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal @@ -232,15 +233,13 @@ object Zoomify : ClientModInitializer { if (key != zoomKey && key.equals(zoomKey)) { minecraft.options.setKey(key, InputConstants.UNKNOWN) - val toast = SystemToast.multiline( - minecraft, - SystemToast.SystemToastId.PERIODIC_NOTIFICATION, // doesn't do anything except toast duration + toast( Component.translatable("zoomify.toast.unbindConflicting.name"), Component.translatable("zoomify.toast.unbindConflicting.description", Component.translatable(key.name) - ) + ), + longer = false ) - minecraft.toasts.addToast(toast) return true } @@ -257,15 +256,13 @@ object Zoomify : ClientModInitializer { return if (minecraft.options.keyMappings.any { it != zoomKey && it.equals(zoomKey) }) { - val toast = SystemToast.multiline( - minecraft, - SystemToast.SystemToastId.UNSECURE_SERVER_WARNING, + toast( Component.translatable("zoomify.toast.conflictingKeybind.title"), Component.translatable("zoomify.toast.conflictingKeybind.description", Component.translatable("zoomify.gui.category.misc") - ) + ), + longer = true ) - minecraft.toasts.addToast(toast) } } } diff --git a/src/main/kotlin/dev/isxander/zoomify/config/SettingsGuiFactory.kt b/src/main/kotlin/dev/isxander/zoomify/config/SettingsGuiFactory.kt index b44954b..d80cf0b 100644 --- a/src/main/kotlin/dev/isxander/zoomify/config/SettingsGuiFactory.kt +++ b/src/main/kotlin/dev/isxander/zoomify/config/SettingsGuiFactory.kt @@ -14,6 +14,7 @@ import dev.isxander.zoomify.config.demo.ThirdPersonDemo import dev.isxander.zoomify.config.demo.ZoomDemoImageRenderer import dev.isxander.zoomify.config.migrator.Migrator import dev.isxander.zoomify.utils.TransitionType +import dev.isxander.zoomify.utils.toast import dev.isxander.zoomify.zoom.* import net.minecraft.ChatFormatting import net.minecraft.client.Minecraft @@ -261,7 +262,7 @@ fun createSettingsGui(parent: Screen? = null): Screen { option(Option.createBuilder().apply { useSettxiName(ZoomifySettings::spyglassBehaviour) - description(OptionDescription.of(Component.translatable(ZoomifySettings::spyglassBehaviour.setting.description))) + description(OptionDescription.of(Component.translatable(ZoomifySettings::spyglassBehaviour.setting.description!!))) bindSetting(ZoomifySettings::spyglassBehaviour) controller { opt -> EnumControllerBuilder.create(opt).apply { enumClass(SpyglassBehaviour::class.java) @@ -272,7 +273,7 @@ fun createSettingsGui(parent: Screen? = null): Screen { option(Option.createBuilder().apply { useSettxiName(ZoomifySettings::spyglassOverlayVisibility) desc { - text(Component.translatable(ZoomifySettings::spyglassOverlayVisibility.setting.description)) + text(Component.translatable(ZoomifySettings::spyglassOverlayVisibility.setting.description!!)) } bindSetting(ZoomifySettings::spyglassOverlayVisibility) controller { opt -> EnumControllerBuilder.create(opt).apply { @@ -284,7 +285,7 @@ fun createSettingsGui(parent: Screen? = null): Screen { option(Option.createBuilder().apply { useSettxiName(ZoomifySettings::spyglassSoundBehaviour) desc { - text(Component.translatable(ZoomifySettings::spyglassSoundBehaviour.setting.description)) + text(Component.translatable(ZoomifySettings::spyglassSoundBehaviour.setting.description!!)) } bindSetting(ZoomifySettings::spyglassSoundBehaviour) controller { opt -> EnumControllerBuilder.create(opt).apply { @@ -301,7 +302,7 @@ fun createSettingsGui(parent: Screen? = null): Screen { option(Option.createBuilder().apply { useSettxiName(ZoomifySettings::zoomKeyBehaviour) desc { - text(Component.translatable(ZoomifySettings::zoomKeyBehaviour.setting.description)) + text(Component.translatable(ZoomifySettings::zoomKeyBehaviour.setting.description!!)) } bindSetting(ZoomifySettings::zoomKeyBehaviour) controller { opt -> EnumControllerBuilder.create(opt).apply { @@ -313,7 +314,7 @@ fun createSettingsGui(parent: Screen? = null): Screen { option(Option.createBuilder().apply { useSettxiName(ZoomifySettings::_keybindScrolling) desc { - text(Component.translatable(ZoomifySettings::_keybindScrolling.setting.description)) + text(Component.translatable(ZoomifySettings::_keybindScrolling.setting.description!!)) } bindSetting(ZoomifySettings::_keybindScrolling) controller(TickBoxControllerBuilder::create) @@ -323,7 +324,7 @@ fun createSettingsGui(parent: Screen? = null): Screen { option(Option.createBuilder().apply { useSettxiName(ZoomifySettings::relativeSensitivity) desc { - text(Component.translatable(ZoomifySettings::relativeSensitivity.setting.description)) + text(Component.translatable(ZoomifySettings::relativeSensitivity.setting.description!!)) } bindSetting(ZoomifySettings::relativeSensitivity) controller { opt -> IntegerSliderControllerBuilder.create(opt).apply { @@ -341,7 +342,7 @@ fun createSettingsGui(parent: Screen? = null): Screen { option(Option.createBuilder().apply { useSettxiName(ZoomifySettings::relativeViewBobbing) desc { - text(Component.translatable(ZoomifySettings::relativeViewBobbing.setting.description)) + text(Component.translatable(ZoomifySettings::relativeViewBobbing.setting.description!!)) } bindSetting(ZoomifySettings::relativeViewBobbing) controller(TickBoxControllerBuilder::create) @@ -350,7 +351,7 @@ fun createSettingsGui(parent: Screen? = null): Screen { option(Option.createBuilder().apply { useSettxiName(ZoomifySettings::cinematicCamera) desc { - text(Component.translatable(ZoomifySettings::cinematicCamera.setting.description)) + text(Component.translatable(ZoomifySettings::cinematicCamera.setting.description!!)) } bindSetting(ZoomifySettings::cinematicCamera) controller { opt -> IntegerSliderControllerBuilder.create(opt).apply { @@ -449,13 +450,11 @@ fun createSettingsGui(parent: Screen? = null): Screen { action { _, _ -> if (!Migrator.checkMigrations()) { - val minecraft = Minecraft.getInstance() - minecraft.toasts.addToast(SystemToast.multiline( - minecraft, - SystemToast.SystemToastId.PERIODIC_NOTIFICATION, + toast( Component.translatable("zoomify.gui.title"), - Component.translatable("zoomify.migrate.no_migrations") - )) + Component.translatable("zoomify.migrate.no_migrations"), + longer = false + ) } } }.build()) @@ -472,7 +471,12 @@ fun createSettingsGui(parent: Screen? = null): Screen { action { screen, _ -> val minecraft = Minecraft.getInstance() preset.apply(ZoomifySettings) - minecraft.toasts.addToast(SystemToast.multiline(minecraft, SystemToast.SystemToastId.PERIODIC_NOTIFICATION, Component.translatable("zoomify.gui.preset.toast.title"), Component.translatable("zoomify.gui.preset.toast.description", Component.translatable(preset.displayName)))) + toast( + Component.translatable("zoomify.gui.preset.toast.title"), + Component.translatable("zoomify.gui.preset.toast.description", + Component.translatable(preset.displayName) + ) + ) OptionUtils.forEachOptions(screen.config, Option<*>::forgetPendingValue) ZoomifySettings.export() diff --git a/src/main/kotlin/dev/isxander/zoomify/utils/MinecraftExt.kt b/src/main/kotlin/dev/isxander/zoomify/utils/MinecraftExt.kt index f01e6ee..5dfbf20 100644 --- a/src/main/kotlin/dev/isxander/zoomify/utils/MinecraftExt.kt +++ b/src/main/kotlin/dev/isxander/zoomify/utils/MinecraftExt.kt @@ -1,9 +1,30 @@ package dev.isxander.zoomify.utils +import net.minecraft.client.Minecraft import net.minecraft.client.gui.GuiGraphics +import net.minecraft.client.gui.components.toasts.SystemToast +import net.minecraft.network.chat.Component + +val minecraft: Minecraft + get() = Minecraft.getInstance() fun GuiGraphics.pushPose() = pose().pushPose() fun GuiGraphics.popPose() = pose().popPose() fun GuiGraphics.translate(x: Double, y: Double, z: Double) = pose().translate(x, y, z) fun GuiGraphics.translate(x: Float, y: Float, z: Float) = pose().translate(x, y, z) fun GuiGraphics.scale(x: Float, y: Float, z: Float) = pose().scale(x, y, z) + +fun toast(title: Component, description: Component, longer: Boolean = false) { + SystemToast.multiline( + minecraft, + /*? if >=1.20.4 {*//* + if (longer) SystemToast.SystemToastId.UNSECURE_SERVER_WARNING + else SystemToast.SystemToastId.PERIODIC_NOTIFICATION, + *//*?} else {*/ + if (longer) SystemToast.SystemToastIds.UNSECURE_SERVER_WARNING + else SystemToast.SystemToastIds.PERIODIC_NOTIFICATION, + /*?}*/ + title, + description, + ).also { minecraft.toasts.addToast(it) } +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index f82fa39..3888f20 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -43,11 +43,11 @@ ], "depends": { "fabric-api": "*", - "fabricloader": ">=0.14.22", + "fabricloader": ">=0.15.0", "fabric-language-kotlin": ">=1.10.10+kotlin.1.9.10", - "minecraft": "~1.20.2", + "minecraft": "${mc}", "java": ">=17", - "yet_another_config_lib_v3": ">=3.2.1+1.20.2" + "yet_another_config_lib_v3": "${yacl}" }, "suggests": { "modmenu": ">=4.0.0" diff --git a/src/main/resources/zoomify.mixins.json b/src/main/resources/zoomify.mixins.json index d4c63fa..d0a5a8b 100644 --- a/src/main/resources/zoomify.mixins.json +++ b/src/main/resources/zoomify.mixins.json @@ -11,7 +11,7 @@ "spyglass.InGameHudMixin", "spyglass.SpyglassItemMixin", "zoom.GameRendererMixin", - "zoom.MouseMixin", + "zoom.MouseHandlerMixin", "zoom.secondary.GameRendererMixin" ] } diff --git a/stonecutter.gradle.kts b/stonecutter.gradle.kts new file mode 100644 index 0000000..bcaa352 --- /dev/null +++ b/stonecutter.gradle.kts @@ -0,0 +1,14 @@ +plugins { + id("dev.kikugie.stonecutter") +} +stonecutter active "1.20.1" /* [SC] DO NOT EDIT */ + +stonecutter registerChiseled tasks.register("chiseledBuild", stonecutter.chiseled) { + group = "mod" + ofTask("build") +} + +stonecutter registerChiseled tasks.register("chiseledReleaseMod", stonecutter.chiseled) { + group = "mod" + ofTask("releaseMod") +} diff --git a/versions/1.20.1/gradle.properties b/versions/1.20.1/gradle.properties new file mode 100644 index 0000000..987c23b --- /dev/null +++ b/versions/1.20.1/gradle.properties @@ -0,0 +1,8 @@ +deps.fabricApi=0.92.0+1.20.1 +deps.quiltMappings=23 +deps.yacl=3.2.2+1.20 +deps.modMenu=7.2.2 +deps.controlify=2.0.0-beta.3+1.20.1 + +fmj.mcDep=1.20.1 +fmj.yaclDep=>=3.2.1 diff --git a/versions/1.20.4/gradle.properties b/versions/1.20.4/gradle.properties new file mode 100644 index 0000000..b3d7d9b --- /dev/null +++ b/versions/1.20.4/gradle.properties @@ -0,0 +1,8 @@ +deps.fabricApi=0.96.11+1.20.4 +deps.quiltMappings=3 +deps.yacl=3.3.2+1.20.4 +deps.modMenu=9.0.0 +deps.controlify=2.0.0-beta.3+1.20.4 + +fmj.mcDep=1.20.4 +fmj.yaclDep=>=3.2.1