diff --git a/README.md b/README.md index 08db1bb..e0f66cd 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ My personalized Quilt template Mod. You can use it as a template for your own mo ## Differences from the Official Mod - Added a build github action - +- Added gametest support (See ##Usage###Gametest Support) ## Usage In order to use this mod as a template: @@ -14,7 +14,7 @@ In order to use this mod as a template: 3. Make the necessary changes in order to make it yours: - Update `gradle.properties` in order to use your Maven group and mod ID - If you don't know which Maven group to use, and you are planning to host the mod's source code on GitHub, use `io.github.` - - Update `quilt.mod.json` in order to reflect your mod's metadata + - Update `quilt.mod.json` in `src/main/resources` in order to reflect your mod's metadata - If you are planning to include (jar-in-jar) a mod, don't forget to declare its dependency on it! - The icon provided here is a placeholder one. If you aren't able to replace it yet, you can delete it and remove the "icon" property - Create a LICENSE file for this mod! If you don't know which license to use, check out [here](https://choosealicense.com/). @@ -24,6 +24,16 @@ In order to use this mod as a template: - If the dependencies on `gradle/libs.versions.toml` isn't up-to-date, feel free to update them! The [linked utility](https://lambdaurora.dev/tools/import_quilt.html) should help you in this easy and quick process. 4. The mod is now ready to be worked on! +### Gametest Support +1. Update `quilt.mod.json` in `src/gametest/resources` and the rest of the naming in order to reflect your testmod's metadata + +> [WARNING] +> +> make sure to change the dependency on `example_mod` to your modid and to not reuse the modid of your main project, e.g. suffix your project's modid with `_test` +> + +2. Now testing should be available using the test gradle task + ## License This template on the QuiltMC GitHub is licensed under the [Creative Common Zero v1.0 license](./LICENSE-TEMPLATE.md). diff --git a/build.gradle b/build.gradle index 6d2c0d6..c6aeee3 100644 --- a/build.gradle +++ b/build.gradle @@ -69,6 +69,36 @@ jar { } } +// Gametest stuff +sourceSets { + gametest { + compileClasspath += sourceSets.main.compileClasspath + runtimeClasspath += sourceSets.main.runtimeClasspath + compileClasspath += sourceSets.main.output + runtimeClasspath += sourceSets.main.output + } +} + +loom { + runs { + gametest { + server() + name = "Headless Game Test Server" + vmArg "-Dfabric-api.gametest" + runDir "build/gametest" + source = project.sourceSets.gametest + } + + gametestClient { + client() + name = "Game Test Client" + source = project.sourceSets.gametest + } + } +} + +test.dependsOn runGametest + // Configure the maven publication publishing { publications { diff --git a/src/gametest/java/com/example/example_mod/test/ExampleModTests.java b/src/gametest/java/com/example/example_mod/test/ExampleModTests.java new file mode 100644 index 0000000..80caff9 --- /dev/null +++ b/src/gametest/java/com/example/example_mod/test/ExampleModTests.java @@ -0,0 +1,14 @@ +package com.example.example_mod.test; + +import net.minecraft.block.Blocks; +import net.minecraft.test.GameTest; +import net.minecraft.test.TestContext; +import net.minecraft.util.math.BlockPos; + +public class ExampleModTests { + @GameTest() + public void exampleStructureTest (TestContext context) { + context.setBlockState(new BlockPos(0, 2, 0), Blocks.DIAMOND_BLOCK.getDefaultState()); + context.addInstantFinalTask(() -> context.checkBlock(new BlockPos(0,2,0), block -> block == Blocks.DIAMOND_BLOCK, "Expect block to be a Diamond Block")); + } +} diff --git a/src/gametest/resources/assets/example_mod_test/icon.png b/src/gametest/resources/assets/example_mod_test/icon.png new file mode 100644 index 0000000..d42fc1e Binary files /dev/null and b/src/gametest/resources/assets/example_mod_test/icon.png differ diff --git a/src/gametest/resources/data/example_mod_test/gametest/structures/examplemodtests.examplestructuretest.snbt b/src/gametest/resources/data/example_mod_test/gametest/structures/examplemodtests.examplestructuretest.snbt new file mode 100644 index 0000000..9ace075 --- /dev/null +++ b/src/gametest/resources/data/example_mod_test/gametest/structures/examplemodtests.examplestructuretest.snbt @@ -0,0 +1,138 @@ +{ + DataVersion: 3120, + size: [5, 5, 5], + data: [ + {pos: [0, 0, 0], state: "minecraft:polished_andesite"}, + {pos: [0, 0, 1], state: "minecraft:polished_andesite"}, + {pos: [0, 0, 2], state: "minecraft:polished_andesite"}, + {pos: [0, 0, 3], state: "minecraft:polished_andesite"}, + {pos: [0, 0, 4], state: "minecraft:polished_andesite"}, + {pos: [1, 0, 0], state: "minecraft:polished_andesite"}, + {pos: [1, 0, 1], state: "minecraft:polished_andesite"}, + {pos: [1, 0, 2], state: "minecraft:polished_andesite"}, + {pos: [1, 0, 3], state: "minecraft:polished_andesite"}, + {pos: [1, 0, 4], state: "minecraft:polished_andesite"}, + {pos: [2, 0, 0], state: "minecraft:polished_andesite"}, + {pos: [2, 0, 1], state: "minecraft:polished_andesite"}, + {pos: [2, 0, 2], state: "minecraft:polished_andesite"}, + {pos: [2, 0, 3], state: "minecraft:polished_andesite"}, + {pos: [2, 0, 4], state: "minecraft:polished_andesite"}, + {pos: [3, 0, 0], state: "minecraft:polished_andesite"}, + {pos: [3, 0, 1], state: "minecraft:polished_andesite"}, + {pos: [3, 0, 2], state: "minecraft:polished_andesite"}, + {pos: [3, 0, 3], state: "minecraft:polished_andesite"}, + {pos: [3, 0, 4], state: "minecraft:polished_andesite"}, + {pos: [4, 0, 0], state: "minecraft:polished_andesite"}, + {pos: [4, 0, 1], state: "minecraft:polished_andesite"}, + {pos: [4, 0, 2], state: "minecraft:polished_andesite"}, + {pos: [4, 0, 3], state: "minecraft:polished_andesite"}, + {pos: [4, 0, 4], state: "minecraft:polished_andesite"}, + {pos: [0, 1, 0], state: "minecraft:air"}, + {pos: [0, 1, 1], state: "minecraft:air"}, + {pos: [0, 1, 2], state: "minecraft:air"}, + {pos: [0, 1, 3], state: "minecraft:air"}, + {pos: [0, 1, 4], state: "minecraft:air"}, + {pos: [1, 1, 0], state: "minecraft:air"}, + {pos: [1, 1, 1], state: "minecraft:air"}, + {pos: [1, 1, 2], state: "minecraft:air"}, + {pos: [1, 1, 3], state: "minecraft:air"}, + {pos: [1, 1, 4], state: "minecraft:air"}, + {pos: [2, 1, 0], state: "minecraft:air"}, + {pos: [2, 1, 1], state: "minecraft:air"}, + {pos: [2, 1, 2], state: "minecraft:air"}, + {pos: [2, 1, 3], state: "minecraft:air"}, + {pos: [2, 1, 4], state: "minecraft:air"}, + {pos: [3, 1, 0], state: "minecraft:air"}, + {pos: [3, 1, 1], state: "minecraft:air"}, + {pos: [3, 1, 2], state: "minecraft:air"}, + {pos: [3, 1, 3], state: "minecraft:air"}, + {pos: [3, 1, 4], state: "minecraft:air"}, + {pos: [4, 1, 0], state: "minecraft:air"}, + {pos: [4, 1, 1], state: "minecraft:air"}, + {pos: [4, 1, 2], state: "minecraft:air"}, + {pos: [4, 1, 3], state: "minecraft:air"}, + {pos: [4, 1, 4], state: "minecraft:air"}, + {pos: [0, 2, 0], state: "minecraft:air"}, + {pos: [0, 2, 1], state: "minecraft:air"}, + {pos: [0, 2, 2], state: "minecraft:air"}, + {pos: [0, 2, 3], state: "minecraft:air"}, + {pos: [0, 2, 4], state: "minecraft:air"}, + {pos: [1, 2, 0], state: "minecraft:air"}, + {pos: [1, 2, 1], state: "minecraft:air"}, + {pos: [1, 2, 2], state: "minecraft:air"}, + {pos: [1, 2, 3], state: "minecraft:air"}, + {pos: [1, 2, 4], state: "minecraft:air"}, + {pos: [2, 2, 0], state: "minecraft:air"}, + {pos: [2, 2, 1], state: "minecraft:air"}, + {pos: [2, 2, 2], state: "minecraft:air"}, + {pos: [2, 2, 3], state: "minecraft:air"}, + {pos: [2, 2, 4], state: "minecraft:air"}, + {pos: [3, 2, 0], state: "minecraft:air"}, + {pos: [3, 2, 1], state: "minecraft:air"}, + {pos: [3, 2, 2], state: "minecraft:air"}, + {pos: [3, 2, 3], state: "minecraft:air"}, + {pos: [3, 2, 4], state: "minecraft:air"}, + {pos: [4, 2, 0], state: "minecraft:air"}, + {pos: [4, 2, 1], state: "minecraft:air"}, + {pos: [4, 2, 2], state: "minecraft:air"}, + {pos: [4, 2, 3], state: "minecraft:air"}, + {pos: [4, 2, 4], state: "minecraft:air"}, + {pos: [0, 3, 0], state: "minecraft:air"}, + {pos: [0, 3, 1], state: "minecraft:air"}, + {pos: [0, 3, 2], state: "minecraft:air"}, + {pos: [0, 3, 3], state: "minecraft:air"}, + {pos: [0, 3, 4], state: "minecraft:air"}, + {pos: [1, 3, 0], state: "minecraft:air"}, + {pos: [1, 3, 1], state: "minecraft:air"}, + {pos: [1, 3, 2], state: "minecraft:air"}, + {pos: [1, 3, 3], state: "minecraft:air"}, + {pos: [1, 3, 4], state: "minecraft:air"}, + {pos: [2, 3, 0], state: "minecraft:air"}, + {pos: [2, 3, 1], state: "minecraft:air"}, + {pos: [2, 3, 2], state: "minecraft:air"}, + {pos: [2, 3, 3], state: "minecraft:air"}, + {pos: [2, 3, 4], state: "minecraft:air"}, + {pos: [3, 3, 0], state: "minecraft:air"}, + {pos: [3, 3, 1], state: "minecraft:air"}, + {pos: [3, 3, 2], state: "minecraft:air"}, + {pos: [3, 3, 3], state: "minecraft:air"}, + {pos: [3, 3, 4], state: "minecraft:air"}, + {pos: [4, 3, 0], state: "minecraft:air"}, + {pos: [4, 3, 1], state: "minecraft:air"}, + {pos: [4, 3, 2], state: "minecraft:air"}, + {pos: [4, 3, 3], state: "minecraft:air"}, + {pos: [4, 3, 4], state: "minecraft:air"}, + {pos: [0, 4, 0], state: "minecraft:air"}, + {pos: [0, 4, 1], state: "minecraft:air"}, + {pos: [0, 4, 2], state: "minecraft:air"}, + {pos: [0, 4, 3], state: "minecraft:air"}, + {pos: [0, 4, 4], state: "minecraft:air"}, + {pos: [1, 4, 0], state: "minecraft:air"}, + {pos: [1, 4, 1], state: "minecraft:air"}, + {pos: [1, 4, 2], state: "minecraft:air"}, + {pos: [1, 4, 3], state: "minecraft:air"}, + {pos: [1, 4, 4], state: "minecraft:air"}, + {pos: [2, 4, 0], state: "minecraft:air"}, + {pos: [2, 4, 1], state: "minecraft:air"}, + {pos: [2, 4, 2], state: "minecraft:air"}, + {pos: [2, 4, 3], state: "minecraft:air"}, + {pos: [2, 4, 4], state: "minecraft:air"}, + {pos: [3, 4, 0], state: "minecraft:air"}, + {pos: [3, 4, 1], state: "minecraft:air"}, + {pos: [3, 4, 2], state: "minecraft:air"}, + {pos: [3, 4, 3], state: "minecraft:air"}, + {pos: [3, 4, 4], state: "minecraft:air"}, + {pos: [4, 4, 0], state: "minecraft:air"}, + {pos: [4, 4, 1], state: "minecraft:air"}, + {pos: [4, 4, 2], state: "minecraft:air"}, + {pos: [4, 4, 3], state: "minecraft:air"}, + {pos: [4, 4, 4], state: "minecraft:air"} + ], + entities: [], + palette: [ + "minecraft:polished_andesite", + "minecraft:air", + "minecraft:campfire{facing:south,lit:true,signal_fire:false,waterlogged:false}", + "turing_potions:potion_cauldron{level:1}" + ] +} diff --git a/src/gametest/resources/quilt.mod.json b/src/gametest/resources/quilt.mod.json new file mode 100644 index 0000000..be2b9a4 --- /dev/null +++ b/src/gametest/resources/quilt.mod.json @@ -0,0 +1,40 @@ +{ + "schema_version": 1, + "quilt_loader": { + "group": "com.example", + "id": "example_mod_test", + "version": "${version}", + "metadata": { + "name": "Mod Name Testmod", + "description": "The Mod Name Testmod.", + "contributors": { + "Your name here": "Owner" + }, + "icon": "assets/example_mod/icon.png" + }, + "intermediate_mappings": "net.fabricmc:intermediary", + "entrypoints": { + "fabric-gametest": [ + "com.example.example_mod.test.ExampleModTests" + ] + }, + "depends": [ + { + "id": "example_mod", + "versions": "*" + }, + { + "id": "quilt_loader", + "versions": ">=0.17.0-" + }, + { + "id": "quilted_fabric_api", + "versions": ">=4.0.0-" + }, + { + "id": "minecraft", + "versions": ">=1.19.2" + } + ] + } +}