Skip to content
This repository was archived by the owner on Jul 18, 2023. It is now read-only.

Commit

Permalink
chore: update test mod, don't run client mixins on the server
Browse files Browse the repository at this point in the history
use gametest framework
  • Loading branch information
marcus8448 committed Sep 6, 2021
1 parent 63eb74b commit 98b753f
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 414 deletions.
84 changes: 41 additions & 43 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,50 @@ plugins {
}

val mc = "1.17.1"
val yarn = "29"
val yarn = "52"
val loader = "0.11.6"
val fabric = "0.37.1+1.17"
val lba = "0.9.0"
val fabric = "0.40.0+1.17"
val lba = "0.9.1-pre.1"

group = "dev.galacticraft"
version ="0.4.0-prealpha.18+$mc"
version ="0.4.0-prealpha.19+$mc"

base.archivesName.set("GalacticraftAPI")

val testmodSourceSet = sourceSets.create("testmod") {
java {
targetCompatibility = JavaVersion.VERSION_16
sourceCompatibility = JavaVersion.VERSION_16

withSourcesJar()
withJavadocJar()
}

val gametestSourceSet = sourceSets.create("gametest") {
compileClasspath += sourceSets.main.get().compileClasspath
runtimeClasspath += sourceSets.main.get().runtimeClasspath
java.srcDir("src/testmod/java")
resources.srcDir("src/testmod/resources")
java.srcDir("src/gametest/java")
resources.srcDir("src/gametest/resources")
}

loom {
accessWidenerPath.set(project.file("src/main/resources/galacticraft-api.accesswidener"))
mixin {
add(sourceSets.getByName("testmod"), "gc-testmod.refmap.json")
add(sourceSets.getByName("main"), "galacticraft-api.refmap.json")
add(sourceSets.main.get(), "galacticraft-api.refmap.json")
}

runs {
register("TestModClient") {
client()
source(testmodSourceSet)
vmArgs("-ea")
property("fabric.log.level", "debug")
name("TestMod Client")
}
register("TestModServer") {
register("gametest") {
server()
source(testmodSourceSet)
vmArgs("-ea",)
name("Game Test")
source(gametestSourceSet)
property("fabric.log.level", "debug")
name("TestMod Server")
vmArg("-Dfabric-api.gametest=true")
vmArg("-ea")
}
}
}

val testmodCompile by configurations.creating { extendsFrom(configurations.runtimeOnly.get()) }
val gametestCompile by configurations.creating { extendsFrom(configurations.runtimeOnly.get()) }

repositories {
maven("https://alexiil.uk/maven/") {
Expand All @@ -69,6 +70,7 @@ dependencies {
listOf(
"fabric-api-base",
"fabric-command-api-v1",
"fabric-gametest-api-v1",
"fabric-lifecycle-events-v1",
"fabric-networking-api-v1",
"fabric-registry-sync-v0",
Expand All @@ -82,35 +84,25 @@ dependencies {
modImplementation("alexiil.mc.lib:libblockattributes-items:$lba")
modRuntime("net.fabricmc.fabric-api:fabric-api:$fabric")

testmodCompile(sourceSets.main.get().output)
gametestCompile(sourceSets.main.get().output)
}

tasks.processResources {
inputs.property("version", project.version)
duplicatesStrategy = DuplicatesStrategy.WARN

from(sourceSets.main.get().resources.srcDirs) {
include("fabric.mod.json")
expand(mutableMapOf("version" to project.version))
filesMatching("fabric.mod.json") {
expand("version" to project.version)
}

from(sourceSets.main.get().resources.srcDirs) {
exclude("fabric.mod.json")
// Minify json resources
// https://stackoverflow.com/questions/41028030/gradle-minimize-json-resources-in-processresources#41029113
doLast {
fileTree(mapOf("dir" to outputs.files.asPath, "includes" to listOf("**/*.json", "**/*.mcmeta"))).forEach {
file: File -> file.writeText(groovy.json.JsonOutput.toJson(groovy.json.JsonSlurper().parse(file)))
}
}
}

tasks.getByName<ProcessResources>("processTestmodResources") {
duplicatesStrategy = DuplicatesStrategy.WARN
}

java {
withSourcesJar()
withJavadocJar()

targetCompatibility = JavaVersion.VERSION_16
sourceCompatibility = JavaVersion.VERSION_16
}

tasks.withType<JavaCompile> {
dependsOn(tasks.checkLicenses)
options.encoding = "UTF-8"
Expand All @@ -135,14 +127,14 @@ tasks.remapSourcesJar.configure {
tasks.jar {
from("LICENSE")
manifest {
attributes(mapOf(
attributes(
"Implementation-Title" to "GalacticraftAPI",
"Implementation-Version" to "${project.version}",
"Implementation-Vendor" to "Team Galacticraft",
"Implementation-Timestamp" to DateTimeFormatter.ISO_DATE_TIME,
"Maven-Artifact" to "${project.group}:GalacticraftAPI:${project.version}",
"ModSide" to "BOTH"
))
)
}
}

Expand Down Expand Up @@ -179,4 +171,10 @@ license {
set("year", Year.now().value)
set("company", "Team Galacticraft")
}
}
}

tasks.named<ProcessResources>("processGametestResources") {
duplicatesStrategy = DuplicatesStrategy.WARN
}

tasks.getByName("gametestClasses").dependsOn("classes")
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@
* SOFTWARE.
*/

package dev.galacticraft.api.testmod;
package dev.galacticraft.api.gametest;

import net.fabricmc.api.ModInitializer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import net.fabricmc.fabric.api.gametest.v1.FabricGameTest;
import net.minecraft.test.GameTest;
import net.minecraft.test.TestContext;

public class GCApiTestMod implements ModInitializer {
public static final Logger LOGGER = LogManager.getLogger();
@Override
public void onInitialize() {
LOGGER.info("Loaded test mod!");
public class GalacticraftApiTestSuite implements FabricGameTest {
@GameTest(structureName = EMPTY_STRUCTURE)
public void emptyTest(TestContext context) {
context.addInstantFinalTask(() -> {});
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"parent": "gc-testmod:custom/root",
"parent": "gc-api-test:custom/root",
"display": {
"icon": {
"item": "minecraft:diamond_block"
},
"title": {
"translate": "gc-testmod.advancements.custom.diamond_block.title"
"translate": "gc-api-test.advancements.custom.diamond_block.title"
},
"description": {
"translate": "gc-testmod.advancements.custom.diamond_block.description"
"translate": "gc-api-test.advancements.custom.diamond_block.description"
},
"frame": "challenge",
"show_toast": true,
Expand All @@ -17,7 +17,7 @@
},
"rewards": {
"rocket_parts": [
"gc-testmod:test"
"gc-api-test:test"
]
},
"criteria": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"item": "minecraft:gold_block"
},
"title": {
"translate": "gc-testmod.advancements.custom.root.title"
"translate": "gc-api-test.advancements.custom.root.title"
},
"description": {
"translate": "gc-testmod.advancements.custom.root.description"
"translate": "gc-api-test.advancements.custom.root.description"
},
"frame": "task",
"show_toast": false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,32 @@
{
"schemaVersion": 1,
"id": "gc-testmod",
"id": "gc-api-test",
"version": "$version",

"name": "Galacticraft API Test Mod",
"description": "Test mod for the Addon API for the FabricMC port of Galacticraft.",
"license": "MIT",
"contact": {
"homepage": "https://galacticraft.team",
"sources": "https://github.com/TeamGalacticraft/Addon-API",
"issues": "https://github.com/TeamGalacticraft/Addon-API/issues"
"homepage": "https://galacticraft.team/",
"sources": "https://github.com/TeamGalacticraft/Addon-API/",
"issues": "https://github.com/TeamGalacticraft/Addon-API/issues/"
},
"authors": [
{
"name": "Team Galacticraft",
"contact": {
"homepage": "https://github.com/TeamGalacticraft",
"homepage": "https://github.com/TeamGalacticraft/",
"discord": "https://discord.gg/n3QqhMYyFK"
}
}
],
"environment": "*",
"entrypoints": {
"main": [
"dev.galacticraft.api.testmod.GCApiTestMod"
]
"fabric-gametest": [ "dev.galacticraft.api.gametest.GalacticraftApiTestSuite" ]
},
"depends": {
"fabricloader": ">=0.10.0",
"minecraft": ">=1.16.2",
"galacticraft-api": ">=0.3"
},
"suggests": {
"modmenu": "*",
"galacticraft": "*"
"fabricloader": ">=0.11.6",
"minecraft": ">=1.17.1",
"galacticraft-api": ">=0.4.0-prealpha.19+1.17.1"
}
}
84 changes: 0 additions & 84 deletions src/main/java/dev/galacticraft/api/team/Role.java

This file was deleted.

Loading

0 comments on commit 98b753f

Please sign in to comment.