diff --git a/build.gradle b/build.gradle index cd4b4cf..e733aab 100644 --- a/build.gradle +++ b/build.gradle @@ -2,15 +2,48 @@ plugins { id 'groovy' id 'maven-publish' id 'signing' - alias libs.plugins.quilt.loom - alias libs.plugins.quilt.licenser - alias libs.plugins.mdg.plugin - alias libs.plugins.simpleci - alias libs.plugins.cursegradle + alias libs.plugins.fabric.loom + alias libs.plugins.mdg + alias libs.plugins.managedversioning + alias libs.plugins.curseforgegradle alias libs.plugins.minotaur alias libs.plugins.nexuspublish } +managedVersioning { + versionFile.set rootProject.file('version.properties') + + gitHubActions { + release { + prettyName.set 'Release' + workflowDispatch.set(true) + gradleJob { + name.set 'build' + step { + setupGitUser() + } + readOnly.set false + gradlew 'Tag Release', 'tagRelease' + gradlew 'Build', 'build' + step { + run.set 'git push && git push --tags' + } + gradlew 'Publish', 'publish', 'closeAndReleaseSonatypeStagingRepository', 'curseforge', 'modrinth' + secret('CENTRAL_MAVEN_USER') + secret('CENTRAL_MAVEN_PASSWORD') + secret('GPG_GPG_SIGNING_KEY') + secret('GPG_KEY_PASSWORD') + secret('CURSEFORGE_KEY') + secret('MODRINTH_KEY') + } + } + } +} + +managedVersioning.apply() + +println "Building: $version" + java { toolchain { languageVersion = JavaLanguageVersion.of(17) @@ -18,66 +51,21 @@ java { withSourcesJar() } -final mavenLoginUser = (System.getenv('MAVEN_USER') ?: findProperty('inquisitionMavenUser')) ?: '' -final mavenLoginPassword = (System.getenv('MAVEN_PASSWORD') ?: findProperty('inquisitionMavenPassword')) ?: '' - -tasks.changelog { - gitDir = projectDir - start = '2.1.1' -} - import net.fabricmc.loom.task.RemapJarTask -import org.eclipse.jgit.api.Git - -versioning { - fromTag.set('2.1.1') -} -final calculatedVersion = Git.open(projectDir).withCloseable { - versioning.calculateVersion(it) { cm, info -> } -} -final versionBasedReleaseType = calculatedVersion.alphaBeta.betaNumber != -1 ? 'beta' : (calculatedVersion.alphaBeta.alphaNumber != -1 ? 'alpha' : 'release') -allprojects { Project proj -> - println("${proj.name} version: ${proj.version = calculatedVersion.toString()}") -} -license { - rule project.file('header.txt') - exclude '**/*.mcmeta' -} - -static String getGitCommit() { - def proc = 'git rev-parse --short HEAD'.execute() - proc.waitFor() - if (proc.exitValue()) { - throw new RuntimeException("Failed to get git commit: ERROR(${proc.exitValue()})") - } - return proc.text.trim() -} - -static String getGitCommitDate() { - def procDate = 'git log -1 --format=%at'.execute() - procDate.waitFor() - if (procDate.exitValue()) { - throw new RuntimeException("Failed to get git commit time: ERROR(${procDate.exitValue()})") +loom { + mods { + groovyduvet_test { + sourceSet 'test' + } } - long timestamp = procDate.text.trim() as long * 1000 - return new Date(timestamp).format(/yyyy-MM-dd HH:mm:ssZ/, TimeZone.getTimeZone("UTC")) -} -loom { runs.each { it.source sourceSets.test } } repositories { - maven { - name = "TheModdingInquisition" - url = 'https://maven.moddinginquisition.org/releases' - content { - includeGroup 'org.groovymc.cgl' - } - } maven { name = 'ParchmentMC' url = 'https://maven.parchmentmc.org' @@ -87,29 +75,31 @@ repositories { } } -modsDotGroovy { - dslVersion = libs.versions.mdg.dsl.get() - platform 'quilt' - source.set sourceSets.main -} - -import io.github.groovymc.modsdotgroovy.ConvertToQuiltJsonTask +sourceSets.test.modsDotGroovy.enable() -task ('testModsDotGroovyToQuiltJson', type: ConvertToQuiltJsonTask) { - input.set new File(sourceSets.test.resources.sourceDirectories.singleFile, 'mods.groovy') - output.set project.layout.buildDirectory.dir('testModsDotGroovyToQuiltJson').map {it.file('quilt.mod.json')} -} +configurations { + javadocElements { + canBeConsumed = true + canBeResolved = false + attributes { + attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.class, Usage.JAVA_RUNTIME)) + attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.class, Category.DOCUMENTATION)) + attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.class, Bundling.EXTERNAL)) + attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType.class, DocsType.JAVADOC)) + } + } -processTestResources { - exclude 'mods.groovy' - dependsOn tasks.testModsDotGroovyToQuiltJson - from tasks.testModsDotGroovyToQuiltJson.output -} + groovydocInclude { + attributes { + attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.class, Category.DOCUMENTATION)) + attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType.class, DocsType.SOURCES)) + } + transitive = false + } -configurations { - groovydocInclude - runtimePrivate - runtimeClasspath.extendsFrom(runtimePrivate) + localApi + compileOnlyApi.extendsFrom localApi + runtimeClasspath.extendsFrom localApi } dependencies { @@ -118,27 +108,23 @@ dependencies { officialMojangMappings() parchment("org.parchmentmc.data:parchment-${libs.versions.parchment.minecraft.get()}:${libs.versions.parchment.mappings.get()}@zip") } - modImplementation libs.quilt.loader - modImplementation libs.qsl + + modImplementation libs.fabric.loader + modImplementation libs.fabric.api annotationProcessor libs.autoextension annotationProcessor libs.autoservice compileOnly libs.autoextension compileOnly libs.autoservice - compileOnlyApi libs.groovyduvet.core + localApi libs.groovyduvet.core include libs.groovyduvet.core - runtimePrivate libs.groovyduvet.core include libs.cgl - modApi(libs.cgl) { - exclude group: 'org.apache.groovy' - } + modApi libs.cgl - groovydocInclude("org.groovymc.cgl:cgl-${libs.versions.minecraft.get()}:${libs.versions.cgl.get()}:sources") { - transitive = false - } - groovydocInclude("org.groovymc.groovyduvet:groovyduvet-core:${libs.versions.groovyduvet.core.get()}:sources") + groovydocInclude libs.cgl + groovydocInclude libs.groovyduvet.core } tasks.named('jar', Jar) { @@ -152,8 +138,8 @@ tasks.named('jar', Jar) { 'Implementation-Title':"${archivesBaseName}", 'Implementation-Version': project.version, 'Implementation-Vendor' : 'Luke Bemish', - 'Implementation-Commit-Time': getGitCommitDate(), - 'Implementation-Commit': getGitCommit() + 'Implementation-Commit-Time': managedVersioning.timestamp, + 'Implementation-Commit': managedVersioning.hash ]) } @@ -175,6 +161,19 @@ tasks.register("remapFullJar", RemapJarTask) { tasks.build.dependsOn(tasks.remapFullJar) +tasks.register("devTestJar", Jar) { + from(sourceSets.test.output) + archiveClassifier.set 'test-dev' +} + +tasks.register("testJar", RemapJarTask) { + it.targetNamespace = "intermediary" + it.inputFile = tasks.devTestJar.archiveFile + it.dependsOn tasks.devTestJar + it.archiveClassifier.set 'test' + it.addNestedDependencies = false +} + tasks.withType(GroovyCompile).configureEach { groovyOptions.optimizationOptions.indy = true groovyOptions.optimizationOptions.groovydoc = true @@ -201,9 +200,18 @@ groovydoc { } tasks.register('groovydocJar', Jar) { - dependsOn groovydoc - archiveClassifier.set 'javadoc' + archiveClassifier = 'javadoc' from groovydoc.destinationDir + dependsOn(groovydoc) +} + +artifacts { + javadocElements groovydocJar +} + +project.components.named("java").configure { + AdhocComponentWithVariants javaComponent = (AdhocComponentWithVariants) it + javaComponent.addVariantsFromConfiguration(configurations.javadocElements) {} } tasks.build.dependsOn(tasks.groovydocJar) @@ -211,20 +219,12 @@ tasks.build.dependsOn(tasks.groovydocJar) publishing { publications { mavenJava(MavenPublication) { - groupId project.group - version project.version from components.java - artifact tasks.groovydocJar - artifact(tasks.changelog.output.get().asFile) { - it.builtBy tasks.changelog - it.extension = 'txt' - it.classifier = 'changelog' - } pom { name = "GroovyDuvet" packaging = 'jar' - description = 'Wrapper library for mods written in groovy for the quilt loader' + description = 'Wrapper library for mods written in groovy for the fabric loader' url = 'https://github.com/GroovyMC/GroovyDuvet' inceptionYear = '2023' @@ -254,63 +254,57 @@ publishing { nexusPublishing { repositories { sonatype { - username.set(System.getenv('SONATYPE_USER') ?: '') - password.set(System.getenv('SONATYPE_PASSWORD') ?: '') + username.set(System.getenv('CENTRAL_MAVEN_USER') ?: '') + password.set(System.getenv('CENTRAL_MAVEN_PASSWORD') ?: '') nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) } } } -if (System.getenv('SONATYPE_USER')) { +if (System.getenv('CENTRAL_MAVEN_USER')) { signing { - final signingKey = System.getenv('SIGNING_KEY') ?: '' - final signingPassword = System.getenv('SIGNING_PASSWORD') ?: '' + final signingKey = System.getenv('GPG_SIGNING_KEY') ?: '' + final signingPassword = System.getenv('GPG_KEY_PASSWORD') ?: '' useInMemoryPgpKeys(signingKey, signingPassword) sign publishing.publications.mavenJava } } -curseforge { - apiKey = System.getenv('CURSEFORGE_TOKEN') ?: '' - project { - id = '665821' - releaseType = "${versionBasedReleaseType}" - addGameVersion "${libs.versions.minecraft.get()}" - addGameVersion 'Quilt' - mainArtifact(tasks.remapFullJar) { - displayName = "GroovyDuvet v$project.version" - } - relations { - requiredDependency 'qsl' +if (System.getenv('MODRINTH_KEY')) { + modrinth { + token = System.getenv('MODRINTH_KEY') ?: '' + projectId = 'groovyduvet' + versionNumber = "$project.version" + versionType = "${project.release_type}" + detectLoaders = false + uploadFile = tasks.remapFullJar + gameVersions = ["${libs.versions.minecraft.get()}"] + loaders = ['quilt', 'fabric'] + dependencies { + required.project 'fabric-api' } - changelog = tasks.changelog.output.asFile.get() - } - options { - forgeGradleIntegration = false } } -tasks.named('curseforge') { - dependsOn tasks.changelog -} - -modrinth { - token = System.getenv('MODRINTH_TOKEN') ?: '' - projectId = 'groovyduvet' - versionNumber = "$project.version" - versionType = "${versionBasedReleaseType}" - detectLoaders = false - uploadFile = tasks.remapFullJar - gameVersions = ["${libs.versions.minecraft.get()}"] - loaders = ['quilt'] - changelog.set(tasks.changelog.output.map { - it.asFile.text - }) - dependencies { - required.project 'qsl' +import net.darkhax.curseforgegradle.TaskPublishCurseForge + +if (System.getenv('CURSEFORGE_KEY')) { + tasks.register('curseforge', TaskPublishCurseForge) { + dependsOn tasks.remapFullJar + disableVersionDetection() + apiToken = System.getenv('CURSEFORGE_KEY') + def projectId = '665821' + def mainFile = upload(projectId, tasks.remapFullJar) + mainFile.displayName = "GroovyDuvet v$project.version" + mainFile.releaseType = "${project.release_type}" + mainFile.addModLoader('Fabric') + mainFile.addModLoader('Quilt') + mainFile.addGameVersion("${libs.versions.minecraft.get()}") + mainFile.changelog = '' + mainFile.addRequirement("fabric-api") } -} -tasks.named('modrinth') { - dependsOn(tasks.changelog) + afterEvaluate { + tasks.curseforge.dependsOn tasks.remapFullJar + } } diff --git a/gradle.properties b/gradle.properties index 5f2fbc0..efa35d7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,6 @@ -org.gradle.jvmargs = -Xmx3G -org.gradle.daemon = false +org.gradle.jvmargs=-Xmx3G +org.gradle.daemon=false # Mod Properties -group = org.groovymc.groovyduvet +group=org.groovymc.groovyduvet +release_type=release diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4dfb988..4e4fb6e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,44 +1,39 @@ [versions] # The latest versions are available at https://lambdaurora.dev/tools/import_quilt.html -minecraft = "1.20" -quilt_loader = "0.18.10" -parchment_minecraft = "1.19.3" -parchment_mappings = "2023.03.12" -qsl = "6.0.1+1.20" -quilt_loom = "1.4.1" -quilt_licenser = "2.0.1" -cgl = "0.3.8" +minecraft = "1.20.4" +fabric_loader = "0.15.3" +fabric_api = "0.92.0+1.20.4" +parchment_minecraft = "1.20.2" +parchment_mappings = "2023.12.10" +fabric_loom = "1.5.8" +cgl = "0.4.1" autoservice = "1.1.1" autoextension = "0.1.1" -mdg_plugin = "1.4.1" -mdg_dsl = "1.5.1" -simpleci = "0.2.5" +mdg = "2.0.0-beta.16" minotaur = "2.8.4" -cursegradle = "1.4.0" -nexuspublish = "1.3.0" +curseforgegradle = "1.1.16" +managedversioning = "1.2.8" +nexuspublish = "2.0.0-rc-1" -groovyduvet_core = "3.1.2" +groovyduvet_core = "3.1.6" [libraries] minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" } -quilt_loader = { module = "org.quiltmc:quilt-loader", version.ref = "quilt_loader" } -qsl = { module = "org.quiltmc:qsl", version.ref = "qsl" } +fabric_loader = { module = "net.fabricmc:fabric-loader", version.ref = "fabric_loader" } +fabric_api = { module = "net.fabricmc.fabric-api:fabric-api", version.ref = "fabric_api" } -cgl = { module = "org.groovymc.cgl:cgl-1.20-quilt", version.ref = "cgl" } +cgl = { module = "org.groovymc.cgl:cgl-1.20.4-fabric", version.ref = "cgl" } autoservice = { module = "com.google.auto.service:auto-service", version.ref = "autoservice" } autoextension = { module = "dev.lukebemish.autoextension:autoextension", version.ref = "autoextension" } -mdg_dsl = { module = "org.groovymc.modsdotgroovy:dsl", version.ref = "mdg_dsl" } - groovyduvet_core = { module = "org.groovymc.groovyduvet:groovyduvet-core", version.ref = "groovyduvet_core" } [plugins] -quilt_loom = { id = "org.quiltmc.loom", version.ref = "quilt_loom" } -quilt_licenser = { id = "org.quiltmc.gradle.licenser", version.ref = "quilt_licenser" } -mdg_plugin = { id = "org.groovymc.modsdotgroovy", version.ref = "mdg_plugin" } +fabric_loom = { id = "fabric-loom", version.ref = "fabric_loom" } +mdg = { id = "org.groovymc.modsdotgroovy", version.ref = "mdg" } -simpleci = { id = "org.groovymc.simpleci", version.ref = "simpleci" } -cursegradle = { id = "com.matthewprenger.cursegradle", version.ref = "cursegradle" } +managedversioning = { id = "dev.lukebemish.managedversioning", version.ref = "managedversioning" } +curseforgegradle = { id = "net.darkhax.curseforgegradle", version.ref = "curseforgegradle" } minotaur = { id = "com.modrinth.minotaur", version.ref = "minotaur" } nexuspublish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexuspublish" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 033e24c..7f93135 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ac72c34..a80b22c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 79a61d4..1aa94a4 100755 --- a/gradlew +++ b/gradlew @@ -83,10 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,10 +131,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/header.txt b/header.txt deleted file mode 100644 index 3b391b5..0000000 --- a/header.txt +++ /dev/null @@ -1,5 +0,0 @@ -Copyright (C) ${YEAR} Luke Bemish, GroovyMC, and contributors -SPDX-License-Identifier: LGPL-3.0-or-later - -;;year_display: lenient_range -;;year_selection: file diff --git a/settings.gradle b/settings.gradle index 390d9c5..5d07fad 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,19 +1,38 @@ pluginManagement { repositories { - maven { - name = "Quilt" - url = uri("https://maven.quiltmc.org/repository/release") - } maven { name = "Fabric" url = uri("https://maven.fabricmc.net/") } + maven { + name = "Luke's Maven" + url = 'https://maven.lukebemish.dev/releases/' + } + mavenCentral() gradlePluginPortal() } } +// Loom needs this version, foojay brings in an older one +buildscript { + dependencies { + classpath("com.google.code.gson:gson:2.10.1") + } +} + plugins { + id 'com.gradle.enterprise' version '3.15' id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0' } +gradleEnterprise { + if (System.getenv('CI') != null) { + buildScan { + publishAlways() + termsOfServiceUrl = "https://gradle.com/terms-of-service" + termsOfServiceAgree = "yes" + } + } +} + rootProject.name = 'groovyduvet' diff --git a/src/main/groovy/org/groovymc/groovyduvet/wrapper/extension/client/RenderExtension.groovy b/src/main/groovy/org/groovymc/groovyduvet/wrapper/extension/client/RenderExtension.groovy index 51b378f..ec7e749 100644 --- a/src/main/groovy/org/groovymc/groovyduvet/wrapper/extension/client/RenderExtension.groovy +++ b/src/main/groovy/org/groovymc/groovyduvet/wrapper/extension/client/RenderExtension.groovy @@ -1,29 +1,24 @@ -/* - * Copyright (C) 2022-2023 Luke Bemish, GroovyMC, and contributors - * SPDX-License-Identifier: LGPL-3.0-or-later - */ - package org.groovymc.groovyduvet.wrapper.extension.client import dev.lukebemish.autoextension.AutoExtension import groovy.transform.CompileStatic +import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap import net.minecraft.client.renderer.RenderType import net.minecraft.world.level.block.Block import net.minecraft.world.level.material.Fluid -import org.quiltmc.loader.api.minecraft.ClientOnly -import org.quiltmc.qsl.block.extensions.api.client.BlockRenderLayerMap +import org.groovymc.cgl.api.extension.EnvironmentExtension @CompileStatic -@ClientOnly +@EnvironmentExtension(EnvironmentExtension.Side.CLIENT) @AutoExtension class RenderExtension { static RenderType leftShift(RenderType layer, Block block) { - BlockRenderLayerMap.put(layer, block) + BlockRenderLayerMap.INSTANCE.putBlock(block, layer) return layer } static RenderType leftShift(RenderType layer, Fluid fluid) { - BlockRenderLayerMap.put(layer, fluid) + BlockRenderLayerMap.INSTANCE.putFluid(fluid, layer) return layer } } diff --git a/src/main/groovy/org/groovymc/groovyduvet/wrapper/extension/client/StaticRenderExtension.groovy b/src/main/groovy/org/groovymc/groovyduvet/wrapper/extension/client/StaticRenderExtension.groovy index d4ae1d2..ca43d36 100644 --- a/src/main/groovy/org/groovymc/groovyduvet/wrapper/extension/client/StaticRenderExtension.groovy +++ b/src/main/groovy/org/groovymc/groovyduvet/wrapper/extension/client/StaticRenderExtension.groovy @@ -1,31 +1,26 @@ -/* - * Copyright (C) 2022-2023 Luke Bemish, GroovyMC, and contributors - * SPDX-License-Identifier: LGPL-3.0-or-later - */ - package org.groovymc.groovyduvet.wrapper.extension.client import dev.lukebemish.autoextension.AutoExtension import groovy.transform.CompileStatic +import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap import net.minecraft.client.renderer.ItemBlockRenderTypes import net.minecraft.client.renderer.RenderType import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.material.Fluid import net.minecraft.world.level.material.FluidState -import org.quiltmc.loader.api.minecraft.ClientOnly -import org.quiltmc.qsl.block.extensions.api.client.BlockRenderLayerMap +import org.groovymc.cgl.api.extension.EnvironmentExtension @CompileStatic -@ClientOnly +@EnvironmentExtension(EnvironmentExtension.Side.CLIENT) @AutoExtension(isStatic = true) class StaticRenderExtension { static void putAt(ItemBlockRenderTypes type, Block block, RenderType layer) { - BlockRenderLayerMap.put(layer, block) + BlockRenderLayerMap.INSTANCE.putBlock(block, layer) } static void putAt(ItemBlockRenderTypes type, Fluid fluid, RenderType layer) { - BlockRenderLayerMap.put(layer, fluid) + BlockRenderLayerMap.INSTANCE.putFluid(fluid, layer) } static RenderType getAt(ItemBlockRenderTypes type, Block block) { diff --git a/src/main/groovy/org/groovymc/groovyduvet/wrapper/extension/event/EventExtension.groovy b/src/main/groovy/org/groovymc/groovyduvet/wrapper/extension/event/EventExtension.groovy index 41c8a8f..3d8767a 100644 --- a/src/main/groovy/org/groovymc/groovyduvet/wrapper/extension/event/EventExtension.groovy +++ b/src/main/groovy/org/groovymc/groovyduvet/wrapper/extension/event/EventExtension.groovy @@ -1,15 +1,10 @@ -/* - * Copyright (C) 2022-2023 Luke Bemish, GroovyMC, and contributors - * SPDX-License-Identifier: LGPL-3.0-or-later - */ - package org.groovymc.groovyduvet.wrapper.extension.event import dev.lukebemish.autoextension.AutoExtension import groovy.transform.CompileStatic - +import net.fabricmc.fabric.api.event.Event import net.minecraft.resources.ResourceLocation -import org.quiltmc.qsl.base.api.event.Event +import org.jetbrains.annotations.ApiStatus @CompileStatic @AutoExtension @@ -18,17 +13,14 @@ class EventExtension { return event.invoker() } - static void add(Event event, T toRegister) { - Class clazz = event.type - event.register((T) toRegister.asType(clazz)) - } - - static void leftShift(Event event, T toRegister) { - add(event, toRegister) + @ApiStatus.Experimental + static Event leftShift(Event event, T toRegister) { + event.register(toRegister) + event.invoker() + return event } - static void add(Event event, ResourceLocation phase, T toRegister) { - Class clazz = event.type - event.register(phase, (T) toRegister.asType(clazz)) + static EventPhase getAt(Event event, ResourceLocation phase) { + return new EventPhase<>(event, phase) } } diff --git a/src/main/groovy/org/groovymc/groovyduvet/wrapper/extension/event/EventPhase.groovy b/src/main/groovy/org/groovymc/groovyduvet/wrapper/extension/event/EventPhase.groovy new file mode 100644 index 0000000..8bb8521 --- /dev/null +++ b/src/main/groovy/org/groovymc/groovyduvet/wrapper/extension/event/EventPhase.groovy @@ -0,0 +1,24 @@ +package org.groovymc.groovyduvet.wrapper.extension.event + +import groovy.transform.CompileStatic +import groovy.transform.PackageScope +import net.fabricmc.fabric.api.event.Event +import net.minecraft.resources.ResourceLocation +import org.jetbrains.annotations.ApiStatus + +@CompileStatic +class EventPhase { + private final Event event + private final ResourceLocation phase + + @PackageScope + EventPhase(Event event, ResourceLocation phase) { + this.event = event + this.phase = phase + } + + @ApiStatus.Experimental + void leftShift(T toRegister) { + this.event.register(this.phase, toRegister) + } +} diff --git a/src/main/resources/mods.groovy b/src/main/resources/mods.groovy index a7794eb..1fcb4a0 100644 --- a/src/main/resources/mods.groovy +++ b/src/main/resources/mods.groovy @@ -1,27 +1,24 @@ -/* - * Copyright (C) 2022-2023 Luke Bemish, GroovyMC, and contributors - * SPDX-License-Identifier: LGPL-3.0-or-later - */ - -ModsDotGroovy.make { - issueTrackerUrl = 'https://github.com/GroovyMC/groovyduvet/issues' +FabricModsDotGroovy.make { license = 'LGPL-3.0-or-later' - mod { - modId = 'groovyduvet' - version = this.version - group = this.group - displayName = 'GroovyDuvet' - description = 'Language adapter and wrapper libraries for Groovy mods on Quilt' - author 'Luke Bemish' - intermediate_mappings = "net.fabricmc:intermediary" - dependencies { - quiltLoader = ">=${this.quiltLoaderVersion}" - minecraft = "~${this.minecraftVersion}" - groovyduvet_core = ">=${this.libs.versions.groovyduvet.core}" - commongroovylibrary = ">=${this.libs.versions.cgl}" - } - displayUrl = 'https://github.com/GroovyMC/groovyduvet' - logoFile = 'assets/groovyduvet/icon.png' + contact { + issues = 'https://github.com/GroovyMC/groovyduvet/issues' + sources = 'https://github.com/GroovyMC/groovyduvet' + } + icon = 'assets/groovyduvet/icon.png' + id = 'groovyduvet' + version = environmentInfo.version + name = 'GroovyDuvet' + description = 'Language adapter and wrapper libraries for Groovy mods on Quilt/Fabric' + authors { + person 'Luke Bemish' + } + depends { + fabricloader = ">=${libs.versions.fabric_loader}" + minecraft = "~${libs.versions.minecraft}" + groovyduvet_core = ">=${libs.versions.groovyduvet_core}" + commongroovylibrary = ">=${libs.versions.cgl}" + } + custom { + modmenu = ['badges': ['library']] } - modmenu = ['badges':['library']] } diff --git a/src/test/groovy/org/groovymc/groovyduvet/test/TestMod.groovy b/src/test/groovy/org/groovymc/groovyduvet/test/TestMod.groovy index a963465..c0e4aec 100644 --- a/src/test/groovy/org/groovymc/groovyduvet/test/TestMod.groovy +++ b/src/test/groovy/org/groovymc/groovyduvet/test/TestMod.groovy @@ -1,8 +1,3 @@ -/* - * Copyright (C) 2022-2023 Luke Bemish, GroovyMC, and contributors - * SPDX-License-Identifier: LGPL-3.0-or-later - */ - package org.groovymc.groovyduvet.test import blue.endless.jankson.JsonGrammar @@ -11,6 +6,7 @@ import com.electronwill.nightconfig.toml.TomlWriter import com.mojang.serialization.Codec import groovy.json.JsonOutput import groovy.transform.* +import net.fabricmc.fabric.api.networking.v1.EntityTrackingEvents import org.groovymc.cgl.api.codec.JanksonOps import org.groovymc.cgl.api.codec.ObjectOps import org.groovymc.cgl.api.codec.TomlConfigOps @@ -25,7 +21,6 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.util.valueproviders.IntProvider import net.minecraft.util.valueproviders.UniformInt import net.minecraft.world.level.block.Blocks -import org.quiltmc.qsl.networking.api.EntityTrackingEvents @Immutable(knownImmutableClasses = [Optional]) @CodecSerializable @@ -33,8 +28,8 @@ import org.quiltmc.qsl.networking.api.EntityTrackingEvents class Test { int i String value - @WithCodec(value = { IntProvider.NON_NEGATIVE_CODEC }, path = WithCodecPath.LIST) List ints - @WithCodec(value = { IntProvider.NON_NEGATIVE_CODEC }, path = WithCodecPath.OPTIONAL) Optional maybeInt + @WithCodec(value = { IntProvider.NON_NEGATIVE_CODEC }, target = [0]) List ints + @WithCodec(value = { IntProvider.NON_NEGATIVE_CODEC }, target = [0]) Optional maybeInt } @KnownImmutable @@ -106,12 +101,12 @@ println CodecRetriever[TestTupleCodecBuilder].decode(ObjectOps.instance,map).get println BuiltInRegistries.BLOCK[new ResourceLocation('stone')] //noinspection GroovyAssignabilityCheck -EntityTrackingEvents.AFTER_START_TRACKING << { entity, player -> +EntityTrackingEvents.START_TRACKING << ({ entity, player -> player.sendSystemMessage Component.literal("Test") << Style.of { style ChatFormatting.DARK_BLUE strikethrough = true } -} +} as EntityTrackingEvents.StartTracking) @CompileStatic @TupleConstructor @@ -144,6 +139,8 @@ class TestCommentedCodec { List testList } +println TestCommentedCodec.$CODEC + final toml = TestCommentedCodec.$CODEC.encodeStart(TomlConfigOps.COMMENTED, new TestCommentedCodec('Stuff',5,3.0,[new TestStruct(3),new TestStruct(5)])).getOrThrow(false, {}) println new TomlWriter().writeToString(toml as UnmodifiableCommentedConfig) diff --git a/src/test/resources/mods.groovy b/src/test/resources/mods.groovy index 9122ab4..4694a80 100644 --- a/src/test/resources/mods.groovy +++ b/src/test/resources/mods.groovy @@ -1,30 +1,15 @@ -/* - * Copyright (C) 2022-2023 Luke Bemish, GroovyMC, and contributors - * SPDX-License-Identifier: LGPL-3.0-or-later - */ - -ModsDotGroovy.make { - issueTrackerUrl = 'https://github.com/GroovyMC/groovyduvet/issues' +FabricModsDotGroovy.make { license = 'LGPL-3.0-or-later' - mod { - modId = 'groovyduvet_test' - version = this.version - group = this.group - displayName = 'GroovyDuvet Test Mod' - description = 'Test Mod for GroovyDuvet' - author 'Luke Bemish' - intermediate_mappings = "net.fabricmc:intermediary" - dependencies { - quiltLoader = ">=${this.quiltLoaderVersion}" - minecraft = "~${this.minecraftVersion}" - groovyduvet = ">=${this.version}" - } - displayUrl = 'https://github.com/GroovyMC/groovyduvet' - entrypoints { - client_init = adapted { - adapter = 'groovyduvet' - value = 'org.groovymc.groovyduvet.test.TestMod' - } + id = 'groovyduvet_test' + version = environmentInfo.version + name = 'GroovyDuvet - Test' + depends { + groovyduvet = ">=${environmentInfo.version}" + } + entrypoints { + entrypoint('main') { + adapter = 'groovyduvet' + value = 'org.groovymc.groovyduvet.test.TestMod' } } } diff --git a/version.properties b/version.properties new file mode 100644 index 0000000..19a0188 --- /dev/null +++ b/version.properties @@ -0,0 +1 @@ +version=4.0.0