From d7d0eef4189435604822b9c82a5abc4158ef18b2 Mon Sep 17 00:00:00 2001 From: Yedelo <158670400+yedelo@users.noreply.github.com> Date: Sun, 13 Sep 2026 20:32:18 -0400 Subject: [PATCH] Port to ornithe (initial) --- .github/workflows/build.yml | 53 --- .github/workflows/gradle.yml | 69 ++++ .github/workflows/mod_project_integration.yml | 17 +- README.md | 2 +- build.gradle.kts | 354 ++++++++++-------- gradle.properties | 15 +- gradle/wrapper/gradle-wrapper.properties | 2 +- root.gradle.kts | 13 - settings.gradle.kts | 48 +-- .../mixin/ForgeHooksClientMixin.java | 28 -- ...yRendererMixin_HandleCameraTransforms.java | 23 ++ ...mRendererMixin_HandleCameraTransforms.java | 29 ++ .../mixin/LayerArmorBaseMixin.java | 12 +- .../RenderItemMixin_GlintCustomizer.java | 16 +- .../mixin/accessor/RenderItemAccessor.java | 5 +- .../mixin/oneconfig/ConfigMixin.java | 97 ----- .../glintcolorizer/GlintColorizer.kt | 36 +- .../glintcolorizer/command/GlintCommand.kt | 14 +- .../glintcolorizer/config/GlintConfig.kt | 148 +++----- .../config/GlintEffectOptions.kt | 87 ++--- .../config/annotation/ColorEntry.kt | 4 - .../handler/SecondGlintHandler.kt | 4 +- .../glintcolorizer}/glintcolorizer_dark.svg | 0 src/main/resources/fabric.mod.json | 34 ++ src/main/resources/mcmod.info | 18 - src/main/resources/mixins.glintcolorizer.json | 15 +- stonecutter.gradle.kts | 48 +++ stonecutter.properties.toml | 22 ++ versions/1.12.2-1.8.9.txt | 2 - versions/1.17.1-fabric/gradle.properties | 3 - versions/1.17.1-forge/gradle.properties | 0 versions/1.18.1-fabric/gradle.properties | 3 - versions/mainProject | 1 - 33 files changed, 590 insertions(+), 632 deletions(-) delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/gradle.yml delete mode 100644 root.gradle.kts delete mode 100644 src/main/java/org/polyfrost/glintcolorizer/mixin/ForgeHooksClientMixin.java create mode 100644 src/main/java/org/polyfrost/glintcolorizer/mixin/ItemEntityRendererMixin_HandleCameraTransforms.java create mode 100644 src/main/java/org/polyfrost/glintcolorizer/mixin/ItemRendererMixin_HandleCameraTransforms.java delete mode 100644 src/main/java/org/polyfrost/glintcolorizer/mixin/oneconfig/ConfigMixin.java delete mode 100644 src/main/kotlin/org/polyfrost/glintcolorizer/config/annotation/ColorEntry.kt rename src/main/resources/{ => assets/glintcolorizer}/glintcolorizer_dark.svg (100%) create mode 100644 src/main/resources/fabric.mod.json delete mode 100644 src/main/resources/mcmod.info create mode 100644 stonecutter.gradle.kts create mode 100644 stonecutter.properties.toml delete mode 100644 versions/1.12.2-1.8.9.txt delete mode 100644 versions/1.17.1-fabric/gradle.properties delete mode 100644 versions/1.17.1-forge/gradle.properties delete mode 100644 versions/1.18.1-fabric/gradle.properties delete mode 100644 versions/mainProject diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index c33133f..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,53 +0,0 @@ -# Build Workflow - -name: Build - -on: - pull_request: - workflow_dispatch: - push: - -concurrency: - group: ${{ github.head_ref || format('{0}-{1}', github.ref, github.run_number) }} - cancel-in-progress: true - -jobs: - build: - name: Build - - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up JDK 17 - uses: actions/setup-java@v2 - with: - java-version: 17 - distribution: temurin - cache: 'gradle' - - - uses: actions/cache@v2 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - **/loom-cache - **/prebundled-jars - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- - - name: Chmod Gradle - run: chmod +x ./gradlew - - - name: Build - run: ./gradlew build --no-daemon - - - name: Upload Build Artifacts - uses: actions/upload-artifact@v2 - with: - name: artifacts - path: versions/**/build/libs/ \ No newline at end of file diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 0000000..7dc6801 --- /dev/null +++ b/.github/workflows/gradle.yml @@ -0,0 +1,69 @@ +name: Build with Gradle + +on: + push: + branches: '*' + paths-ignore: + - 'README.md' + - 'LICENSE' + - '.gitignore' + pull_request: + branches: '*' + paths-ignore: + - 'README.md' + - 'LICENSE' + - '.gitignore' + workflow_dispatch: + +permissions: + contents: read + +concurrency: + # Maximum of one running workflow per pull request source branch or pushed branch + group: ${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + build: + name: "Build ${{ matrix.version }}" + runs-on: "ubuntu-latest" + strategy: + fail-fast: false + matrix: + version: ["1.8.9"] + + steps: + - uses: actions/checkout@v6 + + - uses: actions/setup-java@v5 + with: + distribution: "temurin" + java-version: | + 21 + 25 + + - uses: gradle/actions/setup-gradle@v5 + + - run: chmod +x ./gradlew + - name: Build Stonecutter version + run: | + ./gradlew ":${{ matrix.version }}:build" + + - name: Resolve built mod jar + id: mod-jar + run: | + mapfile -t jars < <(find "versions/${{ matrix.version }}/build/libs" -maxdepth 1 -type f -name '*.jar' ! -name '*-sources.jar' ! -name '*-dev.jar' | sort) + + if [ "${#jars[@]}" -ne 1 ]; then + printf 'Expected exactly one non-sources jar, found %s:\n' "${#jars[@]}" + printf '%s\n' "${jars[@]}" + exit 1 + fi + + echo "path=${jars[0]}" >> "$GITHUB_OUTPUT" + + - name: Upload built mod jar + uses: actions/upload-artifact@v7 + with: + path: ${{ steps.mod-jar.outputs.path }} + archive: false \ No newline at end of file diff --git a/.github/workflows/mod_project_integration.yml b/.github/workflows/mod_project_integration.yml index ddd613b..22b8259 100644 --- a/.github/workflows/mod_project_integration.yml +++ b/.github/workflows/mod_project_integration.yml @@ -6,12 +6,25 @@ on: pull_request: types: [opened] +permissions: + contents: read + issues: read + pull-requests: read + jobs: add-to-project: name: Add issue/PR to project runs-on: ubuntu-latest + env: + ADD_TO_PROJECT_PAT: ${{ secrets.ADD_TO_PROJECT_PAT }} steps: - - uses: actions/add-to-project@v1.0.2 + - name: Add issue/PR to project + if: ${{ env.ADD_TO_PROJECT_PAT != '' }} + uses: actions/add-to-project@v2 with: project-url: https://github.com/orgs/Polyfrost/projects/9 - github-token: ${{ secrets.ADD_TO_PROJECT_PAT }} \ No newline at end of file + github-token: ${{ env.ADD_TO_PROJECT_PAT }} + + - name: Skip project automation without token + if: ${{ env.ADD_TO_PROJECT_PAT == '' }} + run: echo "ADD_TO_PROJECT_PAT is not configured; skipping project automation." \ No newline at end of file diff --git a/README.md b/README.md index dbe4d1b..3f6e93d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -GlintColorizer Icon +GlintColorizer Icon # GlintColorizer diff --git a/build.gradle.kts b/build.gradle.kts index eb0b2d8..33a4310 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,193 +1,239 @@ -@file:Suppress("UnstableApiUsage", "PropertyName") +import org.gradle.api.tasks.testing.logging.TestExceptionFormat +import net.ornithemc.ploceus.api.PloceusGradleExtensionApi +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import org.polyfrost.gradle.util.noServerRunConfigs -import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar - -// Adds support for kotlin, and adds the Polyfrost Gradle Toolkit -// which we use to prepare the environment. plugins { - kotlin("jvm") - id("org.polyfrost.multi-version") - id("org.polyfrost.defaults.repo") - id("org.polyfrost.defaults.java") - id("org.polyfrost.defaults.loom") - id("com.github.johnrengelman.shadow") - id("net.kyori.blossom") version "1.3.2" - id("signing") - java + id("dev.kikugie.loom-back-compat") + id("org.jetbrains.kotlin.jvm") version "2.4.10" + id("net.fabricmc.fabric-loom-remap") version "1.17-SNAPSHOT" apply false + id("ploceus") version "1.17.4" apply false + id("dev.deftu.gradle.bloom") version "0.2.0" + id("me.modmuss50.mod-publish-plugin") version "2.2.0" } -// Gets the mod name, version and id from the `gradle.properties` file. -val mod_name: String by project -val mod_version: String by project -val mod_id: String by project -val mod_archives_name: String by project +val isOrnithe = stonecutter.current.version == "1.8.9" +val ploceus = if (isOrnithe) { + pluginManager.apply("net.fabricmc.fabric-loom-remap") + pluginManager.apply("ploceus") + configurations.configureEach { + exclude(group = "org.lwjgl.lwjgl") + } -// Replaces the variables in `ExampleMod.java` to the ones specified in `gradle.properties`. -blossom { - replaceToken("@VER@", mod_version) - replaceToken("@NAME@", mod_name) - replaceToken("@ID@", mod_id) + extensions.getByType().apply { + setIntermediaryGeneration(2) + } +} else { + null } -// Sets the mod version to the one specified in `gradle.properties`. Make sure to change this following semver! -version = mod_version -// Sets the group, make sure to change this to your own. It can be a website you own backwards or your GitHub username. -// e.g. com.github. or com. -group = "org.polyfrost" +val modid: String = sc.properties["mod.id"] +val modname: String = sc.properties["mod.name"] +val modversion: String = sc.properties["mod.version"] +val moddescription: String = sc.properties["mod.description"] +val license: String = sc.properties["license"] +val mcversion: String = sc.current.version +val versionrange: String = sc.properties["mod.mc_compat"] +val loaderversion: String = sc.properties["deps.fabric_loader"] +val oneconfigversion: String = sc.properties["deps.oneconfig"] +val loader = if (isOrnithe) "ornithe" else "fabric" -// Sets the name of the output jar (the one you put in your mods folder and send to other people) -// It outputs all versions of the mod into the `build` directory. -base { - archivesName.set("$mod_archives_name-$platform") -} +version = "$modversion+$mcversion" +base.archivesName = modid -// Configures the Polyfrost Loom, our plugin fork to easily set up the programming environment. -loom { - // Removes the server configs from IntelliJ IDEA, leaving only client runs. - // If you're developing a server-side mod, you can remove this line. - noServerRunConfigs() - - // Adds the tweak class if we are building legacy version of forge as per the documentation (https://docs.polyfrost.org) - if (project.platform.isLegacyForge) { - runConfigs { - "client" { - programArgs("--tweakClass", "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker") - property("mixin.debug.export", "true") - } - } +val requiredJava = JavaVersion.VERSION_25 + +val compatibleVersions: List = sc.properties.rawOrNull("mod", "mc_releases") + ?.asList().orEmpty().map { it.toString() } + +repositories { + fun strictMaven(url: String, alias: String, vararg groups: String) = exclusiveContent { + forRepository { maven(url) { name = alias } } + filter { groups.forEach(::includeGroup) } } - // Configures the mixins if we are building for forge, useful for when we are dealing with cross-platform projects. - if (project.platform.isForge) { - forge { - mixinConfig("mixins.${mod_id}.json") - } + + mavenCentral() + google() + maven("https://repo.polyfrost.org/releases") { name = "Polyfrost Releases" } + maven("https://repo.polyfrost.org/snapshots") { name = "Polyfrost Snapshots" } + maven("https://central.sonatype.com/repository/maven-snapshots") { + name = "Sonatype Snapshots" + content { includeGroup("net.kyori") } } - // Configures the name of the mixin "refmap" using an experimental loom api. - mixin.defaultRefmapName.set("mixins.${mod_id}.refmap.json") + maven("https://maven.cloverclient.com/releases") { + content { includeGroup("pl.tomgirl") } + } + strictMaven("https://maven.deftu.dev/releases", "Deftu", "dev.deftu") + strictMaven("https://maven.terraformersmc.com/", "TerraformersMC", "com.terraformersmc") + strictMaven("https://maven.fabricmc.net/", "FabricMC", "net.fabricmc") + strictMaven("https://www.cursemaven.com", "CurseForge", "curse.maven") + strictMaven("https://api.modrinth.com/maven", "Modrinth", "maven.modrinth") } -// Creates the shade/shadow configuration, so we can include libraries inside our mod, rather than having to add them separately. -val shade: Configuration by configurations.creating { - configurations.implementation.get().extendsFrom(this) +dependencies { + minecraft("com.mojang:minecraft:$mcversion") + if (isOrnithe) { + mappings(ploceus!!.mcpMappings("stable", "1.8.9", "22")) + implementation("net.ornithemc.osl-gen2:core:${sc.properties["deps.osl_core"] as String}") + implementation("net.ornithemc.osl-gen2:entrypoints:${sc.properties["deps.osl_entrypoints"] as String}") + implementation("net.ornithemc.osl-gen2:lifecycle-events:${sc.properties["deps.osl_lifecycle_events"] as String}") + } else { + loomx.applyMojangMappings() + } + + modImplementation("net.fabricmc:fabric-loader:$loaderversion") + modImplementation("org.polyfrost.oneconfig:$mcversion-$loader:$oneconfigversion") + for (module in arrayOf("commands", "config", "config-impl", "events", "internal", "ui", "utils", "hud")) { + implementation("org.polyfrost.oneconfig:$module:$oneconfigversion") + } + + if (!isOrnithe) { + val fapiversion: String = sc.properties["deps.fabric_api"] + modImplementation("net.fabricmc.fabric-api:fabric-api:$fapiversion") + } + + testImplementation("org.junit.jupiter:junit-jupiter:${sc.properties.getAs("deps.junit")}") + testImplementation("net.fabricmc:fabric-loader-junit:$loaderversion") } -// Configures the output directory for when building from the `src/resources` directory. -sourceSets { - val dummy by creating - main { - dummy.compileClasspath += compileClasspath - compileClasspath += dummy.output - output.setResourcesDir(java.classesDirectory) +loom { + fabricModJsonPath = rootProject.file("src/main/resources/fabric.mod.json") +// accessWidenerPath = sc.process( +// rootProject.file("src/main/resources/$modid.ct"), +// "build/processed.ct" +// ) + + decompilerOptions.named("vineflower") { + options.put("mark-corresponding-synthetics", "1") + } + + runConfigs.all { + preferGradleTask = true + generateRunConfig = true + runDirectory = rootProject.file("run") + jvmArguments.add("-Dmixin.debug.export=true") } + + runConfigs.remove(runConfigs["server"]) } -// Adds the Polyfrost maven repository so that we can get the libraries necessary to develop the mod. -repositories { - maven("https://repo.polyfrost.org/releases") +java { + withSourcesJar() + targetCompatibility = requiredJava + sourceCompatibility = requiredJava + + toolchain { + vendor = JvmVendorSpec.ADOPTIUM + languageVersion = JavaLanguageVersion.of(requiredJava.majorVersion) + } } -// Configures the libraries/dependencies for your mod. -dependencies { - // Adds the OneConfig library, so we can develop with it. - modCompileOnly("cc.polyfrost:oneconfig-$platform:0.2.2-alpha+") +val kotlinJvmTarget = JvmTarget.fromTarget(requiredJava.majorVersion) - modRuntimeOnly("me.djtheredstoner:DevAuth-${if (platform.isFabric) "fabric" else if (platform.isLegacyForge) "forge-legacy" else "forge-latest"}:1.2.0") +tasks.withType().configureEach { + options.release = requiredJava.majorVersion.toInt() +} - // If we are building for legacy forge, includes the launch wrapper with `shade` as we configured earlier. - if (platform.isLegacyForge) { - compileOnly("org.spongepowered:mixin:0.7.11-SNAPSHOT") - shade("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta17") - } +tasks.withType().configureEach { + compilerOptions.jvmTarget = kotlinJvmTarget +} + +bloom { + replacement("@MOD_ID@", modid) + replacement("@MOD_NAME@", modname) + replacement("@MOD_VERSION@", modversion) } tasks { - // Processes the `src/resources/mcmod.info or fabric.mod.json` and replaces - // the mod id, name and version with the ones in `gradle.properties` - processResources { - inputs.property("id", mod_id) - inputs.property("name", mod_name) - val java = if (project.platform.mcMinor >= 18) { - 17 // If we are playing on version 1.18, set the java version to 17 - } else { - // Else if we are playing on version 1.17, use java 16. - if (project.platform.mcMinor == 17) - 16 - else - 8 // For all previous versions, we **need** java 8 (for Forge support). - } - 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" - ) - ) + test { + useJUnitPlatform() + testLogging { + showStackTraces = true + exceptionFormat = TestExceptionFormat.FULL } } - // Configures the resources to include if we are building for forge or fabric. - 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") - } + processResources { + val props = mapOf( + "mod_id" to modid, + "mod_name" to modname, + "mod_version" to modversion, + "mod_description" to moddescription, + "license" to license, + "minecraft_version_range" to versionrange, + "loader_version" to loaderversion, + "oneconfig_version" to oneconfigversion + ) + + inputs.properties(props) + + filesMatching("fabric.mod.json") { expand(props) } + } + + jar { + inputs.property("archivesName", base.archivesName) + + from(rootProject.file("LICENSE")) { + rename { "${it}_${inputs.properties["archivesName"]}" } } } - // Configures our shadow/shade configuration, so we can - // include some dependencies within our mod jar file. - named("shadowJar") { - archiveClassifier.set("dev") // TODO: machete gets confused by the `dev` prefix. - configurations = listOf(shade) - duplicatesStrategy = DuplicatesStrategy.EXCLUDE + register("buildAndCollect") { + group = "build" + description = "Builds mod jars and copies results to `build/libs/{mod version}/`" + + inputs.property("version", modversion) + from(loomx.modJar.flatMap { it.archiveFile }, loomx.modSourcesJar.flatMap { it.archiveFile }) + into(rootProject.layout.buildDirectory.file("libs/$modversion")) } +} + +val modrinthId = listOf("publish.modrinth") + .firstNotNullOfOrNull { sc.properties.getAs(it) ?: findProperty(it)?.toString() } + ?.takeIf { it.isNotBlank() } +val modrinthToken = listOf("oneconfig.publish.modrinth.token", "publish.modrinth.token", "modrinth.token") + .firstNotNullOfOrNull { findProperty(it) }?.toString()?.takeIf { it.isNotBlank() } - remapJar { - inputFile.set(shadowJar.get().archiveFile) - archiveClassifier.set("") +val changelogs = rootProject.file("CHANGELOG.md").takeIf { it.exists() }?.readText() ?: "No changelog provided." + +val validateChangelog = tasks.register("validateChangelog") { + description = "Validates that the changelog is written for the current version." + group = "publishing" + + if (!changelogs.contains(modversion)) { + throw GradleException("Changelog for version $modversion not found.") } +} - jar { - // Sets the jar manifest attributes. - if (platform.isLegacyForge) { - manifest.attributes += mapOf( - "ModSide" to "CLIENT", // We aren't developing a server-side mod, so this is fine. - "ForceLoadAsMod" to true, // We want to load this jar as a mod, so we force Forge to do so. - "TweakOrder" to "0", // Makes sure that the OneConfig launch wrapper is loaded as soon as possible. - "MixinConfigs" to "mixins.${mod_id}.json", // We want to use our mixin configuration, so we specify it here. - "TweakClass" to "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker" // Loads the OneConfig launch wrapper. - ) +tasks.publishMods.configure { + dependsOn(validateChangelog) +} +tasks.matching { it.name == "publishModrinth" }.configureEach { + dependsOn(validateChangelog) +} + +// set modrinth token in your user gradle properties +publishMods { + file = loomx.modJar.flatMap { it.archiveFile } + + displayName = modversion + version = "v$modversion" + changelog = changelogs + type = STABLE + + modLoaders.add(loader) + + dryRun = modrinthId == null || modrinthToken == null + + if (modrinthId != null) { + modrinth { + projectId = modrinthId + accessToken = modrinthToken.orEmpty() + + minecraftVersions.addAll(compatibleVersions.ifEmpty { listOf(mcversion) }) + + requires("oneconfig", "fabric-language-kotlin") } - dependsOn(shadowJar) - archiveClassifier.set("") - enabled = false } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index ff353e6..f24a24f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,12 +1,5 @@ -mod_name = GlintColorizer -mod_id = glintcolorizer -mod_version = 2.0.1 -mod_archives_name = GlintColorizer - -# Gradle Configuration -- DO NOT TOUCH THESE VALUES. -polyfrost.defaults.loom=3 -org.gradle.daemon=true +org.gradle.jvmargs=-Xmx4G org.gradle.parallel=true -org.gradle.configureoncommand=true -org.gradle.parallel.threads=4 -org.gradle.jvmargs=-Xmx2G \ No newline at end of file +# cus of bloom we cant use configuration cache +# org.gradle.configuration-cache=true +org.gradle.configureondemand=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0d18421..c56b367 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.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/root.gradle.kts b/root.gradle.kts deleted file mode 100644 index e490f41..0000000 --- a/root.gradle.kts +++ /dev/null @@ -1,13 +0,0 @@ -plugins { - kotlin("jvm") version "1.9.10" apply false - id("org.polyfrost.multi-version.root") - id("com.github.johnrengelman.shadow") version "8.1.1" apply false -} - -preprocess { -// "1.12.2-forge"(11202, "srg") { - "1.8.9-forge"(10809, "srg", -// rootProject.file("versions/1.12.2-1.8.9.txt") - ) -// } -} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index b2cca22..43903f0 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,33 +1,33 @@ -@file:Suppress("PropertyName") - pluginManagement { repositories { - gradlePluginPortal() mavenCentral() - maven("https://repo.polyfrost.org/releases") // Adds the Polyfrost maven repository to get Polyfrost Gradle Toolkit - } - plugins { - val pgtVersion = "0.6.5" // Sets the default versions for Polyfrost Gradle Toolkit - id("org.polyfrost.multi-version.root") version pgtVersion + gradlePluginPortal() + maven("https://maven.fabricmc.net/") + maven("https://maven.ornithemc.net/releases") + maven("https://maven.kikugie.dev/releases") { name = "KikuGie Releases" } + maven("https://maven.kikugie.dev/snapshots") { name = "KikuGie Snapshots" } + maven("https://maven.deftu.dev/releases") + maven("https://maven.deftu.dev/snapshots") + maven("https://maven.architectury.dev") + maven("https://repo.polyfrost.org/releases") + maven("https://repo.polyfrost.org/snapshots") + maven("https://jitpack.io/") } } -val mod_name: String by settings +plugins { + id("dev.kikugie.stonecutter") version "0.10-alpha.7" + id("dev.kikugie.loom-back-compat") version "0.4.2" + id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0" +} -// Configures the root project Gradle name based on the value in `gradle.properties` -rootProject.name = mod_name -rootProject.buildFileName = "root.gradle.kts" +stonecutter { + create(rootProject) { + versions("1.8.9") -// Adds all of our build target versions to the classpath if we need to add version-specific code. -listOf( - "1.8.9-forge" -// , - // Update this if you want to remove/add a version, along with `build.gradle.kts` and `root.gradle.kts`. -// "1.12.2-forge" -).forEach { version -> - include(":$version") - project(":$version").apply { - projectDir = file("versions/$version") - buildFileName = "../../build.gradle.kts" + vcsVersion = "1.8.9" } -} \ No newline at end of file +} + +// Configures the root project Gradle name based on the value in `stonecutter.properties.toml` +rootProject.name = sc.properties["mod.name"] \ No newline at end of file diff --git a/src/main/java/org/polyfrost/glintcolorizer/mixin/ForgeHooksClientMixin.java b/src/main/java/org/polyfrost/glintcolorizer/mixin/ForgeHooksClientMixin.java deleted file mode 100644 index 32fe188..0000000 --- a/src/main/java/org/polyfrost/glintcolorizer/mixin/ForgeHooksClientMixin.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.polyfrost.glintcolorizer.mixin; - -import org.polyfrost.glintcolorizer.hook.RenderItemHook; -import net.minecraft.client.renderer.block.model.ItemCameraTransforms; -import net.minecraft.client.resources.model.IBakedModel; -import net.minecraftforge.client.ForgeHooksClient; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin( - value = ForgeHooksClient.class, - remap = false -) -public class ForgeHooksClientMixin { - - @Inject( - method = "handleCameraTransforms", - at = @At( - value = "HEAD" - ) - ) - private static void glintColorizer$setCameraTransform(IBakedModel model, ItemCameraTransforms.TransformType cameraTransformType, CallbackInfoReturnable cir) { - RenderItemHook.INSTANCE.setTransformType(cameraTransformType); - } - -} \ No newline at end of file diff --git a/src/main/java/org/polyfrost/glintcolorizer/mixin/ItemEntityRendererMixin_HandleCameraTransforms.java b/src/main/java/org/polyfrost/glintcolorizer/mixin/ItemEntityRendererMixin_HandleCameraTransforms.java new file mode 100644 index 0000000..a7a69cf --- /dev/null +++ b/src/main/java/org/polyfrost/glintcolorizer/mixin/ItemEntityRendererMixin_HandleCameraTransforms.java @@ -0,0 +1,23 @@ + +package org.polyfrost.glintcolorizer.mixin; + + + +import net.minecraft.client.renderer.block.model.ItemCameraTransforms; +import net.minecraft.client.renderer.entity.RenderEntityItem; +import net.minecraft.entity.item.EntityItem; +import org.polyfrost.glintcolorizer.hook.RenderItemHook; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + + + +@Mixin(RenderEntityItem.class) +public class ItemEntityRendererMixin_HandleCameraTransforms { + @Inject(method = "doRender(Lnet/minecraft/entity/item/EntityItem;DDDFF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/block/model/ItemCameraTransforms;applyTransform(Lnet/minecraft/client/renderer/block/model/ItemCameraTransforms$TransformType;)V", ordinal = 0)) + private void glintcolorizer$setCameraTransform(EntityItem itemEntity, double d, double e, double f, float g, float h, CallbackInfo ci) { + RenderItemHook.INSTANCE.setTransformType(ItemCameraTransforms.TransformType.GROUND); + } +} diff --git a/src/main/java/org/polyfrost/glintcolorizer/mixin/ItemRendererMixin_HandleCameraTransforms.java b/src/main/java/org/polyfrost/glintcolorizer/mixin/ItemRendererMixin_HandleCameraTransforms.java new file mode 100644 index 0000000..9d745f0 --- /dev/null +++ b/src/main/java/org/polyfrost/glintcolorizer/mixin/ItemRendererMixin_HandleCameraTransforms.java @@ -0,0 +1,29 @@ +package org.polyfrost.glintcolorizer.mixin; + + + + +import net.minecraft.client.renderer.block.model.ItemCameraTransforms; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.resources.model.IBakedModel; +import net.minecraft.item.ItemStack; +import org.polyfrost.glintcolorizer.hook.RenderItemHook; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + + + +@Mixin(RenderItem.class) +public class ItemRendererMixin_HandleCameraTransforms { + @Inject(method = "renderItemModelTransform", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/block/model/ItemCameraTransforms;applyTransform(Lnet/minecraft/client/renderer/block/model/ItemCameraTransforms$TransformType;)V")) + private void glintcolorizer$setCameraTransform$hand(ItemStack item, IBakedModel model, ItemCameraTransforms.TransformType transform, CallbackInfo ci) { + RenderItemHook.INSTANCE.setTransformType(transform); + } + + @Inject(method = "renderItemIntoGUI", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/block/model/ItemCameraTransforms;applyTransform(Lnet/minecraft/client/renderer/block/model/ItemCameraTransforms$TransformType;)V")) + private void glintcolorizer$setCameraTransform$gui(ItemStack item, int x, int y, CallbackInfo ci) { + RenderItemHook.INSTANCE.setTransformType(ItemCameraTransforms.TransformType.GUI); + } +} diff --git a/src/main/java/org/polyfrost/glintcolorizer/mixin/LayerArmorBaseMixin.java b/src/main/java/org/polyfrost/glintcolorizer/mixin/LayerArmorBaseMixin.java index 4fcfbc6..045f31a 100644 --- a/src/main/java/org/polyfrost/glintcolorizer/mixin/LayerArmorBaseMixin.java +++ b/src/main/java/org/polyfrost/glintcolorizer/mixin/LayerArmorBaseMixin.java @@ -1,9 +1,9 @@ package org.polyfrost.glintcolorizer.mixin; -import cc.polyfrost.oneconfig.utils.color.ColorUtils; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.entity.EntityLivingBase; +import org.polyfrost.compose.render.PolyColor; import org.polyfrost.glintcolorizer.config.GlintConfig; import net.minecraft.client.renderer.entity.layers.LayerArmorBase; import org.spongepowered.asm.mixin.Mixin; @@ -27,7 +27,7 @@ public abstract class LayerArmorBaseMixin implements LayerR cancellable = true ) private void glintColorizer$disableGlint(EntityLivingBase entitylivingbaseIn, T modelbaseIn, float p_177183_3_, float p_177183_4_, float partialTicks, float p_177183_6_, float p_177183_7_, float p_177183_8_, float scale, CallbackInfo ci) { - if (GlintConfig.INSTANCE.getArmorGlintToggle() && GlintConfig.INSTANCE.enabled) { + if (GlintConfig.INSTANCE.getArmorGlintToggle() && GlintConfig.INSTANCE.getEnabled()) { ci.cancel(); } } @@ -40,10 +40,10 @@ public abstract class LayerArmorBaseMixin implements LayerR ) ) private void glintColorizer$modifyArmorColor(Args args) { - int color = GlintConfig.INSTANCE.getArmorColor().getRGB(); - args.set(0, (float) ColorUtils.getRed(color) / 255); - args.set(1, (float) ColorUtils.getGreen(color) / 255); - args.set(2, (float) ColorUtils.getBlue(color) / 255); + PolyColor color = GlintConfig.INSTANCE.getArmorColor(); + args.set(0, color.getRedF()); + args.set(1, color.getGreenF()); + args.set(2, color.getBlueF()); } } diff --git a/src/main/java/org/polyfrost/glintcolorizer/mixin/RenderItemMixin_GlintCustomizer.java b/src/main/java/org/polyfrost/glintcolorizer/mixin/RenderItemMixin_GlintCustomizer.java index 7bdf639..272d3d1 100644 --- a/src/main/java/org/polyfrost/glintcolorizer/mixin/RenderItemMixin_GlintCustomizer.java +++ b/src/main/java/org/polyfrost/glintcolorizer/mixin/RenderItemMixin_GlintCustomizer.java @@ -53,7 +53,7 @@ public class RenderItemMixin_GlintCustomizer { ) ) private void glintColorizer$modifyScale(Args args) { - if (!GlintConfig.INSTANCE.enabled) { return; } + if (!GlintConfig.INSTANCE.getEnabled()) { return; } args.set(0, glintColorizer$getModifiedScale(args.get(0))); args.set(1, glintColorizer$getModifiedScale(args.get(1))); args.set(2, glintColorizer$getModifiedScale(args.get(2))); @@ -68,7 +68,7 @@ public class RenderItemMixin_GlintCustomizer { index = 0 ) private float glintColorizer$modifySpeed(float speed) { - if (!GlintConfig.INSTANCE.enabled) { return speed; } + if (!GlintConfig.INSTANCE.getEnabled()) { return speed; } return glintColorizer$getModifiedSpeed(speed); } @@ -82,7 +82,7 @@ public class RenderItemMixin_GlintCustomizer { index = 0 ) private float glintColorizer$modifyRotation(float angle) { - if (!GlintConfig.INSTANCE.enabled) { return angle; } + if (!GlintConfig.INSTANCE.getEnabled()) { return angle; } return glintColorizer$getModifiedRotation(angle , true); } @@ -96,7 +96,7 @@ public class RenderItemMixin_GlintCustomizer { index = 0 ) private float glintColorizer$modifyRotation2(float angle) { - if (!GlintConfig.INSTANCE.enabled) { return angle; } + if (!GlintConfig.INSTANCE.getEnabled()) { return angle; } return glintColorizer$getModifiedRotation(angle, false); } @@ -110,7 +110,7 @@ public class RenderItemMixin_GlintCustomizer { index = 1 ) private int glintColorizer$modifyColor1(int color) { - if (!GlintConfig.INSTANCE.enabled) { return color; } + if (!GlintConfig.INSTANCE.getEnabled()) { return color; } return glintColorizer$getModifiedColor(color, true); } @@ -124,7 +124,7 @@ public class RenderItemMixin_GlintCustomizer { index = 1 ) private int glintColorizer$modifyColor2(int color) { - if (!GlintConfig.INSTANCE.enabled) { return color; } + if (!GlintConfig.INSTANCE.getEnabled()) { return color; } return glintColorizer$getModifiedColor(color, false); } @@ -158,8 +158,8 @@ public class RenderItemMixin_GlintCustomizer { @Unique private int glintColorizer$getColor(GlintEffectOptions settings, boolean isFirstStroke) { return settings.getIndividualStrokes() ? - (isFirstStroke ? settings.getStrokeOneColor().getRGB() : settings.getStrokeTwoColor().getRGB()) : - settings.getGlintColor().getRGB(); + (isFirstStroke ? settings.getStrokeOneColor().getArgb() : settings.getStrokeTwoColor().getArgb()) : + settings.getGlintColor().getArgb(); } @Unique diff --git a/src/main/java/org/polyfrost/glintcolorizer/mixin/accessor/RenderItemAccessor.java b/src/main/java/org/polyfrost/glintcolorizer/mixin/accessor/RenderItemAccessor.java index c399b26..4ad98d8 100644 --- a/src/main/java/org/polyfrost/glintcolorizer/mixin/accessor/RenderItemAccessor.java +++ b/src/main/java/org/polyfrost/glintcolorizer/mixin/accessor/RenderItemAccessor.java @@ -7,7 +7,6 @@ @Mixin(RenderItem.class) public interface RenderItemAccessor { - - @Invoker void invokeRenderModel(IBakedModel model, int color); - + @Invoker("renderModel") + void invokeRenderModel(IBakedModel model, int color); } \ No newline at end of file diff --git a/src/main/java/org/polyfrost/glintcolorizer/mixin/oneconfig/ConfigMixin.java b/src/main/java/org/polyfrost/glintcolorizer/mixin/oneconfig/ConfigMixin.java deleted file mode 100644 index 2ae5e2f..0000000 --- a/src/main/java/org/polyfrost/glintcolorizer/mixin/oneconfig/ConfigMixin.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.polyfrost.glintcolorizer.mixin.oneconfig; - -import cc.polyfrost.oneconfig.config.Config; -import cc.polyfrost.oneconfig.config.core.ConfigUtils; -import cc.polyfrost.oneconfig.config.data.Mod; -import cc.polyfrost.oneconfig.config.elements.BasicOption; -import cc.polyfrost.oneconfig.config.elements.OptionPage; -import cc.polyfrost.oneconfig.internal.config.annotations.Option; -import org.polyfrost.glintcolorizer.config.GlintEffectOptions; -import org.polyfrost.glintcolorizer.config.annotation.ColorEntry; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyVariable; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.lang.reflect.Field; -import java.util.ArrayList; - -@Mixin(value = Config.class, remap = false) -public class ConfigMixin { - - @Unique private transient OptionPage glintColorizer$page; - @Unique private transient Object glintColorizer$instance; - - @Inject( - method = "generateOptionList(Ljava/lang/Object;Ljava/lang/Class;Lcc/polyfrost/oneconfig/config/elements/OptionPage;Lcc/polyfrost/oneconfig/config/data/Mod;Z)V", - at = @At( - value = "HEAD" - ) - ) - private void capture(Object instance, Class targetClass, OptionPage page, Mod mod, boolean migrate, CallbackInfo ci) { - this.glintColorizer$instance = instance; - this.glintColorizer$page = page; - } - - @ModifyVariable( - method = "generateOptionList(Ljava/lang/Object;Ljava/lang/Class;Lcc/polyfrost/oneconfig/config/elements/OptionPage;Lcc/polyfrost/oneconfig/config/data/Mod;Z)V", - at = @At( - value = "LOAD", - ordinal = 0 - ), - name = "field" - ) - private Field generate(Field field) { - if (field.isAnnotationPresent(ColorEntry.class)) { - glintColorizer$addOptions(glintColorizer$page, field, glintColorizer$instance); - } - return field; - } - - @Unique - private void glintColorizer$addOptions(OptionPage page, Field field, Object instance) { - ColorEntry annotation = field.getAnnotation(ColorEntry.class); - GlintEffectOptions colorSettings = (GlintEffectOptions) ConfigUtils.getField(field, instance); - BasicOption strokeOne = null; - BasicOption strokeTwo = null; - BasicOption individualStrokes = null; - for (BasicOption option : glintColorizer$getClassOptions(colorSettings)) { - if (option.getField().getName().equals("strokeOneColor")) strokeOne = option; - if (option.getField().getName().equals("strokeTwoColor")) strokeTwo = option; - if (option.getField().getName().equals("individualStrokes")) individualStrokes = option; - ConfigUtils.getSubCategory(page, annotation.category(), option.subcategory).options.add(option); - } - if (strokeOne != null && strokeTwo != null && individualStrokes != null) { - BasicOption finalIndividualStrokes = individualStrokes; - strokeOne.addDependency(individualStrokes.name, () -> { - try { - return (boolean) finalIndividualStrokes.get(); - } catch (IllegalAccessException ignored) { - return true; - } - }); - strokeTwo.addDependency(individualStrokes.name, () -> { - try { - return (boolean) finalIndividualStrokes.get(); - } catch (IllegalAccessException ignored) { - return true; - } - }); - } - } - - @Unique - private static ArrayList glintColorizer$getClassOptions(Object object) { - ArrayList options = new ArrayList<>(); - ArrayList fields = ConfigUtils.getClassFields(object.getClass()); - for (Field field : fields) { - Option option = ConfigUtils.findAnnotation(field, Option.class); - if (option == null) continue; - options.add(ConfigUtils.getOption(option, field, object)); - } - return options; - } - -} \ No newline at end of file diff --git a/src/main/kotlin/org/polyfrost/glintcolorizer/GlintColorizer.kt b/src/main/kotlin/org/polyfrost/glintcolorizer/GlintColorizer.kt index bb3709b..9a857f7 100644 --- a/src/main/kotlin/org/polyfrost/glintcolorizer/GlintColorizer.kt +++ b/src/main/kotlin/org/polyfrost/glintcolorizer/GlintColorizer.kt @@ -1,32 +1,20 @@ package org.polyfrost.glintcolorizer -import cc.polyfrost.oneconfig.utils.commands.CommandManager -import net.minecraftforge.fml.common.Mod -import net.minecraftforge.fml.common.event.FMLInitializationEvent -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent -import org.polyfrost.glintcolorizer.command.GlintCommand -import org.polyfrost.glintcolorizer.config.GlintConfig -@Mod( - modid = GlintColorizer.ID, - name = GlintColorizer.NAME, - version = GlintColorizer.VER, - modLanguageAdapter = "cc.polyfrost.oneconfig.utils.KotlinLanguageAdapter" -) -object GlintColorizer { +import net.fabricmc.api.ClientModInitializer +import net.ornithemc.osl.lifecycle.api.client.MinecraftClientEvents - const val NAME: String = "@NAME@" - const val VER: String = "@VER@" - const val ID: String = "@ID@" +import org.polyfrost.glintcolorizer.command.GlintCommand +import org.polyfrost.glintcolorizer.config.GlintConfig +import org.polyfrost.oneconfig.api.commands.v1.CommandManager - @Mod.EventHandler - fun onInit(event: FMLInitializationEvent?) { - GlintConfig - } +object GlintColorizer : ClientModInitializer { + const val NAME: String = "@MOD_NAME@" + const val VERSION: String = "@MOD_VERSION@" + const val ID: String = "@MOD_ID@" - @Mod.EventHandler - fun postInit(event: FMLPostInitializationEvent?) { - CommandManager.INSTANCE.registerCommand(GlintCommand()) + override fun onInitializeClient() { + CommandManager.register(GlintCommand()) + MinecraftClientEvents.READY.register() { context: Any -> GlintConfig.preload() } } - } diff --git a/src/main/kotlin/org/polyfrost/glintcolorizer/command/GlintCommand.kt b/src/main/kotlin/org/polyfrost/glintcolorizer/command/GlintCommand.kt index 73bb2ef..17bbded 100644 --- a/src/main/kotlin/org/polyfrost/glintcolorizer/command/GlintCommand.kt +++ b/src/main/kotlin/org/polyfrost/glintcolorizer/command/GlintCommand.kt @@ -1,19 +1,21 @@ package org.polyfrost.glintcolorizer.command -import cc.polyfrost.oneconfig.utils.commands.annotations.Command -import cc.polyfrost.oneconfig.utils.commands.annotations.Main + import org.polyfrost.glintcolorizer.GlintColorizer import org.polyfrost.glintcolorizer.config.GlintConfig +import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Command +import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Handler +import org.polyfrost.oneconfig.utils.v1.dsl.openUI @Command( - value = GlintColorizer.ID, + value = [GlintColorizer.ID], description = "Access the " + GlintColorizer.NAME + " GUI." ) class GlintCommand { - @Main - fun handle() { - GlintConfig.openGui() + @Handler + fun main() { + GlintConfig.openUI() } } \ No newline at end of file diff --git a/src/main/kotlin/org/polyfrost/glintcolorizer/config/GlintConfig.kt b/src/main/kotlin/org/polyfrost/glintcolorizer/config/GlintConfig.kt index 48ef718..a2bde14 100644 --- a/src/main/kotlin/org/polyfrost/glintcolorizer/config/GlintConfig.kt +++ b/src/main/kotlin/org/polyfrost/glintcolorizer/config/GlintConfig.kt @@ -1,64 +1,31 @@ package org.polyfrost.glintcolorizer.config -import cc.polyfrost.oneconfig.config.Config -import cc.polyfrost.oneconfig.config.annotations.* -import cc.polyfrost.oneconfig.config.core.OneColor -import cc.polyfrost.oneconfig.config.data.Mod -import cc.polyfrost.oneconfig.config.data.ModType -import cc.polyfrost.oneconfig.config.migration.VigilanceMigrator -import org.polyfrost.glintcolorizer.GlintColorizer -import org.polyfrost.glintcolorizer.config.annotation.ColorEntry -import cc.polyfrost.oneconfig.config.annotations.Color -import java.io.File -object GlintConfig : Config( - Mod( - GlintColorizer.NAME, ModType.UTIL_QOL, "/glintcolorizer_dark.svg", VigilanceMigrator( - File(File(File("./W-OVERFLOW"), GlintColorizer.NAME), GlintColorizer.ID + ".toml").path - ) - ), GlintColorizer.ID + ".json" -) { +import org.polyfrost.compose.render.PolyColor +import org.polyfrost.oneconfig.api.config.v1.Config +import org.polyfrost.oneconfig.api.config.v1.annotations.Accordion +import org.polyfrost.oneconfig.api.config.v1.annotations.Button +import org.polyfrost.oneconfig.api.config.v1.annotations.Checkbox +import org.polyfrost.oneconfig.api.config.v1.annotations.Color +import org.polyfrost.oneconfig.api.config.v1.annotations.Switch - @Exclude val defaultColor = -8372020 - @Exclude var oldGlintValue = -10407781 - @Button( - name = "Reset ALL Colors Settings", - category = "Global", - text = "Reset", - description = "Resets ALL custom glint colors settings and defaults them back to the vanilla color." - ) - var resetColors = Runnable { - globalColor = OneColor(defaultColor) - heldItem.reset(true) - guiItem.reset(true) - droppedItem.reset(true) - framedItem.reset(true) - shinyPots.reset(true) - armorColor = OneColor(defaultColor) - } +object GlintConfig : Config( + "glintcolorizer.json", "/assets/glintcolorizer/glintcolorizer_dark.svg", "GlintColorizer", Category.VISUALS +) { + val defaultColor = -8372020 + var oldGlintValue = -10407781 - @Button( - name = "Reset ALL Transformation Settings", - category = "Global", - text = "Reset", - description = "Resets ALL custom glint colors settings and defaults them back to the vanilla color." - ) - var resetTransformations = Runnable { - heldItem.reset2() - guiItem.reset2() - droppedItem.reset2() - framedItem.reset2() - shinyPots.reset2() - } + @Switch(title = "Enabled") + var enabled = true @Button( - name = "Reset ALL Shiny Pots Settings", + title = "Reset ALL Shiny Pots Settings", category = "Global", text = "Reset", description = "Resets ALL custom shiny pots settings." ) - var resetShinyPots = Runnable { + fun resetShinyPots() { potionGlint = false potionGlintSize = false potionGlintBackground = false @@ -67,28 +34,36 @@ object GlintConfig : Config( } @Color( - name = "Global Glint Color", + title = "Global Glint Color", category = "Global", subcategory = "Configuration", description = "Modifies the color of the enchantment glint." ) - var globalColor = OneColor(defaultColor) + var globalColor = PolyColor(defaultColor) @Button( - name = "Apply Global Glint Color", + title = "Apply Global Glint Color", category = "Global", subcategory = "Configuration", text = "Apply", description = "Applies your global glint color. Resets ALL custom colors." ) - var applyColors = Runnable { + fun applyColors() { /* Singular Colors */ - heldItem.glintColor = globalColor.clone().also { it.setChromaSpeed(globalColor.dataBit) } - guiItem.glintColor = globalColor.clone().also { it.setChromaSpeed(globalColor.dataBit) } - droppedItem.glintColor = globalColor.clone().also { it.setChromaSpeed(globalColor.dataBit) } - framedItem.glintColor = globalColor.clone().also { it.setChromaSpeed(globalColor.dataBit) } - shinyPots.glintColor = globalColor.clone().also { it.setChromaSpeed(globalColor.dataBit) } - armorColor = globalColor.clone().also { it.setChromaSpeed(globalColor.dataBit) } + + heldItem.glintColor.argb = globalColor.argb + heldItem.glintColor.chromaSpeed = globalColor.chromaSpeed + guiItem.glintColor.argb = globalColor.argb + guiItem.glintColor.chromaSpeed = globalColor.chromaSpeed + droppedItem.glintColor.argb = globalColor.argb + droppedItem.glintColor.chromaSpeed = globalColor.chromaSpeed + framedItem.glintColor.argb = globalColor.argb + framedItem.glintColor.chromaSpeed = globalColor.chromaSpeed + shinyPots.glintColor.argb = globalColor.argb + shinyPots.glintColor.chromaSpeed = globalColor.chromaSpeed + armorColor.argb = globalColor.argb + armorColor.chromaSpeed = globalColor.chromaSpeed + /* Stroke */ heldItem.individualStrokes = false guiItem.individualStrokes = false @@ -98,58 +73,46 @@ object GlintConfig : Config( } @Button( - name = "1.7 Glint Color", + title = "1.7 Glint Color", category = "Global", subcategory = "Configuration", text = "Apply", description = "Applies the 1.7 glint color to all transform types." ) - var oldGlint = Runnable { - heldItem.glintColor = OneColor(oldGlintValue) + fun oldGlint() { + heldItem.glintColor.argb = oldGlintValue /* GUI Items' glint color are actually the default 1.8 glint color! */ - droppedItem.glintColor = OneColor(oldGlintValue) - framedItem.glintColor = OneColor(oldGlintValue) - shinyPots.glintColor = OneColor(oldGlintValue) + droppedItem.glintColor.argb = oldGlintValue + framedItem.glintColor.argb = oldGlintValue + shinyPots.glintColor.argb = oldGlintValue } /* Held Items */ - @ColorEntry( + @Accordion( category = "Held Item" ) var heldItem = GlintEffectOptions() /* Gui Items */ - @ColorEntry( + @Accordion( category = "GUI Item" ) var guiItem = GlintEffectOptions() /* Dropped Items */ - @ColorEntry( + @Accordion( category = "Dropped Item" ) var droppedItem = GlintEffectOptions() /* Framed Items */ - @ColorEntry( + @Accordion( category = "Framed Item" ) var framedItem = GlintEffectOptions() - /* Armor */ - @Button( - name = "Reset Armor Glint", - category = "Armor", - subcategory = "Configuration", - text = "Reset", - description = "Resets ALL custom glint colors." - ) - var resetArmor = Runnable { - armorColor = OneColor(defaultColor) - } - @Switch( - name = "Disable Armor Glint", + title = "Disable Armor Glint", category = "Armor", subcategory = "Color", description = "Disables the enchantment glint on armor." @@ -157,54 +120,49 @@ object GlintConfig : Config( var armorGlintToggle = false @Color( - name = "Armor Glint Color", + title = "Armor Glint Color", category = "Armor", subcategory = "Color", description = "Modifies the color of the enchantment glint." ) - var armorColor = OneColor(defaultColor) + var armorColor = PolyColor(defaultColor) /* Shiny Pots */ @Switch( - name = "Shiny Potions", + title = "Shiny Potions", category = "Shiny Pots" ) var potionGlint = false @Checkbox( - name = "Render Over Full Slot", + title = "Render Over Full Slot", category = "Shiny Pots" ) var potionGlintSize = false @Checkbox( - name = "Render Shiny Effect Only", + title = "Render Shiny Effect Only", description = "Disables the enchantment glint on the potion and solely renders the shiny effect.", category = "Shiny Pots" ) var potionGlintForeground = false @Checkbox( - name = "Custom Shiny Effect Color", + title = "Custom Shiny Effect Color", category = "Shiny Pots", subcategory = "Color" ) var potionGlintBackground = false - @ColorEntry( + @Accordion( category = "Shiny Pots" ) var shinyPots = GlintEffectOptions() @Switch( - name = "Potion Color Based Glint", + title = "Potion Color Based Glint", category = "Shiny Pots", subcategory = "Color" ) var potionBasedColor = false - - init { - initialize() - } - } \ No newline at end of file diff --git a/src/main/kotlin/org/polyfrost/glintcolorizer/config/GlintEffectOptions.kt b/src/main/kotlin/org/polyfrost/glintcolorizer/config/GlintEffectOptions.kt index c35fa86..efb7b47 100644 --- a/src/main/kotlin/org/polyfrost/glintcolorizer/config/GlintEffectOptions.kt +++ b/src/main/kotlin/org/polyfrost/glintcolorizer/config/GlintEffectOptions.kt @@ -1,114 +1,69 @@ package org.polyfrost.glintcolorizer.config -import cc.polyfrost.oneconfig.config.annotations.* -import cc.polyfrost.oneconfig.config.core.ConfigUtils -import cc.polyfrost.oneconfig.config.core.OneColor +import org.polyfrost.compose.render.PolyColor +import org.polyfrost.oneconfig.api.config.v1.annotations.Button +import org.polyfrost.oneconfig.api.config.v1.annotations.Color +import org.polyfrost.oneconfig.api.config.v1.annotations.Slider +import org.polyfrost.oneconfig.api.config.v1.annotations.Switch -class GlintEffectOptions { - - @Button( - name = "Reset Glint Colors", - subcategory = "Configuration", - text = "Reset", - description = "Resets ALL custom glint colors." - ) - var resetColor = Runnable { - reset(false) - GlintConfig.save() - GlintConfig.openGui() - } - - @Button( - name = "Reset Transformations", - category = "Held Item", - subcategory = "Configuration", - text = "Reset", - description = "Resets ALL custom glint transformations." - ) - var resetTransforms = Runnable { - reset2() - GlintConfig.save() - GlintConfig.openGui() - } +class GlintEffectOptions { @Switch( - name = "Modify Strokes Individually", + title = "Modify Strokes Individually", subcategory = "Color" ) var individualStrokes = false @Color( - name = "Glint Color", + title = "Glint Color", subcategory = "Color", description = "Modifies the color of the enchantment glint." ) - var glintColor = OneColor(GlintConfig.defaultColor) + var glintColor = PolyColor(GlintConfig.defaultColor) @Color( - name = "Stroke 1 Color", + title = "Stroke 1 Color", subcategory = "Color", description = "Modifies the first stroke of the enchantment glint effect." ) - var strokeOneColor = OneColor(GlintConfig.defaultColor) + var strokeOneColor = PolyColor(GlintConfig.defaultColor) @Color( - name = "Stroke 2 Color", + title = "Stroke 2 Color", subcategory = "Color", description = "Modifies the second stroke of the enchantment glint effect." ) - var strokeTwoColor = OneColor(GlintConfig.defaultColor) + var strokeTwoColor = PolyColor(GlintConfig.defaultColor) @Slider( - name = "Speed", + title = "Speed", subcategory = "Speed", min = 0.1F, - max = 10.0F, - instant = true + max = 10.0F ) var speed = 1.0F @Slider( - name = "Stroke 1 Rotation", + title = "Stroke 1 Rotation", subcategory = "Rotation", min = -180.0F, - max = 180.0F, - instant = true + max = 180.0F ) var strokeRotOne = -50.0F @Slider( - name = "Stroke 2 Rotation", + title = "Stroke 2 Rotation", subcategory = "Rotation", min = -180.0F, - max = 180.0F, - instant = true + max = 180.0F ) var strokeRotTwo = 10.0F @Slider( - name = "Scale", + title = "Scale", subcategory = "Scale", min = 0.0F, - max = 8.0F, - instant = true + max = 8.0F ) var scale = 1.0F - - fun reset(resetAll: Boolean) { - val target = GlintEffectOptions() - val newFields = ConfigUtils.getClassFields(target::class.java) - val fields = ConfigUtils.getClassFields(this::class.java) - for (i in 0 until fields.size) { - if (!resetAll && fields[i].type != OneColor::class.java) continue - fields[i].set(this, ConfigUtils.getField(newFields[i], target)) - } - } - - fun reset2() { - speed = 1.0F - strokeRotOne = -50.0F - strokeRotTwo = 10.0F - scale = 1.0F - } - } \ No newline at end of file diff --git a/src/main/kotlin/org/polyfrost/glintcolorizer/config/annotation/ColorEntry.kt b/src/main/kotlin/org/polyfrost/glintcolorizer/config/annotation/ColorEntry.kt deleted file mode 100644 index 884d1a2..0000000 --- a/src/main/kotlin/org/polyfrost/glintcolorizer/config/annotation/ColorEntry.kt +++ /dev/null @@ -1,4 +0,0 @@ -package org.polyfrost.glintcolorizer.config.annotation - -@Target(AnnotationTarget.FIELD) -annotation class ColorEntry(val category: String = "General") \ No newline at end of file diff --git a/src/main/kotlin/org/polyfrost/glintcolorizer/handler/SecondGlintHandler.kt b/src/main/kotlin/org/polyfrost/glintcolorizer/handler/SecondGlintHandler.kt index 63cb2a0..657b2b6 100644 --- a/src/main/kotlin/org/polyfrost/glintcolorizer/handler/SecondGlintHandler.kt +++ b/src/main/kotlin/org/polyfrost/glintcolorizer/handler/SecondGlintHandler.kt @@ -38,7 +38,7 @@ fun glintStroke1(renderItem : RenderItem, model : IBakedModel) { GlStateManager.translate(f, 0.0f, 0.0f) GlStateManager.rotate(-50.0f, 0.0f, 0.0f, 1.0f) (renderItem as RenderItemAccessor).invokeRenderModel(model, - if (GlintConfig.guiItem.individualStrokes) GlintConfig.guiItem.strokeOneColor.rgb else GlintConfig.guiItem.glintColor.rgb + if (GlintConfig.guiItem.individualStrokes) GlintConfig.guiItem.strokeOneColor.argb else GlintConfig.guiItem.glintColor.argb ) GlStateManager.popMatrix() } @@ -50,7 +50,7 @@ fun glintStroke2(renderItem : RenderItem, model : IBakedModel) { GlStateManager.translate(-f1, 0.0f, 0.0f) GlStateManager.rotate(10.0f, 0.0f, 0.0f, 1.0f) (renderItem as RenderItemAccessor).invokeRenderModel(model, - if (GlintConfig.guiItem.individualStrokes) GlintConfig.guiItem.strokeTwoColor.rgb else GlintConfig.guiItem.glintColor.rgb + if (GlintConfig.guiItem.individualStrokes) GlintConfig.guiItem.strokeTwoColor.argb else GlintConfig.guiItem.glintColor.argb ) GlStateManager.popMatrix() } \ No newline at end of file diff --git a/src/main/resources/glintcolorizer_dark.svg b/src/main/resources/assets/glintcolorizer/glintcolorizer_dark.svg similarity index 100% rename from src/main/resources/glintcolorizer_dark.svg rename to src/main/resources/assets/glintcolorizer/glintcolorizer_dark.svg diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..27f4a6e --- /dev/null +++ b/src/main/resources/fabric.mod.json @@ -0,0 +1,34 @@ +{ + "schemaVersion": 1, + "id": "${mod_id}", + "version": "${mod_version}", + "name": "${mod_name}", + "description": "${mod_description}", + "authors": [ + "Polyfrost" + ], + "icon": "assets/glintcolorizer/glintcolorizer_dark.svg", + "contact": { + "issues": "https://github.com/Polyfrost/${mod_name}/issues", + "sources": "https://github.com/Polyfrost/${mod_name}" + }, + "license": "${license}", + "environment": "*", + "entrypoints": { + "client": [ + { + "adapter": "kotlin", + "value": "org.polyfrost.glintcolorizer.GlintColorizer" + } + ] + }, + "mixins": [ + "mixins.${mod_id}.json" + ], + "depends": { + "fabricloader": ">=${loader_version}", + "minecraft": "${minecraft_version_range}", + "oneconfigv1": ">=${oneconfig_version}", + "fabric-language-kotlin": "*" + } +} \ No newline at end of file diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info deleted file mode 100644 index 3953293..0000000 --- a/src/main/resources/mcmod.info +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "modid": "${id}", - "name": "${name}", - "description": "Change the color of the enchantment glint!", - "version": "${version}", - "mcversion": "${mcVersionStr}", - "url": "", - "updateUrl": "", - "authorList": [ - "Polyfrost" - ], - "credits": "", - "logoFile": "", - "screenshots": [], - "dependencies": [] - } -] diff --git a/src/main/resources/mixins.glintcolorizer.json b/src/main/resources/mixins.glintcolorizer.json index a5dbe8d..c006395 100644 --- a/src/main/resources/mixins.glintcolorizer.json +++ b/src/main/resources/mixins.glintcolorizer.json @@ -1,15 +1,16 @@ { - "compatibilityLevel": "JAVA_8", - "minVersion": "0.7", + "compatibilityLevel": "JAVA_25", + "minVersion": "0.8", "package": "org.polyfrost.glintcolorizer.mixin", - "refmap": "mixins.${id}.refmap.json", "mixins": [ - "ForgeHooksClientMixin", "LayerArmorBaseMixin", "RenderItemMixin_GlintCustomizer", "RenderItemMixin_ShinyEffect", - "accessor.RenderItemAccessor", - "oneconfig.ConfigMixin" + "accessor.RenderItemAccessor" ], - "verbose": true + "verbose": true, + "client": [ + "ItemEntityRendererMixin_HandleCameraTransforms", + "ItemRendererMixin_HandleCameraTransforms" + ] } \ No newline at end of file diff --git a/stonecutter.gradle.kts b/stonecutter.gradle.kts new file mode 100644 index 0000000..fdbf14f --- /dev/null +++ b/stonecutter.gradle.kts @@ -0,0 +1,48 @@ +plugins { + id("dev.kikugie.stonecutter") +} + +stonecutter active "1.8.9" /* [SC] DO NOT EDIT */ + +stonecutter { + tasks { + order("publishModrinth") + } + + parameters { + replacements { + string(eval(current.version, "= 1.8.9")) { + replace( + "com.mojang.blaze3d.platform.InputConstants", + "org.polyfrost.oneconfig.internal.legacy.InputConstants" + ) + replace( + "net.minecraft.server.Bootstrap", + "net.minecraft.Bootstrap" + ) + replace( + "net.minecraft.client.player.KeyboardInput", + "net.minecraft.client.entity.living.player.KeyboardInput" + ) + replace( + "net.minecraft.world.entity.Entity", + "net.minecraft.entity.Entity" + ) + } + } + } +} + +stonecutter parameters { + constants { + val legacy = current.version == "1.8.9" + this["legacy"] = legacy + this["modern"] = !legacy + } + + replacements { + string(current.parsed < "26.1") { + replace("classTweaker v1 official", "classTweaker v1 named") + } + } +} \ No newline at end of file diff --git a/stonecutter.properties.toml b/stonecutter.properties.toml new file mode 100644 index 0000000..a5af49d --- /dev/null +++ b/stonecutter.properties.toml @@ -0,0 +1,22 @@ +mod.id = "glintcolorizer" +mod.name = "GlintColorizer" +mod.group = "org.polyfrost" +mod.version = "3.0.0" +mod.description = "Change the color of the enchantment glint!" +license = "GPL-3.0-or-later" + +deps.fabric_loader = "0.19.3" +deps.oneconfig = "1.1.15" +deps.junit = "6.1.3" + +loomx.loom_version = "1.17-SNAPSHOT" + +publish.modrinth = "SevsTfWN" + +["1.8.9"] +mod.mc_compat = "1.8.9" +mod.mc_releases = ["1.8.9"] +feather_build = 1 +deps.osl_core = "0.10.0+mc14w27a-mc1.14.4" +deps.osl_entrypoints = "0.6.1+mc13w16a-mc1.14.4" +deps.osl_lifecycle_events = "0.6.1+mc13w36a-mc19w07a" \ No newline at end of file diff --git a/versions/1.12.2-1.8.9.txt b/versions/1.12.2-1.8.9.txt deleted file mode 100644 index 2b1bf6c..0000000 --- a/versions/1.12.2-1.8.9.txt +++ /dev/null @@ -1,2 +0,0 @@ -net.minecraft.client.renderer.RenderItem net.minecraft.client.renderer.entity.RenderItem -net.minecraft.client.renderer.block.model.IBakedModel net.minecraft.client.resources.model.IBakedModel \ No newline at end of file diff --git a/versions/1.17.1-fabric/gradle.properties b/versions/1.17.1-fabric/gradle.properties deleted file mode 100644 index 15676fd..0000000 --- a/versions/1.17.1-fabric/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -fabricLanguageKotlinVersion=1.7.1+kotlin.1.6.10 -fabricApiVersion=0.46.1+1.17 -modMenuVersion=2.0.14 \ No newline at end of file diff --git a/versions/1.17.1-forge/gradle.properties b/versions/1.17.1-forge/gradle.properties deleted file mode 100644 index e69de29..0000000 diff --git a/versions/1.18.1-fabric/gradle.properties b/versions/1.18.1-fabric/gradle.properties deleted file mode 100644 index 897565f..0000000 --- a/versions/1.18.1-fabric/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -fabricLanguageKotlinVersion=1.7.1+kotlin.1.6.10 -fabricApiVersion=0.46.4+1.18 -modMenuVersion=3.0.1 \ No newline at end of file diff --git a/versions/mainProject b/versions/mainProject deleted file mode 100644 index dd1433e..0000000 --- a/versions/mainProject +++ /dev/null @@ -1 +0,0 @@ -1.8.9-forge \ No newline at end of file