### Configure Build Script for Fabric Modding (Kotlin and Groovy) Source: https://stonecutter.kikugie.dev/wiki/start/builds Sets up the build script to include necessary plugins, dependencies like Minecraft, Fabric API, and loader, and configures resource processing for mod metadata. It also defines run configurations for IDE integration. ```kotlin plugins { id("fabric-loom") version "1.13-SNAPSHOT" } dependencies { minecraft("com.mojang:minecraft:${stonecutter.current.project}") mappings("net.fabricmc:yarn:${property("deps.yarn_mappings")}:v2") modImplementation("net.fabricmc:fabric-loader:${property("deps.fabric_loader")}") modImplementation("net.fabricmc.fabric-api:fabric-api:${property("deps.fabric_api")}") } tasks.processResources { inputs.property("minecraft", stonecutter.current.version) filesMatching("fabric.mod.json") { expand(mapOf( "minecraft" to stonecutter.current.version )) } } loom { runConfigs.all { ideConfigGenerated(true) // Run configurations are not created for subprojects by default runDir = "../../run" // Use a shared run folder and create separate worlds } } ``` ```groovy plugins { id "fabric-loom" version "1.13-SNAPSHOT" } dependencies { minecraft "com.mojang:minecraft:${stonecutter.current.project}" mappings "net.fabricmc:yarn:${property('deps.yarn_mappings')}:v2" modImplementation "net.fabricmc:fabric-loader:${property('deps.fabric_loader')}" modImplementation "net.fabricmc.fabric-api:fabric-api:${property('deps.fabric_api')}" } processResources { inputs.property "minecraft", stonecutter.current.version filesMatching("fabric.mod.json") { expand "minecraft": stonecutter.current.version } } loom { runConfigs.all { ideConfigGenerated true // Run configurations are not created for subprojects by default runDir "../../run" // Use a shared run folder and create separate worlds } } ``` -------------------------------- ### Java Code Example for Version Verification Source: https://stonecutter.kikugie.dev/wiki/config/params Demonstrates a Java code snippet that verifies the current version using MyEntryPoint. The example showcases how imports change based on the package name. ```java import io.github.me.MyEntrypoint; import io.github.me.data.Version; public void example() { MyEntryPoint.verifyVersion(Version.LATEST); } ``` ```java import dev.me.MyEntrypoint; import dev.me.data.Version; public void example() { MyEntryPoint.verifyVersion(Version.LATEST); } ``` -------------------------------- ### Use Swaps with Parameters in Java Source: https://stonecutter.kikugie.dev/wiki/config/params Provides an example of how to invoke a Stonecutter swap with arguments in Java code, demonstrating parameter substitution. ```java void main() { //$ my_swap argument '"long quoted string"' method1(argument, "long quoted string"); } ``` -------------------------------- ### Java: Closed Scope Example for Swaps Source: https://stonecutter.kikugie.dev/wiki/config/params Shows how closed scopes in Java can be used for swap operations, denoted by a specific symbol. ```java void example() { //$ swap_id { action1(); action2(); //?} } ``` -------------------------------- ### Example Commenter for '#'-prefixed comments Source: https://stonecutter.kikugie.dev/wiki/config/handlers Provides a naive implementation of a commenter function for lines prefixed with '#'. It joins lines and prepends '#' to each. This example highlights potential issues with indentation and closed comments. ```kotlin comment { scope -> val lines = scope.lines() lines.joinToString { "#$it" } } ``` -------------------------------- ### Java: Word Scope Example Source: https://stonecutter.kikugie.dev/wiki/config/params Shows the word scope in Java, which captures characters up to the first space in a line, useful for commenting specific parameters. ```java void example() { Clazz.method(/*? condition >>*/param ); // commented up to the first space ^ } ``` -------------------------------- ### Apply Fletching Table Plugin Standalone Gradle Source: https://stonecutter.kikugie.dev/wiki/fletching-table/setup Applies the standalone version of the Fletching Table Gradle plugin. This setup is for projects that do not rely on specific mod loaders like Fabric or Neoforge. It requires the plugin to be available in the configured repositories. ```kotlin plugins { id("dev.kikugie.fletching-table") version "0.1.0-alpha.22" } ``` -------------------------------- ### Kotlin: If-Else Control Flow Example Source: https://stonecutter.kikugie.dev/wiki/config/params Demonstrates the basic structure of scopes in Kotlin using if-else statements, similar to how Stonecutter organizes code blocks. ```kotlin if (condition1) { // Scope of the `condition1` branch action1() action2() } else // Scope of the `else` branch action3() ``` -------------------------------- ### Example fabric.mod.json with Placeholders (JSON5) Source: https://stonecutter.kikugie.dev/wiki/tips/interface-injection This is an example of a fabric.mod.json file using JSON5 syntax, illustrating the potential conflict with resource processing techniques that use placeholders. When overriding the fabric.mod.json path, the unprocessed file must be valid JSON. This example shows unsupported placeholder usage like '${id}', '${version}', and '${injected_entry}', which can cause issues. ```json { "schemaVersion": 1, "id": "${id}", "version": "${version}", // ... | this is unsupported ${injected_entry} } ``` -------------------------------- ### Java: Referencing Constants in Comments Source: https://stonecutter.kikugie.dev/wiki/config/params Provides an example of how to reference defined constants within Java comments for conditional compilation. ```java public static void example() { //? if my_const { MinecraftClass.method(); //?} } ``` -------------------------------- ### Java: Line Scope Example Source: https://stonecutter.kikugie.dev/wiki/config/params Demonstrates the line scope functionality in Java, where omitting the scope operator affects the next non-empty line or logical block. ```java void example() { //? condition action1(); action2(); // This line will not be commented } ``` -------------------------------- ### Conditional Logic with Version Predicates (Java) Source: https://stonecutter.kikugie.dev/wiki/config/params Illustrates the use of version predicates in Java for conditional logic within Stonecutter. The example uses the '~' (major and minor version equality) and '<' (less than) predicates to control method execution. ```java //? if ~1.20 <1.20.4 method(); ``` -------------------------------- ### Configure Maven Repository for Stonecutter Gradle Source: https://stonecutter.kikugie.dev/wiki/fletching-table/setup Configures the Maven repository for fetching Stonecutter snapshots. This is essential for the build process to locate the necessary artifacts. It specifies the URL and a display name for the repository. ```kotlin pluginManagement { repositories { maven("https://maven.kikugie.dev/snapshots") { name = "KikuGie Snapshots" } } } ``` -------------------------------- ### Java: Closed Scope Example for Conditions Source: https://stonecutter.kikugie.dev/wiki/config/params Illustrates the use of closed scopes in Java using `{` and `}` to define conditional blocks, which can be chained. ```java void example() { //? condition { action1(); action2(); //?} } ``` -------------------------------- ### Apply Fletching Table Plugin Neoforge Gradle Source: https://stonecutter.kikugie.dev/wiki/fletching-table/setup Applies the Fletching Table Gradle plugin with Neoforge integration. This version bundles the standalone plugin and is designed for Neoforge mod development. It can be used alongside Forge but with limitations. ```kotlin plugins { id("dev.kikugie.fletching-table.neoforge") version "0.1.0-alpha.22" } ``` -------------------------------- ### Java: Line Scope for Swap Operations Source: https://stonecutter.kikugie.dev/wiki/config/params Demonstrates using line scopes in Java for swap operations, affecting subsequent lines until a new logical block starts. ```java void example() { //$ swap id action1(); action2(); } ``` -------------------------------- ### Java: Line Scope Interruption Example Source: https://stonecutter.kikugie.dev/wiki/config/params Illustrates scope interruption in Java's line scope when a new condition is encountered within a commented block. ```java void example() { //? condition action1(/*? if condition 2 {*/ param /*?}*/); // ^ commented up to here because a new condition was started action2(); } ``` -------------------------------- ### Manual Mod Dependency Setup (Gradle) Source: https://stonecutter.kikugie.dev/wiki/fletching-table/dependencies Demonstrates how to manually specify mod dependencies using Curseforge Maven coordinates in a Gradle build script. Requires manually finding project and version IDs. ```kotlin repositories { maven("https://cursemaven.com") { name = "Curseforge" } } dependencies { modImplementation("curse.maven:lithium-360438:6713689") } ``` -------------------------------- ### AW to AT Conversion Example Source: https://stonecutter.kikugie.dev/wiki/fletching-table/accessconverters Demonstrates the conversion of a Fabric Access Wideners file (.aw) to a Forge Access Transformers format (.cfg). The example shows the input AW format and the corresponding AT output. ```aw accessWidener v2 named accessible method com/mojang/blaze3d/platform/NativeImage writeToChannel (Ljava/nio/channels/WritableByteChannel;)Z ``` ```accesstransformer public com.mojang.blaze3d.platform.NativeImage public com.mojang.blaze3d.platform.NativeImage writeToChannel(Ljava/nio/channels/WritableByteChannel;)Z ``` -------------------------------- ### Apply Fletching Table Plugin Fabric Gradle Source: https://stonecutter.kikugie.dev/wiki/fletching-table/setup Applies the Fletching Table Gradle plugin with Fabric integration. This version bundles the standalone plugin and is intended for Fabric mod development. Ensure Fabric dependencies are also set up in your project. ```kotlin plugins { id("dev.kikugie.fletching-table.fabric") version "0.1.0-alpha.22" } ``` -------------------------------- ### JSON Project Specification Examples for Stonecutter Source: https://stonecutter.kikugie.dev/wiki/config/projects Demonstrates the JSON format for declaring Stonecutter projects, including composite and primitive types for project names, versions, and build scripts. This allows for dynamic project configuration based on data. ```json { project: "snapshot", // Optional, defaulting to `project`. version: "1.21.9-snapshot", // Optional, defaulting to `centralScript` in `settings.gradle[.kts]`. buildscript: "snapshot.gradle.kts" } ``` ```json "snapshot:1.21.9-snapshot:snapshot.gradle.kts" ``` -------------------------------- ### Automated Mod Dependency Setup with Fletching Table (Gradle) Source: https://stonecutter.kikugie.dev/wiki/fletching-table/dependencies Shows how to set up Modrinth and Curseforge mavens using the Fletching Table plugin in a Gradle build script. This automates the process of finding mod IDs and versions. ```kotlin repositories { // The recommended way of setting up Modrinth/Curseforge mavens fun strictMaven(url: String, alias: String, vararg groups: String) = exclusiveContent { forRepository { maven(url) { name = alias } } filter { groups.forEach(::includeGroup) } } strictMaven("https://www.cursemaven.com", "Curseforge", "curse.maven") strictMaven("https://api.modrinth.com/maven", "Modrinth", "maven.modrinth") } dependencies { modImplementation(fletchingTable.modrinth("lithium", "1.21.7")) // or modImplementation(fletchingTable.curseforge("lithium", "1.21.7")) } ``` -------------------------------- ### Basic Commenter Configuration Source: https://stonecutter.kikugie.dev/wiki/config/handlers Defines a basic commenter configuration for Stonecutter. This function accepts a scope (string of text) and is expected to return a new string with comments added. The provided example is a placeholder for custom logic. ```kotlin stonecutter handlers { configure("aw", "accesswidener") { comment { scope: String -> // do something with it } } } ``` -------------------------------- ### Java Version-Specific Code Example Source: https://stonecutter.kikugie.dev/wiki/glossary Demonstrates how to use Stonecutter's comment preprocessor to conditionally include or exclude Java code based on the active project version. This is useful for managing compatibility across different releases. It requires the Stonecutter build tools to process the `//?` directives. ```java void example() { //? if >=1.21 { System.out.println("Hello Trails and Tails update!"); //?} else { /*System.out.println("Hello Tricky Trials!") *///?} } ``` -------------------------------- ### Java Version-Specific Code Example with VCS Reset Source: https://stonecutter.kikugie.dev/wiki/glossary Illustrates a scenario where version-specific code blocks in Java are affected by the active version, highlighting the need to reset the active project version before committing to avoid unintended diffs. This functionality relies on Stonecutter's preprocessor and VCS integration. ```java void example() { //? if >=1.21 { System.out.println("Hello Trails and Tails update!"); //?} else { /*System.out.println("Hello Tricky Trials!"); *///?} /*System.out.println("Hello Trails and Tails update!"); *///?} else { System.out.println("Hello Tricky Trials!"); //?} } ``` -------------------------------- ### JSON for Single Branch Project Versions in Stonecutter Source: https://stonecutter.kikugie.dev/wiki/config/projects Illustrates the JSON structure for defining a single branch of project versions in Stonecutter. It includes a schema definition and an example array of version strings and an object for a snapshot version. ```json { "$schema": "https://codeberg.org/stonecutter/stonecutter/src/branch/0.7/tools/settings-schema.json", "versions": [ "1.20.1", "1.21.1", "1.21.8", { "project": "snapshot", "version": "1.21.9-snapshot" } ] } ``` -------------------------------- ### Define Mod Properties in gradle.properties Source: https://stonecutter.kikugie.dev/wiki/start/builds Specifies essential mod details such as ID, version, and dependencies for different Minecraft versions. These properties are crucial for the build process and must be adapted for each version. ```properties mod.id=template mod.version=1.0.0 deps.fabric_loader=0.16.10 deps.yarn_mappings=[VERSIONED] deps.fabric_api=[VERSIONED] ``` ```properties deps.yarn_mappings=1.20.1+build.10 deps.fabric_api=0.92.1+1.20.1 ``` ```properties deps.yarn_mappings=1.21.1+build.3 deps.fabric_api=0.115.3+1.21.1 ``` ```properties deps.yarn_mappings=1.21.4+build.8 deps.fabric_api=0.119.2+1.21.4 ``` -------------------------------- ### Apply String Swaps in Java Source: https://stonecutter.kikugie.dev/wiki/config/params Demonstrates how to use the '$' syntax in Java code to apply predefined string swaps based on version or other conditions. ```java public static void example1() { //$ my_swap method1(); } public static void example2() { //$ my_swap method1(); } ``` ```java public static void example1() { //$ my_swap method2(); } public static void example2() { //$ my_swap method2(); } ``` -------------------------------- ### Adjust Java Compatibility Based on Minecraft Version (Kotlin and Groovy) Source: https://stonecutter.kikugie.dev/wiki/start/builds Dynamically sets the target and source compatibility for the Java compiler based on the Minecraft version being processed. This ensures compatibility with different Java versions required by newer Minecraft releases. ```kotlin java { withSourcesJar() val java = if (stonecutter.eval(stonecutter.current.version, ">=1.20.5")) JavaVersion.VERSION_21 else JavaVersion.VERSION_17 targetCompatibility = java sourceCompatibility = java } ``` ```groovy java { withSourcesJar() def java = stonecutter.eval(stonecutter.current.version, ">=1.20.5") ? JavaVersion.VERSION_21 : JavaVersion.VERSION_17 targetCompatibility = java sourceCompatibility = java } ``` -------------------------------- ### Apply Stonecutter Settings with Gradle Source: https://stonecutter.kikugie.dev/wiki/config/projects Shows how to apply Stonecutter project settings from a JSON file within a Gradle build script. It demonstrates the `create` function for both Kotlin DSL (.kts) and Groovy DSL (.gradle) files. ```kotlin stonecutter { create(rootProject, file("versions.json")) } ``` ```groovy stonecutter { create(getRootProject(), file("versions.json")) } ``` -------------------------------- ### Java: Explicit Version Predicate Dependency Source: https://stonecutter.kikugie.dev/wiki/config/params Demonstrates how to explicitly specify a version predicate target and version for a condition in Java comments. ```java //? if minecraft: >=1.20 ``` -------------------------------- ### Define Swaps with Parameters in Gradle (Kotlin/Groovy) Source: https://stonecutter.kikugie.dev/wiki/config/params Shows how to define Stonecutter swaps in Gradle that accept parameters, allowing for more dynamic code generation. ```kotlin stonecutter { swaps["my_swap"] = when { current.parsed >= "1.21" -> "method1($1, $2);" else -> "method2($1, $2);" } } ``` ```groovy stonecutter { swaps["my_swap"] = current.parsed.matches(">=1.21") ? "method1(\$1, \$2);" : "method2(\$1, \$2);" } ``` -------------------------------- ### Add KSP Plugin for Entrypoint Registration (Gradle) Source: https://stonecutter.kikugie.dev/wiki/fletching-table/entrypoints Integrates the Kotlin JVM and KSP plugins into your project's build script. These are required for entrypoint registration using the Fletching Table annotation processor. ```kotlin plugins { kotlin("jvm") version "2.2.10" id("com.google.devtools.ksp") version "2.2.10-2.0.2" } ``` -------------------------------- ### Handle Replacement Ordering in Gradle (Kotlin) Source: https://stonecutter.kikugie.dev/wiki/config/params Illustrates how to manage replacement ordering in Gradle using Kotlin DSL to avoid issues when switching between versions. It defines replacements that are conditional on the parsed version. ```kotlin stonecutter { replacements.string(current.parsed < "1.21") { replace("A", "B") } replacements.string(current.parsed < "1.20") { replace("B", "C") } } ``` -------------------------------- ### Kotlin Gradle: Defining Snapshot Constant Source: https://stonecutter.kikugie.dev/wiki/config/params Shows how to define a boolean constant 'snapshot' in a Kotlin Gradle build script based on a project property. ```kotlin stonecutter { val snapshot = findProperty("is_snapshot") == "true" constants["snapshot"] = snapshot } ``` -------------------------------- ### Link Stonecutter Lifecycle Tasks Source: https://stonecutter.kikugie.dev/wiki/config/settings Stonecutter lifecycle tasks are registered in the `stonecutter-impl` group and are not meant for direct CLI invocation. This example shows how to link the `createMinecraftArtifacts` task to Stonecutter sources when using Neoforge. ```kotlin tasks.named("createMinecraftArtifacts") { dependsOn("stonecutterGenerate") } ``` -------------------------------- ### Define String Swaps in Gradle (Kotlin/Groovy) Source: https://stonecutter.kikugie.dev/wiki/config/params Explains how to define string swaps in Gradle build scripts using Stonecutter's DSL for conditional code insertion. ```kotlin stonecutter { swaps["my_swap"] = when { eval(current.version, "<1.21") -> "method1();" else -> "method2();" } // Swaps have the same kinds of assignment functions as constants } ``` ```groovy stonecutter { swaps["my_swap"] = eval(current.version, "<1.21") ? "method1();" : "method2();" // Swaps have the same kinds of assignment functions as constants } ``` -------------------------------- ### Groovy Gradle: Using Choice Selector for Mod Loader Source: https://stonecutter.kikugie.dev/wiki/config/params Shows how to use `constants.match` in Groovy Gradle to define constants based on a 'mod_loader' property. ```groovy stonecutter { def loader = property("mod_loader") // neoforge constants.match( loader, "fabric", // != "loader" -> false "neoforge", // == "loader" -> true "forge", // != "loader" -> false ) } ``` -------------------------------- ### Kotlin Gradle: Using Choice Selector for Mod Loader Source: https://stonecutter.kikugie.dev/wiki/config/params Demonstrates using the `constants.match` function in Kotlin Gradle to select a constant based on a 'mod_loader' property. ```kotlin stonecutter { val loader = property("mod_loader") // neoforge constants.match( loader, "fabric", // != "loader" -> false "neoforge", // == "loader" -> true "forge", // != "loader" -> false ) } ``` -------------------------------- ### Configuring Language File Output Style (Kotlin) Source: https://stonecutter.kikugie.dev/wiki/fletching-table/languages Demonstrates how to configure cosmetic options for language file conversion in Gradle. These options, like key sorting and pretty printing, can affect build time and file size and are disabled by default. ```kotlin fletchingTable { lang.all { // Enables key sorting by their dot-separated segments sortKeys = true // Places converted language entries on separate lines prettyPrint = true } } ``` -------------------------------- ### Java: Line Scope with Empty Line Skipping Source: https://stonecutter.kikugie.dev/wiki/config/params Shows how line scopes in Java handle empty lines, ensuring subsequent code is still affected as expected. ```java void example() { //? condition action1(); // This is commented anyway action2(); } ``` -------------------------------- ### Specify Dependencies in Gradle (Kotlin/Groovy) Source: https://stonecutter.kikugie.dev/wiki/config/params Demonstrates how to declare project dependencies using the Stonecutter DSL in both Kotlin and Groovy scripts for Gradle. ```kotlin stonecutter { dependencies["mod_menu"] = property("mod_menu_version") as String // Dependencies have the same kinds of assignment functions as constants } ``` ```groovy stonecutter { dependencies["mod_menu"] = project.mod_menu_version.toString() // Dependencies have the same kinds of assignment functions as constants } ``` -------------------------------- ### Migrate Allowed Extensions Configuration Source: https://stonecutter.kikugie.dev/wiki/config/settings This snippet shows how to migrate from older versions of Stonecutter by replacing the 'allowExtensions' function with the 'filters.include' property. It demonstrates how to include files with a specific extension. ```kotlin stonecutter { allowExtensions("$value") filters.include("**/*.$value") } ``` -------------------------------- ### Enabling Replacements with Header Comments (Java) Source: https://stonecutter.kikugie.dev/wiki/config/params Demonstrates how to enable a named replacement (e.g., 'me_imports') in a Java file by adding a specific header comment '//~ me_imports' at the top. The replacement is only activated if the comment is encountered before any non-empty or non-comment line. ```java //~ me_imports import io.github.me.*; ``` ```java import io.github.me.*; // Won't be detected! //~ me_imports ``` -------------------------------- ### Java: Capturing Word Scope Lookup Source: https://stonecutter.kikugie.dev/wiki/config/params Demonstrates a capturing word scope lookup in Java, where the specified string delimiter is included in the commented portion. ```java void example() { //? if condition >>+ '.' Clazz.Extracted.method(); // ^ commented up to and including the dot } ``` -------------------------------- ### Configure Custom Entrypoint Mappings (Gradle) Source: https://stonecutter.kikugie.dev/wiki/fletching-table/entrypoints Configures custom entrypoint mappings for Fabric within the Fletching Table extension in your Gradle build script. This allows you to specify additional entrypoint interfaces, such as for the Mod Menu API. ```kotlin fletchingTable { fabric { entrypointMappings.put("modmenu", "com.terraformersmc.modmenu.api.ModMenuApi") } } ``` -------------------------------- ### Groovy Gradle: Defining Snapshot Constant Source: https://stonecutter.kikugie.dev/wiki/config/params Illustrates defining a boolean constant 'snapshot' in a Groovy Gradle build script using a project property. ```groovy stonecutter { def snapshot = findProperty("is_snapshot") == "true" constants["snapshot"] = snapshot } ``` -------------------------------- ### Conditional Code Blocks with Java Source: https://stonecutter.kikugie.dev/wiki/config/params Illustrates using Stonecutter's conditional logic to include different Java code snippets based on version comparisons. ```java public static void example1() { //? if <1.21 { method1(); //?} else /*method2();*/ } public static void example2() { //? if <1.21 { method1(); //?} else /*method2();*/ } ``` ```java public static void example1() { //? if <1.21 { /*method1(); *///?} else method2(); } public static void example2() { //? if <1.21 { /*method1(); *///?} else method2(); } ``` -------------------------------- ### Configure Mixins in build.gradle.kts Source: https://stonecutter.kikugie.dev/wiki/fletching-table/mixins This snippet demonstrates how to configure mixin registration within the `fletchingTable` extension in a build.gradle.kts file. It shows how to create a mixin configuration named 'main' and register specific mixin files. ```kotlin fletchingTable { mixins.create("main") { // Name should match an existing source set // Default matches the default value in the annotation mixin("default", "example.mixins.json") // Optionally add other mixin configs mixin("compat", "compat.mixins.json") } } ``` -------------------------------- ### Define Root Project and Versions in Gradle (Kotlin) Source: https://stonecutter.kikugie.dev/wiki/config/branches This snippet demonstrates how to define the root project and its versions using Stonecutter in a `settings.gradle.kts` file. It specifies the project and a list of versions associated with it. ```kotlin stonecutter { create(rootProject) { // <- tree is rootProject versions("1.20.1", "1.21.1") // <- nodes are /versions/1.20.1 and /versions/1.21.1 } } ``` -------------------------------- ### NeoForge Access Transformers: Select Versioned File in build.gradle.kts Source: https://stonecutter.kikugie.dev/wiki/tips/resource-processing Dynamically selects the correct access transformer configuration file based on the Minecraft version and applies it using the NeoForge Minecraft plugin. This snippet is for Kotlin build scripts. ```kotlin val minecraft = stonecutter.current.version val accesstransformer = when { stonecutter.eval(minecraft, ">=1.21") -> "1.21.cfg" stonecutter.eval(minecraft, ">=1.20") -> "1.20.cfg" else -> "1.19.cfg" } minecraft { accessTransformers { file("../../src/main/resources/accesstransformers/$accesstransformer") } } tasks.processResources { filesMatching("META-INF/neoforge.mods.toml") { expand(mapOf( // other properties "at_file" to accesstransformer, )) } } ``` -------------------------------- ### Defining Gradle Properties Source: https://stonecutter.kikugie.dev/wiki/tips/properties Properties are defined with a key and value. They can be set in command line arguments, `versions/*/gradle.properties`, `gradle.properties`, or `~/.gradle/gradle.properties`. Higher priority locations override lower ones. ```gradle deps.fabric_loader=0.17.3 ``` ```gradle deps.fabric_api=0.92.2+1.20.1 ``` ```gradle deps.fabric_api=0.110.0+1.21.1 ``` -------------------------------- ### Organizing Stonecutter Parameters with `stonecutter.parameters` (Kotlin) Source: https://stonecutter.kikugie.dev/wiki/tips/properties Demonstrates the use of `stonecutter.parameters { }` to centralize Stonecutter configuration. It shows how to access properties from corresponding `versions/*/gradle.properties` within this block. ```kotlin stonecutter parameters { // Gets the `deps.mod_menu` from the corresponding `versions/*/gradle.properties` dependencies["mod_menu"] = node.project.property("deps.mod_menu") as String } ``` -------------------------------- ### Configure Custom File Handler with Scanner in Gradle Source: https://stonecutter.kikugie.dev/wiki/config/handlers This code illustrates how to configure a custom file handler in Stonecutter using a Gradle build script. It includes setting up the scanner component with a custom lexer and defining comment openers and closers. ```kotlin stonecutter handlers { configure("ext", "ext2") { scanner { lexer = ::MyLexer openers(MyLexer.COMMENT_OPEN) closers(MyLexer.COMMENT_CLOSE) } commenter = { } // Optional uncommenter = { } swapper = { } } } ``` -------------------------------- ### Configure Regex Replacements in Gradle (Kotlin) Source: https://stonecutter.kikugie.dev/wiki/config/params Configures regex replacements for a specific version range using Kotlin DSL in Gradle. It supports capturing groups and defining reverse operations. ```kotlin stonecutter { replacements.regex(current.parsed >= "1.21") { replace("old(\\w+)Context" to "new$1Context", "new(\\w+)Context" to "old$1Context") // ...additional replacements } } ``` -------------------------------- ### Migrate Overridden Extensions Configuration Source: https://stonecutter.kikugie.dev/wiki/config/settings This snippet demonstrates migrating from the 'overrideExtensions' function to the 'filters.setIncludes' property in Stonecutter. It shows how to set a specific list of file extensions to be included. ```kotlin stonecutter { overrideExtensions("$value") filters.setIncludes("**/*.$value") } ``` -------------------------------- ### Conditional Comments in Java Source: https://stonecutter.kikugie.dev/wiki/config/params Shows how to use conditional comments with Stonecutter for including or excluding code blocks based on version requirements. ```java //? if mod_menu: >=1.0 { public class ModMenuIntegration { // ... } //?} ``` -------------------------------- ### Java: Word Scope with String Lookup Source: https://stonecutter.kikugie.dev/wiki/config/params Illustrates word scope with string lookup in Java, defining a specific character sequence to mark the end of the scope. ```java void example() { Clazz.method(/*? condition >> ');'*/param); // commented up to the specified string ^ } ``` -------------------------------- ### Configure KSP Plugin in build.gradle.kts Source: https://stonecutter.kikugie.dev/wiki/fletching-table/mixins This snippet shows how to add the KSP plugin and configure the Kotlin JVM version in the build.gradle.kts file. This is a prerequisite for using the mixin registration features. ```kotlin kotlin("jvm") version "2.2.10" id("com.google.devtools.ksp") version "2.2.10-2.0.2" ``` -------------------------------- ### Configure Mixin Environments with Packages Source: https://stonecutter.kikugie.dev/wiki/fletching-table/mixins This snippet illustrates how to expand mixin configurations with default environments and specify package names for environment overrides in build.gradle.kts. It demonstrates setting default environments and applying them to specific packages. ```kotlin fletchingTable { mixins.create("main") { mixin("default", "example.mixins.json") { // Makes all mixins be registered in the "client" block by default. env("CLIENT") // Makes mixins in the provided packages be registered in the "server" block. env("SERVER", "com.example.mixin.server") } } } ``` -------------------------------- ### Migrate Excluded Files Configuration Source: https://stonecutter.kikugie.dev/wiki/config/settings This snippet illustrates how to migrate from the 'excludeFiles' function to using the 'filters.exclude' property in Stonecutter. It shows how to exclude files based on a path pattern. ```kotlin stonecutter { excludeFiles("src/main/$value") filters.exclude("$value") } ``` -------------------------------- ### Configure String Replacements in Gradle (Kotlin) Source: https://stonecutter.kikugie.dev/wiki/config/params Configures string replacements for a specific version range using Kotlin DSL in Gradle. It defines a condition for when the replacements should be applied. ```kotlin stonecutter { replacements.string(current.parsed >= "1.21") { replace("io.github.me", "dev.me") // ...additional replacements } } ``` -------------------------------- ### Java: Incorrect vs. Fixed Chaining of Conditions Source: https://stonecutter.kikugie.dev/wiki/config/params Highlights the correct and incorrect ways to chain conditions using closed scopes in Java, emphasizing the need for closing scopes before the last one. ```java void example() { //? condition action1(); //? else // ^ SYNTAX ERROR - expecting } action2(); } ``` ```java void example() { //? condition { action1(); //?} else action2(); } ``` -------------------------------- ### neoforge.mods.toml String Template for Access Transformers Source: https://stonecutter.kikugie.dev/wiki/tips/resource-processing A TOML configuration snippet for neoforge.mods.toml that uses a placeholder for the access transformer file name. This placeholder is intended to be expanded by the build process. ```toml [[accessTransformers]] file="accesstransformers/${at_file}" ``` -------------------------------- ### NeoForge Access Transformers: Select Versioned File in build.gradle Source: https://stonecutter.kikugie.dev/wiki/tips/resource-processing Dynamically selects the correct access transformer configuration file based on the Minecraft version and applies it using the NeoForge Minecraft plugin. This snippet is for Groovy build scripts. ```groovy def minecraft = stonecutter.current.version def accesstransformer = stonecutter.eval(minecraft, ">=1.21") ? "1.21.cfg" : stonecutter.eval(minecraft, ">=1.20") ? "1.20.cfg" : "1.19.cfg" minecraft { accessTransformers { file("../../src/main/resources/accesstransformers/$accesstransformer") } } processResources { filesMatching("META-INF/neoforge.mods.toml") { expand([ // other properties at_file: accesstransformer, ]) } } ``` -------------------------------- ### Inherit File Handler Configurations in Gradle Source: https://stonecutter.kikugie.dev/wiki/config/handlers This snippet demonstrates how to reuse existing file handler configurations in Stonecutter using a Gradle build script. It shows how to inherit the configuration of one file type (e.g., 'java') and apply it to another (e.g., 'hjson'). ```kotlin stonecutter handlers { // Copy the Java configuration to HJson inherit("java", "hjson") } ``` -------------------------------- ### Configure Regex Replacements in Gradle (Groovy) Source: https://stonecutter.kikugie.dev/wiki/config/params Configures regex replacements for a specific version range using Groovy DSL in Gradle. It supports capturing groups and defining reverse operations. ```groovy stonecutter { replacements.regex(current.parsed.matches(">=1.21")) { replace("old(\\w+)Context", "new$1Context", "new(\\w+)Context", "old$1Context") // ...additional replacements } } ``` -------------------------------- ### Entrypoint Annotation Definition (Kotlin) Source: https://stonecutter.kikugie.dev/wiki/fletching-table/entrypoints Defines the `@Entrypoint` annotation used for marking classes, methods, and fields as entrypoints. This annotation is retained at the source level and can target classes, functions, or fields. ```kotlin @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.FIELD) @Retention(AnnotationRetention.SOURCE) annotation class Entrypoint(vararg val value: String = []) ``` -------------------------------- ### Registering Language File Patterns in Gradle (Kotlin) Source: https://stonecutter.kikugie.dev/wiki/fletching-table/languages Shows how to configure the Stonecutter fletchingTable extension in a build.gradle.kts file to process language files. It specifies a pattern for files to be processed and renamed to .json. ```kotlin fletchingTable { lang.create("main") { // Each file in this directory will be processed and renamed to {filename}.json patterns.add("assets/modid/lang/**") } } ``` -------------------------------- ### Switch Active Project Version (Groovy) Source: https://stonecutter.kikugie.dev/wiki/start/controller Demonstrates how to set the active project version in Stonecutter using Groovy DSL. This is crucial for aligning development with a specific Minecraft version. ```groovy plugins { id "dev.kikugie.stonecutter" } stonecutter.active "1.21.4" ```