From e37cca4b98f1aa79f602c00956a03eb4f80dc20a Mon Sep 17 00:00:00 2001 From: Pyrofab Date: Tue, 23 Nov 2021 16:48:22 +0100 Subject: [PATCH] Update loom and migrate tests --- build.gradle | 262 +++++++++++------- .../internal/base/ComponentRegistryImpl.java | 4 +- cardinal-components-block/build.gradle | 2 +- cardinal-components-chunk/build.gradle | 2 +- cardinal-components-entity/build.gradle | 4 +- cardinal-components-item/build.gradle | 4 +- cardinal-components-level/build.gradle | 4 +- cardinal-components-scoreboard/build.gradle | 4 +- cardinal-components-world/build.gradle | 2 +- .../cardinal/components/TestComponent.java | 72 ----- .../cca/internal/base/CcaTesting.java | 12 +- .../base/ComponentRegistryImplTest.java | 39 ++- .../base/QualifiedComponentFactoryTest.java | 51 ++-- .../{ => content}/CCATestClient.java | 6 +- .../{ => content}/CardinalComponentsTest.java | 8 +- .../{ => content}/TestComponents.java | 18 +- .../TestStaticComponentInitializer.java | 6 +- .../{ => content}/VitaCommand.java | 4 +- .../{ => content}/VitaCompound.java | 6 +- .../{ => content}/VitalityCondenser.java | 4 +- .../{ => content}/VitalityStickItem.java | 6 +- .../{ => content}/VitalityZombieEntity.java | 4 +- .../componenttest/content}/package-info.java | 2 +- .../{ => content}/vita/AmbientVita.java | 6 +- .../{ => content}/vita/BaseVita.java | 2 +- .../{ => content}/vita/ChunkVita.java | 4 +- .../{ => content}/vita/EntityVita.java | 2 +- .../{ => content}/vita/ItemVita.java | 2 +- .../{ => content}/vita/PlayerVita.java | 6 +- .../{ => content}/vita/SyncedVita.java | 4 +- .../{ => content}/vita/TeamVita.java | 2 +- .../{ => content}/vita/Vita.java | 4 +- .../content/vita}/package-info.java | 2 +- .../componenttest/package-info.java | 29 -- .../componenttest/tests/CardinalGameTest.java | 65 +++++ .../componenttest/tests/CcaTestSuite.java} | 15 +- .../componenttest/vita/package-info.java | 29 -- src/testmod/readme.md | 32 ++- src/testmod/resources/fabric.mod.json | 18 +- 39 files changed, 373 insertions(+), 375 deletions(-) delete mode 100644 src/test/java/nerdhub/cardinal/components/TestComponent.java rename src/{test => testmod}/java/dev/onyxstudios/cca/internal/base/CcaTesting.java (84%) rename src/{test => testmod}/java/dev/onyxstudios/cca/internal/base/ComponentRegistryImplTest.java (66%) rename src/{test => testmod}/java/dev/onyxstudios/cca/internal/base/QualifiedComponentFactoryTest.java (79%) rename src/testmod/java/dev/onyxstudios/componenttest/{ => content}/CCATestClient.java (87%) rename src/testmod/java/dev/onyxstudios/componenttest/{ => content}/CardinalComponentsTest.java (97%) rename src/testmod/java/dev/onyxstudios/componenttest/{ => content}/TestComponents.java (91%) rename src/testmod/java/dev/onyxstudios/componenttest/{ => content}/TestStaticComponentInitializer.java (94%) rename src/testmod/java/dev/onyxstudios/componenttest/{ => content}/VitaCommand.java (97%) rename src/testmod/java/dev/onyxstudios/componenttest/{ => content}/VitaCompound.java (95%) rename src/testmod/java/dev/onyxstudios/componenttest/{ => content}/VitalityCondenser.java (96%) rename src/testmod/java/dev/onyxstudios/componenttest/{ => content}/VitalityStickItem.java (96%) rename src/testmod/java/dev/onyxstudios/componenttest/{ => content}/VitalityZombieEntity.java (94%) rename src/{test/java/nerdhub/cardinal/components => testmod/java/dev/onyxstudios/componenttest/content}/package-info.java (96%) rename src/testmod/java/dev/onyxstudios/componenttest/{ => content}/vita/AmbientVita.java (95%) rename src/testmod/java/dev/onyxstudios/componenttest/{ => content}/vita/BaseVita.java (97%) rename src/testmod/java/dev/onyxstudios/componenttest/{ => content}/vita/ChunkVita.java (93%) rename src/testmod/java/dev/onyxstudios/componenttest/{ => content}/vita/EntityVita.java (97%) rename src/testmod/java/dev/onyxstudios/componenttest/{ => content}/vita/ItemVita.java (96%) rename src/testmod/java/dev/onyxstudios/componenttest/{ => content}/vita/PlayerVita.java (95%) rename src/testmod/java/dev/onyxstudios/componenttest/{ => content}/vita/SyncedVita.java (93%) rename src/testmod/java/dev/onyxstudios/componenttest/{ => content}/vita/TeamVita.java (97%) rename src/testmod/java/dev/onyxstudios/componenttest/{ => content}/vita/Vita.java (93%) rename src/{test/java/dev/onyxstudios/cca/api/v3/util/util/impl => testmod/java/dev/onyxstudios/componenttest/content/vita}/package-info.java (96%) delete mode 100644 src/testmod/java/dev/onyxstudios/componenttest/package-info.java create mode 100644 src/testmod/java/dev/onyxstudios/componenttest/tests/CardinalGameTest.java rename src/{test/java/dev/onyxstudios/cca/internal/base/asm/CcaBootstrapTest.java => testmod/java/dev/onyxstudios/componenttest/tests/CcaTestSuite.java} (76%) delete mode 100644 src/testmod/java/dev/onyxstudios/componenttest/vita/package-info.java diff --git a/build.gradle b/build.gradle index 5a9c9b67..2dbfe1f3 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ import java.time.Year plugins { id "fabric-loom" version "0.10-SNAPSHOT" apply false - id "org.cadixdev.licenser" version "0.6.0" + id "org.cadixdev.licenser" version "0.6.1" id "com.matthewprenger.cursegradle" version "1.4.0" id "com.jfrog.artifactory" version "4.21.0" id 'org.ajoberstar.grgit' version '3.1.1' @@ -35,47 +35,60 @@ allprojects { sourceCompatibility = targetCompatibility = JavaVersion.VERSION_16 version = System.getenv("TRAVIS_TAG") ?: rootProject.mod_version - configurations { - dev - } // import utility functions apply from: rootProject.file("utilities.gradle") - tasks.withType(Javadoc) { - options.addStringOption("Xdoclint:none", "-quiet") - } - - // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task - // if it is present. - task sourcesJar(type: Jar, dependsOn: classes) { - archiveClassifier = "sources" - from sourceSets.main.allSource + tasks.withType(JavaCompile) { + it.options.release = 16 } - task javadocJar(type: Jar, dependsOn: javadoc) { - from javadoc.destinationDir - archiveClassifier = "javadoc" + sourceSets { + testmod { + compileClasspath += main.compileClasspath + runtimeClasspath += main.runtimeClasspath + } } - tasks.build.dependsOn javadocJar - repositories { + loom { + runs { + testmodClient { + client() + ideConfigGenerated project.rootProject == project + name = "Testmod Client" + source sourceSets.testmod + } + testmodServer { + server() + ideConfigGenerated project.rootProject == project + name = "Testmod Server" + source sourceSets.testmod + } + } } dependencies { - minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" - mappings "net.fabricmc:yarn:${rootProject.minecraft_version}+build.${rootProject.yarn_mappings}:v2" - modApi "net.fabricmc:fabric-loader:${rootProject.loader_version}" - modApi fabricApi.module("fabric-api-base", rootProject.fabric_api_version) - modImplementation fabricApi.module("fabric-networking-api-v1", rootProject.fabric_api_version) + minecraft "com.mojang:minecraft:${minecraft_version}" + mappings "net.fabricmc:yarn:${minecraft_version}+build.${yarn_mappings}:v2" + modApi "net.fabricmc:fabric-loader:${loader_version}" + modApi fabricApi.module("fabric-api-base", fabric_api_version) + modImplementation fabricApi.module("fabric-networking-api-v1", fabric_api_version) - testImplementation 'junit:junit:4.13' - testImplementation 'org.mockito:mockito-core:3.+' + testmodImplementation 'junit:junit:4.13' + testmodImplementation 'org.mockito:mockito-core:3.+' compileOnly "com.google.code.findbugs:jsr305:3.0.2" compileOnly "com.demonwav.mcdev:annotations:1.0" compileOnly "org.jetbrains:annotations:19.0.0" } + loom { + shareRemapCaches = true + } + + repositories { + mavenLocal() + } + processResources { inputs.property "version", project.version @@ -84,12 +97,6 @@ allprojects { } } - test { - useJUnit() - - maxHeapSize = '1G' - } - license { header = rootProject.file("code_quality/${project.license_header}_HEADER.txt") include "**/*.java" @@ -107,12 +114,32 @@ allprojects { } } - // ensure that the encoding is set to UTF-8, no matter what the system default is - // this fixes some edge cases with special characters not displaying correctly - // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html - tasks.withType(JavaCompile).configureEach { - it.options.encoding = "UTF-8" - it.options.release = 16 + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task + // if it is present. + task sourcesJar(type: Jar, dependsOn: classes) { + archiveClassifier = "sources" + from sourceSets.main.allSource + } + + task javadocJar(type: Jar, dependsOn: javadoc) { + from javadoc.destinationDir + archiveClassifier = "javadoc" + } + tasks.build.dependsOn javadocJar + + tasks.withType(AbstractArchiveTask) { + preserveFileTimestamps = false + reproducibleFileOrder = true + } + + tasks.withType(GenerateModuleMetadata) { + enabled = false + } + + test { + useJUnit() + + maxHeapSize = '1G' } java { @@ -123,47 +150,101 @@ allprojects { } jar { - archiveClassifier = "dev" from(rootProject.file("LICENSE.md")) { rename { "LICENSE_${project.archivesBaseName.replace('-', '_')}"} } } +} - afterEvaluate { - artifacts { - dev file: file("${project.buildDir}/libs/$archivesBaseName-${version}-dev.jar"), type: "jar", builtBy: jar +javadoc { + options { + source = "16" + encoding = "UTF-8" + charSet = "UTF-8" + memberLevel = JavadocMemberLevel.PACKAGE + links( + "https://guava.dev/releases/21.0/api/docs/", + "https://asm.ow2.io/javadoc/", + "https://docs.oracle.com/javase/8/docs/api/", + "http://jenkins.liteloader.com/job/Mixin/javadoc/", + "https://logging.apache.org/log4j/2.x/log4j-api/apidocs/" + // Need to add minecraft jd publication etc once there is one available + ) + // Disable the crazy super-strict doclint tool in Java 8 + addStringOption("Xdoclint:none", "-quiet") + } + + allprojects.each { + source(it.sourceSets.main.allJava.srcDirs) + } + + classpath = sourceSets.main.compileClasspath + include("**/api/**") + failOnError false +} + +loom { + runs { + gametest { + inherit testmodServer + + name "Game Test" + + // Enable the gametest runner + vmArg "-Dfabric-api.gametest" + vmArg "-Dfabric-api.gametest.report-file=${project.buildDir}/junit.xml" + runDir "build/gametest" + } + autoTestServer { + inherit testmodServer + + name "Auto Test Server" + + vmArg "-Dfabric.autoTest" } } +} +test.dependsOn runGametest - apply from: "https://raw.githubusercontent.com/NerdHubMC/Gradle-Scripts/master/scripts/fabric/publish/nerdhub_maven.gradle" +subprojects { + version = rootProject.version publishing { publications { mavenJava(MavenPublication) { - artifact(remapJar) { - builtBy(remapJar) - } - artifact(sourcesJar) { - builtBy(remapSourcesJar) - } - artifact(javadocJar) + from components.java } } } -} -subprojects { - version = rootProject.version -} + javadoc.enabled = false -sourceSets { - testmod { - compileClasspath += main.compileClasspath - runtimeClasspath += main.runtimeClasspath + afterEvaluate { + // Disable the gen sources task on sub projects + genSourcesWithFernFlower.enabled = false + genSourcesWithCfr.enabled = false + unpickJar.enabled = false + + // Work around a loom bug causing empty jars to be pushed to maven local. + publishMavenJavaPublicationToMavenLocal.dependsOn rootProject.tasks.getByName("remapAllJars") + publishMavenJavaPublicationToMavenLocal.dependsOn rootProject.tasks.getByName("remapAllSources") } - test { - compileClasspath += main.compileClasspath - runtimeClasspath += main.runtimeClasspath +} + +publishing { + publications { + mavenJava(MavenPublication) { + pom.withXml { + def depsNode = asNode().appendNode("dependencies") + subprojects.each { + def depNode = depsNode.appendNode("dependency") + depNode.appendNode("groupId", it.group) + depNode.appendNode("artifactId", it.name) + depNode.appendNode("version", it.version) + depNode.appendNode("scope", "compile") + } + } + } } } @@ -180,34 +261,34 @@ repositories { dependencies { // used by the test mod - modImplementation fabricApi.module("fabric-api-base", rootProject.fabric_api_version) - modImplementation fabricApi.module("fabric-object-builder-api-v1", rootProject.fabric_api_version) - modImplementation fabricApi.module("fabric-renderer-registries-v1", rootProject.fabric_api_version) - modImplementation fabricApi.module("fabric-lifecycle-events-v1", rootProject.fabric_api_version) - modImplementation fabricApi.module("fabric-item-api-v1", rootProject.fabric_api_version) - modImplementation fabricApi.module("fabric-item-groups-v0", rootProject.fabric_api_version) - modImplementation fabricApi.module("fabric-events-interaction-v0", rootProject.fabric_api_version) - modImplementation fabricApi.module("fabric-api-lookup-api-v1", rootProject.fabric_api_version) + modImplementation fabricApi.module("fabric-api-base", fabric_api_version) + modImplementation fabricApi.module("fabric-object-builder-api-v1", fabric_api_version) + modImplementation fabricApi.module("fabric-renderer-registries-v1", fabric_api_version) + modImplementation fabricApi.module("fabric-lifecycle-events-v1", fabric_api_version) + modImplementation fabricApi.module("fabric-item-api-v1", fabric_api_version) + modImplementation fabricApi.module("fabric-item-groups-v0", fabric_api_version) + modImplementation fabricApi.module("fabric-events-interaction-v0", fabric_api_version) + modImplementation fabricApi.module("fabric-api-lookup-api-v1", fabric_api_version) modImplementation fabricApi.module("fabric-command-api-v1", fabric_api_version) - modRuntime fabricApi.module("fabric-networking-v0", rootProject.rootProject.fabric_api_version) - modRuntime fabricApi.module("fabric-resource-loader-v0", rootProject.fabric_api_version) - modRuntime fabricApi.module("fabric-mining-levels-v0", rootProject.fabric_api_version) - modRuntime fabricApi.module("fabric-tag-extensions-v0", rootProject.fabric_api_version) - modRuntime fabricApi.module("fabric-tool-attribute-api-v1", rootProject.fabric_api_version) - modRuntime fabricApi.module("fabric-events-interaction-v0", rootProject.fabric_api_version) - - // Optibad -// modRuntime 'com.github.modmuss50:OptiFabric:1.1.0-beta2' -// modRuntime 'org.zeroturnaround:zt-zip:1.14' // required dep for optibad + modImplementation fabricApi.module("fabric-gametest-api-v1", fabric_api_version) + modRuntimeOnly fabricApi.module("fabric-networking-v0", fabric_api_version) + modRuntimeOnly fabricApi.module("fabric-resource-loader-v0", fabric_api_version) + modRuntimeOnly fabricApi.module("fabric-mining-levels-v0", fabric_api_version) + modRuntimeOnly fabricApi.module("fabric-tag-extensions-v0", fabric_api_version) + modRuntimeOnly fabricApi.module("fabric-tool-attribute-api-v1", fabric_api_version) + modRuntimeOnly fabricApi.module("fabric-events-interaction-v0", fabric_api_version) testCompileOnly "com.google.code.findbugs:jsr305:3.0.2" include fabricApi.module("fabric-api-base", fabric_api_version) include fabricApi.module("fabric-networking-v0", fabric_api_version) - subprojects.each { - api project(path: ":${it.name}", configuration: "dev") - include project(":${it.name}") + afterEvaluate { + subprojects.each { + api project(path: ":${it.name}", configuration: "namedElements") + + testmodImplementation project("${it.name}:").sourceSets.testmod.output + } } } @@ -225,28 +306,11 @@ task testmodJar(type: Jar, dependsOn: testmodClasses) { task remapTestmodJar(type: RemapJarTask, dependsOn: project.testmodJar) { archiveBaseName = 'CCATest' + archiveClassifier = 'testmod' input = testmodJar.archiveFile addNestedDependencies = false } build.dependsOn(remapTestmodJar) -publishing { - publications { - mavenJava(MavenPublication) { - pom.withXml { - def depsNode = asNode().appendNode("dependencies") - subprojects.each { - def depNode = depsNode.appendNode("dependency") - depNode.appendNode("groupId", it.group) - depNode.appendNode("artifactId", it.name) - depNode.appendNode("version", it.version) - depNode.appendNode("scope", "compile") - } - } - } - } -} -tasks.publish.dependsOn build //stupid fix for maven/loom not publishing the main artifact - apply from: 'release.gradle' diff --git a/cardinal-components-base/src/main/java/dev/onyxstudios/cca/internal/base/ComponentRegistryImpl.java b/cardinal-components-base/src/main/java/dev/onyxstudios/cca/internal/base/ComponentRegistryImpl.java index f6f4a237..77117e65 100644 --- a/cardinal-components-base/src/main/java/dev/onyxstudios/cca/internal/base/ComponentRegistryImpl.java +++ b/cardinal-components-base/src/main/java/dev/onyxstudios/cca/internal/base/ComponentRegistryImpl.java @@ -89,7 +89,7 @@ public Stream> stream() { } @VisibleForTesting - void clear() { - this.keys.clear(); + void clear(Identifier id) { + this.keys.remove(id); } } diff --git a/cardinal-components-block/build.gradle b/cardinal-components-block/build.gradle index 6ead078d..129d79ff 100644 --- a/cardinal-components-block/build.gradle +++ b/cardinal-components-block/build.gradle @@ -1,4 +1,4 @@ dependencies { - api project(":cardinal-components-base") + api project(path: ":cardinal-components-base", configuration: "namedElements") modApi fabricApi.module("fabric-api-lookup-api-v1", rootProject.fabric_api_version) } diff --git a/cardinal-components-chunk/build.gradle b/cardinal-components-chunk/build.gradle index ae86ceba..c73d053a 100644 --- a/cardinal-components-chunk/build.gradle +++ b/cardinal-components-chunk/build.gradle @@ -1,3 +1,3 @@ dependencies { - api project(":cardinal-components-base") + api project(path: ":cardinal-components-base", configuration: "namedElements") } diff --git a/cardinal-components-entity/build.gradle b/cardinal-components-entity/build.gradle index f790ce06..c73d053a 100644 --- a/cardinal-components-entity/build.gradle +++ b/cardinal-components-entity/build.gradle @@ -1,3 +1,3 @@ dependencies { - api project(":cardinal-components-base") -} \ No newline at end of file + api project(path: ":cardinal-components-base", configuration: "namedElements") +} diff --git a/cardinal-components-item/build.gradle b/cardinal-components-item/build.gradle index f790ce06..c73d053a 100644 --- a/cardinal-components-item/build.gradle +++ b/cardinal-components-item/build.gradle @@ -1,3 +1,3 @@ dependencies { - api project(":cardinal-components-base") -} \ No newline at end of file + api project(path: ":cardinal-components-base", configuration: "namedElements") +} diff --git a/cardinal-components-level/build.gradle b/cardinal-components-level/build.gradle index 6ccd0f1e..28e42302 100644 --- a/cardinal-components-level/build.gradle +++ b/cardinal-components-level/build.gradle @@ -1,4 +1,4 @@ dependencies { - api project(":cardinal-components-base") - api project(":cardinal-components-world") + api project(path: ":cardinal-components-base", configuration: "namedElements") + api project(path: ":cardinal-components-world", configuration: "namedElements") } diff --git a/cardinal-components-scoreboard/build.gradle b/cardinal-components-scoreboard/build.gradle index f790ce06..c73d053a 100644 --- a/cardinal-components-scoreboard/build.gradle +++ b/cardinal-components-scoreboard/build.gradle @@ -1,3 +1,3 @@ dependencies { - api project(":cardinal-components-base") -} \ No newline at end of file + api project(path: ":cardinal-components-base", configuration: "namedElements") +} diff --git a/cardinal-components-world/build.gradle b/cardinal-components-world/build.gradle index ae86ceba..c73d053a 100644 --- a/cardinal-components-world/build.gradle +++ b/cardinal-components-world/build.gradle @@ -1,3 +1,3 @@ dependencies { - api project(":cardinal-components-base") + api project(path: ":cardinal-components-base", configuration: "namedElements") } diff --git a/src/test/java/nerdhub/cardinal/components/TestComponent.java b/src/test/java/nerdhub/cardinal/components/TestComponent.java deleted file mode 100644 index 180c1f75..00000000 --- a/src/test/java/nerdhub/cardinal/components/TestComponent.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Cardinal-Components-API - * Copyright (C) 2019-2021 OnyxStudios - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE - * OR OTHER DEALINGS IN THE SOFTWARE. - */ -package nerdhub.cardinal.components; - -import dev.onyxstudios.cca.api.v3.component.Component; -import net.minecraft.nbt.NbtCompound; -import org.jetbrains.annotations.Nullable; - -import java.util.Objects; - -public interface TestComponent extends Component { - - class Impl implements TestComponent { - private int i; - - public Impl(int i) { - this.i = i; - } - - @Override - public void readFromNbt(NbtCompound tag) { - this.i = tag.getInt("i"); - } - - @Override - public void writeToNbt(NbtCompound tag) { - tag.putInt("i", i); - } - - public Component newInstance() { - return new Impl(i); - } - - @Override - public String toString() { - return "Impl@" + this.hashCode(); - } - - @Override - public boolean equals(@Nullable Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Impl impl = (Impl) o; - return i == impl.i; - } - - @Override - public int hashCode() { - return Objects.hash(i); - } - } -} diff --git a/src/test/java/dev/onyxstudios/cca/internal/base/CcaTesting.java b/src/testmod/java/dev/onyxstudios/cca/internal/base/CcaTesting.java similarity index 84% rename from src/test/java/dev/onyxstudios/cca/internal/base/CcaTesting.java rename to src/testmod/java/dev/onyxstudios/cca/internal/base/CcaTesting.java index a3116ded..483c74fb 100644 --- a/src/test/java/dev/onyxstudios/cca/internal/base/CcaTesting.java +++ b/src/testmod/java/dev/onyxstudios/cca/internal/base/CcaTesting.java @@ -22,19 +22,13 @@ */ package dev.onyxstudios.cca.internal.base; -import dev.onyxstudios.cca.internal.base.asm.CcaBootstrapTest; import net.minecraft.util.Identifier; +import java.util.List; + public class CcaTesting { public static final Identifier TEST_ID_1 = new Identifier("testmod:test"); public static final Identifier TEST_ID_2 = new Identifier("testmod:test_2"); public static final Identifier TEST_ID_3 = new Identifier("testmod:test_3"); - - public static void init() { - CcaBootstrapTest.addStaticComponentInitializers( - CcaTesting.TEST_ID_1, - CcaTesting.TEST_ID_2, - CcaTesting.TEST_ID_3 - ); - } + public static final List ALL_TEST_IDS = List.of(TEST_ID_1, TEST_ID_2, TEST_ID_3); } diff --git a/src/test/java/dev/onyxstudios/cca/internal/base/ComponentRegistryImplTest.java b/src/testmod/java/dev/onyxstudios/cca/internal/base/ComponentRegistryImplTest.java similarity index 66% rename from src/test/java/dev/onyxstudios/cca/internal/base/ComponentRegistryImplTest.java rename to src/testmod/java/dev/onyxstudios/cca/internal/base/ComponentRegistryImplTest.java index 02d8225b..95ef3493 100644 --- a/src/test/java/dev/onyxstudios/cca/internal/base/ComponentRegistryImplTest.java +++ b/src/testmod/java/dev/onyxstudios/cca/internal/base/ComponentRegistryImplTest.java @@ -24,42 +24,39 @@ import dev.onyxstudios.cca.api.v3.component.Component; import dev.onyxstudios.cca.api.v3.component.ComponentKey; +import dev.onyxstudios.componenttest.tests.CardinalGameTest; import net.minecraft.nbt.NbtCompound; +import net.minecraft.test.GameTest; import net.minecraft.util.Identifier; -import org.junit.After; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.Assert; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; - -public class ComponentRegistryImplTest { - - @BeforeClass - public static void beforeAll() { - CcaTesting.init(); - } +public class ComponentRegistryImplTest implements CardinalGameTest { @SuppressWarnings({"unchecked", "rawtypes"}) - @Test public void checksRegisteredClasses() { + @GameTest(structureName = EMPTY_STRUCTURE) + public void checksRegisteredClasses() { ComponentRegistryImpl registry = ComponentRegistryImpl.INSTANCE; - assertThrows("Component class must extend Component", IllegalArgumentException.class, () -> registry.getOrCreate(CcaTesting.TEST_ID_1, (Class) TestNotComponentItf.class)); + Assert.assertThrows("Component class must extend Component", IllegalArgumentException.class, () -> registry.getOrCreate(CcaTesting.TEST_ID_1, (Class) TestNotComponentItf.class)); registry.getOrCreate(CcaTesting.TEST_ID_1, TestComponentNotItf.class); registry.getOrCreate(CcaTesting.TEST_ID_2, TestComponentItf.class); } - @Test public void doesNotDuplicateComponentTypes() { + @GameTest(structureName = EMPTY_STRUCTURE) + public void doesNotDuplicateComponentTypes() { ComponentRegistryImpl registry = ComponentRegistryImpl.INSTANCE; Identifier id = CcaTesting.TEST_ID_1; ComponentKey type = registry.getOrCreate(id, TestComponentItf.class); - assertThrows(IllegalStateException.class, () -> registry.getOrCreate(id, TestComponentItf2.class)); - assertThrows(IllegalStateException.class, () -> registry.getOrCreate(id, TestComponentItf3.class)); - assertEquals(type, registry.getOrCreate(id, TestComponentItf.class)); - assertEquals(1, registry.stream().count()); + Assert.assertThrows(IllegalStateException.class, () -> registry.getOrCreate(id, TestComponentItf2.class)); + Assert.assertThrows(IllegalStateException.class, () -> registry.getOrCreate(id, TestComponentItf3.class)); + Assert.assertEquals(type, registry.getOrCreate(id, TestComponentItf.class)); + Assert.assertEquals(1, registry.stream().map(ComponentKey::getId).filter(CcaTesting.ALL_TEST_IDS::contains).count()); } - @After public void tearDown() { - ComponentRegistryImpl.INSTANCE.clear(); + @Override + public void tearDown() { + for (Identifier id : CcaTesting.ALL_TEST_IDS) { + ComponentRegistryImpl.INSTANCE.clear(id); + } } interface TestNotComponentItf {} diff --git a/src/test/java/dev/onyxstudios/cca/internal/base/QualifiedComponentFactoryTest.java b/src/testmod/java/dev/onyxstudios/cca/internal/base/QualifiedComponentFactoryTest.java similarity index 79% rename from src/test/java/dev/onyxstudios/cca/internal/base/QualifiedComponentFactoryTest.java rename to src/testmod/java/dev/onyxstudios/cca/internal/base/QualifiedComponentFactoryTest.java index d88e36f2..78a76f4e 100644 --- a/src/test/java/dev/onyxstudios/cca/internal/base/QualifiedComponentFactoryTest.java +++ b/src/testmod/java/dev/onyxstudios/cca/internal/base/QualifiedComponentFactoryTest.java @@ -25,28 +25,25 @@ import dev.onyxstudios.cca.api.v3.component.ComponentKey; import dev.onyxstudios.cca.api.v3.component.ComponentRegistry; import dev.onyxstudios.cca.internal.base.asm.StaticComponentLoadingException; -import org.junit.After; -import org.junit.BeforeClass; -import org.junit.Test; +import dev.onyxstudios.componenttest.tests.CardinalGameTest; +import net.minecraft.test.GameTest; +import net.minecraft.util.Identifier; +import org.junit.Assert; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; -import static org.junit.Assert.*; - -public class QualifiedComponentFactoryTest { - @BeforeClass - public static void beforeAll() { - CcaTesting.init(); - } - - @After public void tearDown() { - ComponentRegistryImpl.INSTANCE.clear(); +public class QualifiedComponentFactoryTest implements CardinalGameTest { + @Override + public void tearDown() { + for (Identifier id : CcaTesting.ALL_TEST_IDS) { + ComponentRegistryImpl.INSTANCE.clear(id); + } } - @Test + @GameTest(structureName = EMPTY_STRUCTURE) public void sortKeepsOrderByDefault() { Map, QualifiedComponentFactory> map = new LinkedHashMap<>(); var key1 = ComponentRegistry.getOrCreate(CcaTesting.TEST_ID_1, ComponentRegistryImplTest.TestComponentNotItf.class); @@ -56,48 +53,48 @@ public void sortKeepsOrderByDefault() { map.put(key2, new QualifiedComponentFactory<>(new Object(), key2.getComponentClass(), Set.of())); map.put(key3, new QualifiedComponentFactory<>(new Object(), key3.getComponentClass(), Set.of())); Map, QualifiedComponentFactory> sorted = QualifiedComponentFactory.sort(map); - assertNotSame(map, sorted); - assertEquals(List.copyOf(map.keySet()), List.copyOf(sorted.keySet())); + Assert.assertNotSame(map, sorted); + Assert.assertEquals(List.copyOf(map.keySet()), List.copyOf(sorted.keySet())); map = new LinkedHashMap<>(); map.put(key1, new QualifiedComponentFactory<>(new Object(), key1.getComponentClass(), Set.of())); map.put(key3, new QualifiedComponentFactory<>(new Object(), key3.getComponentClass(), Set.of())); map.put(key2, new QualifiedComponentFactory<>(new Object(), key2.getComponentClass(), Set.of())); sorted = QualifiedComponentFactory.sort(map); - assertNotSame(map, sorted); - assertEquals(List.copyOf(map.keySet()), List.copyOf(sorted.keySet())); + Assert.assertNotSame(map, sorted); + Assert.assertEquals(List.copyOf(map.keySet()), List.copyOf(sorted.keySet())); } - @Test + @GameTest(structureName = EMPTY_STRUCTURE) public void sortThrowsOnUnsatisfiedDependency() { Map, QualifiedComponentFactory> map = new LinkedHashMap<>(); var key1 = ComponentRegistry.getOrCreate(CcaTesting.TEST_ID_1, ComponentRegistryImplTest.TestComponentNotItf.class); var key2 = ComponentRegistry.getOrCreate(CcaTesting.TEST_ID_2, ComponentRegistryImplTest.TestComponentNotItf.class); map.put(key1, new QualifiedComponentFactory<>(new Object(), key1.getComponentClass(), Set.of(key2))); - assertThrows(StaticComponentLoadingException.class, () -> QualifiedComponentFactory.checkDependenciesSatisfied(map)); + Assert.assertThrows(StaticComponentLoadingException.class, () -> QualifiedComponentFactory.checkDependenciesSatisfied(map)); map.put(key2, new QualifiedComponentFactory<>(new Object(), key1.getComponentClass(), Set.of())); QualifiedComponentFactory.checkDependenciesSatisfied(map); } - @Test + @GameTest(structureName = EMPTY_STRUCTURE) public void sortThrowsOnCircularDependency() { Map, QualifiedComponentFactory> map = new LinkedHashMap<>(); var key1 = ComponentRegistry.getOrCreate(CcaTesting.TEST_ID_1, ComponentRegistryImplTest.TestComponentNotItf.class); var key2 = ComponentRegistry.getOrCreate(CcaTesting.TEST_ID_2, ComponentRegistryImplTest.TestComponentNotItf.class); var key3 = ComponentRegistry.getOrCreate(CcaTesting.TEST_ID_3, ComponentRegistryImplTest.TestComponentNotItf.class); map.put(key1, new QualifiedComponentFactory<>(new Object(), key1.getComponentClass(), Set.of(key1))); - assertThrows(StaticComponentLoadingException.class, () -> QualifiedComponentFactory.sort(map)); + Assert.assertThrows(StaticComponentLoadingException.class, () -> QualifiedComponentFactory.sort(map)); map.put(key1, new QualifiedComponentFactory<>(new Object(), key1.getComponentClass(), Set.of(key2))); map.put(key2, new QualifiedComponentFactory<>(new Object(), key1.getComponentClass(), Set.of(key1))); - assertThrows(StaticComponentLoadingException.class, () -> QualifiedComponentFactory.sort(map)); + Assert.assertThrows(StaticComponentLoadingException.class, () -> QualifiedComponentFactory.sort(map)); map.put(key1, new QualifiedComponentFactory<>(new Object(), key1.getComponentClass(), Set.of(key2))); map.put(key2, new QualifiedComponentFactory<>(new Object(), key1.getComponentClass(), Set.of(key3))); map.put(key3, new QualifiedComponentFactory<>(new Object(), key1.getComponentClass(), Set.of(key1))); - assertThrows(StaticComponentLoadingException.class, () -> QualifiedComponentFactory.sort(map)); + Assert.assertThrows(StaticComponentLoadingException.class, () -> QualifiedComponentFactory.sort(map)); map.put(key3, new QualifiedComponentFactory<>(new Object(), key1.getComponentClass(), Set.of())); QualifiedComponentFactory.sort(map); } - @Test + @GameTest(structureName = EMPTY_STRUCTURE) public void sortRespectsDependencyOrdering() { Map, QualifiedComponentFactory> map = new LinkedHashMap<>(); var key1 = ComponentRegistry.getOrCreate(CcaTesting.TEST_ID_1, ComponentRegistryImplTest.TestComponentNotItf.class); @@ -105,9 +102,9 @@ public void sortRespectsDependencyOrdering() { var key3 = ComponentRegistry.getOrCreate(CcaTesting.TEST_ID_3, ComponentRegistryImplTest.TestComponentNotItf.class); map.put(key1, new QualifiedComponentFactory<>(new Object(), key1.getComponentClass(), Set.of(key2))); map.put(key2, new QualifiedComponentFactory<>(new Object(), key2.getComponentClass(), Set.of())); - assertEquals(List.of(key2, key1), List.copyOf(QualifiedComponentFactory.sort(map).keySet())); + Assert.assertEquals(List.of(key2, key1), List.copyOf(QualifiedComponentFactory.sort(map).keySet())); map.put(key1, new QualifiedComponentFactory<>(new Object(), key1.getComponentClass(), Set.of(key2, key3))); map.put(key3, new QualifiedComponentFactory<>(new Object(), key3.getComponentClass(), Set.of(key2))); - assertEquals(List.of(key2, key3, key1), List.copyOf(QualifiedComponentFactory.sort(map).keySet())); + Assert.assertEquals(List.of(key2, key3, key1), List.copyOf(QualifiedComponentFactory.sort(map).keySet())); } } diff --git a/src/testmod/java/dev/onyxstudios/componenttest/CCATestClient.java b/src/testmod/java/dev/onyxstudios/componenttest/content/CCATestClient.java similarity index 87% rename from src/testmod/java/dev/onyxstudios/componenttest/CCATestClient.java rename to src/testmod/java/dev/onyxstudios/componenttest/content/CCATestClient.java index 843c844f..a56be50e 100644 --- a/src/testmod/java/dev/onyxstudios/componenttest/CCATestClient.java +++ b/src/testmod/java/dev/onyxstudios/componenttest/content/CCATestClient.java @@ -20,16 +20,16 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE * OR OTHER DEALINGS IN THE SOFTWARE. */ -package dev.onyxstudios.componenttest; +package dev.onyxstudios.componenttest.content; import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback; -import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry; +import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry; import net.minecraft.client.render.entity.ZombieEntityRenderer; import net.minecraft.text.TranslatableText; public final class CCATestClient { public static void clientInit() { - EntityRendererRegistry.INSTANCE.register(CardinalComponentsTest.VITALITY_ZOMBIE, ZombieEntityRenderer::new); + EntityRendererRegistry.register(CardinalComponentsTest.VITALITY_ZOMBIE, ZombieEntityRenderer::new); ItemTooltipCallback.EVENT.register((stack, tooltipContext, lines) -> TestComponents.ALT_VITA.maybeGet(stack).ifPresent(vita -> lines.add(new TranslatableText("componenttest:tooltip.vitality.native", vita.getVitality()))) ); diff --git a/src/testmod/java/dev/onyxstudios/componenttest/CardinalComponentsTest.java b/src/testmod/java/dev/onyxstudios/componenttest/content/CardinalComponentsTest.java similarity index 97% rename from src/testmod/java/dev/onyxstudios/componenttest/CardinalComponentsTest.java rename to src/testmod/java/dev/onyxstudios/componenttest/content/CardinalComponentsTest.java index 1d4a9f0b..7b905547 100644 --- a/src/testmod/java/dev/onyxstudios/componenttest/CardinalComponentsTest.java +++ b/src/testmod/java/dev/onyxstudios/componenttest/content/CardinalComponentsTest.java @@ -20,15 +20,15 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE * OR OTHER DEALINGS IN THE SOFTWARE. */ -package dev.onyxstudios.componenttest; +package dev.onyxstudios.componenttest.content; import dev.onyxstudios.cca.api.v3.block.BlockComponents; import dev.onyxstudios.cca.api.v3.component.Component; import dev.onyxstudios.cca.api.v3.component.ComponentContainer; import dev.onyxstudios.cca.api.v3.component.ComponentRegistryV3; import dev.onyxstudios.cca.internal.base.GenericContainerBuilder; -import dev.onyxstudios.componenttest.vita.BaseVita; -import dev.onyxstudios.componenttest.vita.Vita; +import dev.onyxstudios.componenttest.content.vita.BaseVita; +import dev.onyxstudios.componenttest.content.vita.Vita; import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder; import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback; import net.fabricmc.fabric.api.event.player.UseItemCallback; @@ -72,7 +72,7 @@ public class CardinalComponentsTest { public static final VitalityStickItem VITALITY_STICK = Registry.register(Registry.ITEM, VITA_STICK_ID, new VitalityStickItem(new Item.Settings().group(ITEM_GROUP).maxDamage(50))); - public static final VitalityCondenser VITALITY_CONDENSER = new VitalityCondenser(FabricBlockSettings.of(Material.STONE).dropsNothing().lightLevel(5).ticksRandomly()); + public static final VitalityCondenser VITALITY_CONDENSER = new VitalityCondenser(FabricBlockSettings.of(Material.STONE).dropsNothing().luminance(5).ticksRandomly()); public static final EntityType VITALITY_ZOMBIE = Registry.register(Registry.ENTITY_TYPE, "componenttest:vita_zombie", FabricEntityTypeBuilder.create(SpawnGroup.MONSTER, VitalityZombieEntity::new).dimensions(EntityType.ZOMBIE.getDimensions()).build()); diff --git a/src/testmod/java/dev/onyxstudios/componenttest/TestComponents.java b/src/testmod/java/dev/onyxstudios/componenttest/content/TestComponents.java similarity index 91% rename from src/testmod/java/dev/onyxstudios/componenttest/TestComponents.java rename to src/testmod/java/dev/onyxstudios/componenttest/content/TestComponents.java index e3f6f2cb..7a23c226 100644 --- a/src/testmod/java/dev/onyxstudios/componenttest/TestComponents.java +++ b/src/testmod/java/dev/onyxstudios/componenttest/content/TestComponents.java @@ -20,7 +20,7 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE * OR OTHER DEALINGS IN THE SOFTWARE. */ -package dev.onyxstudios.componenttest; +package dev.onyxstudios.componenttest.content; import dev.onyxstudios.cca.api.v3.block.BlockComponentFactoryRegistry; import dev.onyxstudios.cca.api.v3.block.BlockComponentInitializer; @@ -38,14 +38,14 @@ import dev.onyxstudios.cca.api.v3.scoreboard.ScoreboardComponentInitializer; import dev.onyxstudios.cca.api.v3.world.WorldComponentFactoryRegistry; import dev.onyxstudios.cca.api.v3.world.WorldComponentInitializer; -import dev.onyxstudios.componenttest.vita.AmbientVita; -import dev.onyxstudios.componenttest.vita.BaseVita; -import dev.onyxstudios.componenttest.vita.ChunkVita; -import dev.onyxstudios.componenttest.vita.ItemVita; -import dev.onyxstudios.componenttest.vita.PlayerVita; -import dev.onyxstudios.componenttest.vita.SyncedVita; -import dev.onyxstudios.componenttest.vita.TeamVita; -import dev.onyxstudios.componenttest.vita.Vita; +import dev.onyxstudios.componenttest.content.vita.AmbientVita; +import dev.onyxstudios.componenttest.content.vita.BaseVita; +import dev.onyxstudios.componenttest.content.vita.ChunkVita; +import dev.onyxstudios.componenttest.content.vita.ItemVita; +import dev.onyxstudios.componenttest.content.vita.PlayerVita; +import dev.onyxstudios.componenttest.content.vita.SyncedVita; +import dev.onyxstudios.componenttest.content.vita.TeamVita; +import dev.onyxstudios.componenttest.content.vita.Vita; import net.minecraft.block.entity.EndGatewayBlockEntity; import net.minecraft.block.entity.EndPortalBlockEntity; import net.minecraft.entity.LivingEntity; diff --git a/src/testmod/java/dev/onyxstudios/componenttest/TestStaticComponentInitializer.java b/src/testmod/java/dev/onyxstudios/componenttest/content/TestStaticComponentInitializer.java similarity index 94% rename from src/testmod/java/dev/onyxstudios/componenttest/TestStaticComponentInitializer.java rename to src/testmod/java/dev/onyxstudios/componenttest/content/TestStaticComponentInitializer.java index c424529e..f025f23c 100644 --- a/src/testmod/java/dev/onyxstudios/componenttest/TestStaticComponentInitializer.java +++ b/src/testmod/java/dev/onyxstudios/componenttest/content/TestStaticComponentInitializer.java @@ -20,14 +20,14 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE * OR OTHER DEALINGS IN THE SOFTWARE. */ -package dev.onyxstudios.componenttest; +package dev.onyxstudios.componenttest.content; import dev.onyxstudios.cca.api.v3.component.ComponentContainer; import dev.onyxstudios.cca.api.v3.component.ComponentRegistry; import dev.onyxstudios.cca.api.v3.component.ComponentRegistryV3; import dev.onyxstudios.cca.api.v3.component.StaticComponentInitializer; -import dev.onyxstudios.componenttest.vita.BaseVita; -import dev.onyxstudios.componenttest.vita.Vita; +import dev.onyxstudios.componenttest.content.vita.BaseVita; +import dev.onyxstudios.componenttest.content.vita.Vita; import net.minecraft.util.Identifier; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/src/testmod/java/dev/onyxstudios/componenttest/VitaCommand.java b/src/testmod/java/dev/onyxstudios/componenttest/content/VitaCommand.java similarity index 97% rename from src/testmod/java/dev/onyxstudios/componenttest/VitaCommand.java rename to src/testmod/java/dev/onyxstudios/componenttest/content/VitaCommand.java index f1f9a457..8ad31e4d 100644 --- a/src/testmod/java/dev/onyxstudios/componenttest/VitaCommand.java +++ b/src/testmod/java/dev/onyxstudios/componenttest/content/VitaCommand.java @@ -20,11 +20,11 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE * OR OTHER DEALINGS IN THE SOFTWARE. */ -package dev.onyxstudios.componenttest; +package dev.onyxstudios.componenttest.content; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.IntegerArgumentType; -import dev.onyxstudios.componenttest.vita.Vita; +import dev.onyxstudios.componenttest.content.vita.Vita; import net.minecraft.command.argument.BlockPosArgumentType; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; diff --git a/src/testmod/java/dev/onyxstudios/componenttest/VitaCompound.java b/src/testmod/java/dev/onyxstudios/componenttest/content/VitaCompound.java similarity index 95% rename from src/testmod/java/dev/onyxstudios/componenttest/VitaCompound.java rename to src/testmod/java/dev/onyxstudios/componenttest/content/VitaCompound.java index 4a815851..cca53111 100644 --- a/src/testmod/java/dev/onyxstudios/componenttest/VitaCompound.java +++ b/src/testmod/java/dev/onyxstudios/componenttest/content/VitaCompound.java @@ -20,13 +20,13 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE * OR OTHER DEALINGS IN THE SOFTWARE. */ -package dev.onyxstudios.componenttest; +package dev.onyxstudios.componenttest.content; import dev.onyxstudios.cca.api.v3.component.ComponentKey; import dev.onyxstudios.cca.api.v3.component.ComponentRegistryV3; import dev.onyxstudios.cca.api.v3.component.sync.AutoSyncedComponent; -import dev.onyxstudios.componenttest.vita.SyncedVita; -import dev.onyxstudios.componenttest.vita.Vita; +import dev.onyxstudios.componenttest.content.vita.SyncedVita; +import dev.onyxstudios.componenttest.content.vita.Vita; import net.fabricmc.fabric.api.util.NbtType; import net.minecraft.block.entity.BlockEntity; import net.minecraft.nbt.NbtCompound; diff --git a/src/testmod/java/dev/onyxstudios/componenttest/VitalityCondenser.java b/src/testmod/java/dev/onyxstudios/componenttest/content/VitalityCondenser.java similarity index 96% rename from src/testmod/java/dev/onyxstudios/componenttest/VitalityCondenser.java rename to src/testmod/java/dev/onyxstudios/componenttest/content/VitalityCondenser.java index 9f2e55f0..5cd3b30c 100644 --- a/src/testmod/java/dev/onyxstudios/componenttest/VitalityCondenser.java +++ b/src/testmod/java/dev/onyxstudios/componenttest/content/VitalityCondenser.java @@ -20,9 +20,9 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE * OR OTHER DEALINGS IN THE SOFTWARE. */ -package dev.onyxstudios.componenttest; +package dev.onyxstudios.componenttest.content; -import dev.onyxstudios.componenttest.vita.Vita; +import dev.onyxstudios.componenttest.content.vita.Vita; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/testmod/java/dev/onyxstudios/componenttest/VitalityStickItem.java b/src/testmod/java/dev/onyxstudios/componenttest/content/VitalityStickItem.java similarity index 96% rename from src/testmod/java/dev/onyxstudios/componenttest/VitalityStickItem.java rename to src/testmod/java/dev/onyxstudios/componenttest/content/VitalityStickItem.java index 378c31cf..a1e8f502 100644 --- a/src/testmod/java/dev/onyxstudios/componenttest/VitalityStickItem.java +++ b/src/testmod/java/dev/onyxstudios/componenttest/content/VitalityStickItem.java @@ -20,10 +20,10 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE * OR OTHER DEALINGS IN THE SOFTWARE. */ -package dev.onyxstudios.componenttest; +package dev.onyxstudios.componenttest.content; -import dev.onyxstudios.componenttest.vita.AmbientVita; -import dev.onyxstudios.componenttest.vita.Vita; +import dev.onyxstudios.componenttest.content.vita.AmbientVita; +import dev.onyxstudios.componenttest.content.vita.Vita; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.block.BlockState; diff --git a/src/testmod/java/dev/onyxstudios/componenttest/VitalityZombieEntity.java b/src/testmod/java/dev/onyxstudios/componenttest/content/VitalityZombieEntity.java similarity index 94% rename from src/testmod/java/dev/onyxstudios/componenttest/VitalityZombieEntity.java rename to src/testmod/java/dev/onyxstudios/componenttest/content/VitalityZombieEntity.java index 7a6542e5..1ddae17b 100644 --- a/src/testmod/java/dev/onyxstudios/componenttest/VitalityZombieEntity.java +++ b/src/testmod/java/dev/onyxstudios/componenttest/content/VitalityZombieEntity.java @@ -20,9 +20,9 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE * OR OTHER DEALINGS IN THE SOFTWARE. */ -package dev.onyxstudios.componenttest; +package dev.onyxstudios.componenttest.content; -import dev.onyxstudios.componenttest.vita.EntityVita; +import dev.onyxstudios.componenttest.content.vita.EntityVita; import net.minecraft.entity.EntityType; import net.minecraft.entity.mob.ZombieEntity; import net.minecraft.particle.ParticleTypes; diff --git a/src/test/java/nerdhub/cardinal/components/package-info.java b/src/testmod/java/dev/onyxstudios/componenttest/content/package-info.java similarity index 96% rename from src/test/java/nerdhub/cardinal/components/package-info.java rename to src/testmod/java/dev/onyxstudios/componenttest/content/package-info.java index b69bc0d5..bb85c28a 100644 --- a/src/test/java/nerdhub/cardinal/components/package-info.java +++ b/src/testmod/java/dev/onyxstudios/componenttest/content/package-info.java @@ -22,7 +22,7 @@ */ @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault -package nerdhub.cardinal.components; +package dev.onyxstudios.componenttest.content; import dev.onyxstudios.cca.api.v3.util.MethodsReturnNonnullByDefault; diff --git a/src/testmod/java/dev/onyxstudios/componenttest/vita/AmbientVita.java b/src/testmod/java/dev/onyxstudios/componenttest/content/vita/AmbientVita.java similarity index 95% rename from src/testmod/java/dev/onyxstudios/componenttest/vita/AmbientVita.java rename to src/testmod/java/dev/onyxstudios/componenttest/content/vita/AmbientVita.java index 85e3b7e2..b6254637 100644 --- a/src/testmod/java/dev/onyxstudios/componenttest/vita/AmbientVita.java +++ b/src/testmod/java/dev/onyxstudios/componenttest/content/vita/AmbientVita.java @@ -20,13 +20,13 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE * OR OTHER DEALINGS IN THE SOFTWARE. */ -package dev.onyxstudios.componenttest.vita; +package dev.onyxstudios.componenttest.content.vita; import dev.onyxstudios.cca.api.v3.component.sync.AutoSyncedComponent; import dev.onyxstudios.cca.api.v3.component.tick.ClientTickingComponent; import dev.onyxstudios.cca.api.v3.level.LevelComponents; -import dev.onyxstudios.componenttest.CardinalComponentsTest; -import dev.onyxstudios.componenttest.TestComponents; +import dev.onyxstudios.componenttest.content.CardinalComponentsTest; +import dev.onyxstudios.componenttest.content.TestComponents; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.network.PacketByteBuf; diff --git a/src/testmod/java/dev/onyxstudios/componenttest/vita/BaseVita.java b/src/testmod/java/dev/onyxstudios/componenttest/content/vita/BaseVita.java similarity index 97% rename from src/testmod/java/dev/onyxstudios/componenttest/vita/BaseVita.java rename to src/testmod/java/dev/onyxstudios/componenttest/content/vita/BaseVita.java index 110cee5b..94f553be 100644 --- a/src/testmod/java/dev/onyxstudios/componenttest/vita/BaseVita.java +++ b/src/testmod/java/dev/onyxstudios/componenttest/content/vita/BaseVita.java @@ -20,7 +20,7 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE * OR OTHER DEALINGS IN THE SOFTWARE. */ -package dev.onyxstudios.componenttest.vita; +package dev.onyxstudios.componenttest.content.vita; import dev.onyxstudios.cca.api.v3.component.Component; import dev.onyxstudios.cca.api.v3.component.CopyableComponent; diff --git a/src/testmod/java/dev/onyxstudios/componenttest/vita/ChunkVita.java b/src/testmod/java/dev/onyxstudios/componenttest/content/vita/ChunkVita.java similarity index 93% rename from src/testmod/java/dev/onyxstudios/componenttest/vita/ChunkVita.java rename to src/testmod/java/dev/onyxstudios/componenttest/content/vita/ChunkVita.java index 8d67dfc9..35734b64 100644 --- a/src/testmod/java/dev/onyxstudios/componenttest/vita/ChunkVita.java +++ b/src/testmod/java/dev/onyxstudios/componenttest/content/vita/ChunkVita.java @@ -20,10 +20,10 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE * OR OTHER DEALINGS IN THE SOFTWARE. */ -package dev.onyxstudios.componenttest.vita; +package dev.onyxstudios.componenttest.content.vita; import dev.onyxstudios.cca.api.v3.component.sync.AutoSyncedComponent; -import dev.onyxstudios.componenttest.TestComponents; +import dev.onyxstudios.componenttest.content.TestComponents; import net.minecraft.world.chunk.Chunk; public class ChunkVita extends BaseVita implements AutoSyncedComponent { diff --git a/src/testmod/java/dev/onyxstudios/componenttest/vita/EntityVita.java b/src/testmod/java/dev/onyxstudios/componenttest/content/vita/EntityVita.java similarity index 97% rename from src/testmod/java/dev/onyxstudios/componenttest/vita/EntityVita.java rename to src/testmod/java/dev/onyxstudios/componenttest/content/vita/EntityVita.java index ad7e5319..1ae3b6d4 100644 --- a/src/testmod/java/dev/onyxstudios/componenttest/vita/EntityVita.java +++ b/src/testmod/java/dev/onyxstudios/componenttest/content/vita/EntityVita.java @@ -20,7 +20,7 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE * OR OTHER DEALINGS IN THE SOFTWARE. */ -package dev.onyxstudios.componenttest.vita; +package dev.onyxstudios.componenttest.content.vita; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.effect.StatusEffectInstance; diff --git a/src/testmod/java/dev/onyxstudios/componenttest/vita/ItemVita.java b/src/testmod/java/dev/onyxstudios/componenttest/content/vita/ItemVita.java similarity index 96% rename from src/testmod/java/dev/onyxstudios/componenttest/vita/ItemVita.java rename to src/testmod/java/dev/onyxstudios/componenttest/content/vita/ItemVita.java index d738e3e5..35f0317f 100644 --- a/src/testmod/java/dev/onyxstudios/componenttest/vita/ItemVita.java +++ b/src/testmod/java/dev/onyxstudios/componenttest/content/vita/ItemVita.java @@ -20,7 +20,7 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE * OR OTHER DEALINGS IN THE SOFTWARE. */ -package dev.onyxstudios.componenttest.vita; +package dev.onyxstudios.componenttest.content.vita; import dev.onyxstudios.cca.api.v3.item.ItemComponent; import net.minecraft.item.ItemStack; diff --git a/src/testmod/java/dev/onyxstudios/componenttest/vita/PlayerVita.java b/src/testmod/java/dev/onyxstudios/componenttest/content/vita/PlayerVita.java similarity index 95% rename from src/testmod/java/dev/onyxstudios/componenttest/vita/PlayerVita.java rename to src/testmod/java/dev/onyxstudios/componenttest/content/vita/PlayerVita.java index a5399154..9581caa7 100644 --- a/src/testmod/java/dev/onyxstudios/componenttest/vita/PlayerVita.java +++ b/src/testmod/java/dev/onyxstudios/componenttest/content/vita/PlayerVita.java @@ -20,14 +20,14 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE * OR OTHER DEALINGS IN THE SOFTWARE. */ -package dev.onyxstudios.componenttest.vita; +package dev.onyxstudios.componenttest.content.vita; import dev.onyxstudios.cca.api.v3.component.sync.AutoSyncedComponent; import dev.onyxstudios.cca.api.v3.component.sync.PlayerSyncPredicate; import dev.onyxstudios.cca.api.v3.component.tick.ServerTickingComponent; import dev.onyxstudios.cca.api.v3.entity.PlayerComponent; -import dev.onyxstudios.componenttest.CardinalComponentsTest; -import dev.onyxstudios.componenttest.TestComponents; +import dev.onyxstudios.componenttest.content.CardinalComponentsTest; +import dev.onyxstudios.componenttest.content.TestComponents; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.network.PacketByteBuf; diff --git a/src/testmod/java/dev/onyxstudios/componenttest/vita/SyncedVita.java b/src/testmod/java/dev/onyxstudios/componenttest/content/vita/SyncedVita.java similarity index 93% rename from src/testmod/java/dev/onyxstudios/componenttest/vita/SyncedVita.java rename to src/testmod/java/dev/onyxstudios/componenttest/content/vita/SyncedVita.java index 46fae7de..0f4fcdfb 100644 --- a/src/testmod/java/dev/onyxstudios/componenttest/vita/SyncedVita.java +++ b/src/testmod/java/dev/onyxstudios/componenttest/content/vita/SyncedVita.java @@ -20,10 +20,10 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE * OR OTHER DEALINGS IN THE SOFTWARE. */ -package dev.onyxstudios.componenttest.vita; +package dev.onyxstudios.componenttest.content.vita; import dev.onyxstudios.cca.api.v3.component.sync.AutoSyncedComponent; -import dev.onyxstudios.componenttest.TestComponents; +import dev.onyxstudios.componenttest.content.TestComponents; public class SyncedVita extends BaseVita implements AutoSyncedComponent { private final Object owner; diff --git a/src/testmod/java/dev/onyxstudios/componenttest/vita/TeamVita.java b/src/testmod/java/dev/onyxstudios/componenttest/content/vita/TeamVita.java similarity index 97% rename from src/testmod/java/dev/onyxstudios/componenttest/vita/TeamVita.java rename to src/testmod/java/dev/onyxstudios/componenttest/content/vita/TeamVita.java index af8f3ef1..61f56f6d 100644 --- a/src/testmod/java/dev/onyxstudios/componenttest/vita/TeamVita.java +++ b/src/testmod/java/dev/onyxstudios/componenttest/content/vita/TeamVita.java @@ -20,7 +20,7 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE * OR OTHER DEALINGS IN THE SOFTWARE. */ -package dev.onyxstudios.componenttest.vita; +package dev.onyxstudios.componenttest.content.vita; import dev.onyxstudios.cca.api.v3.component.sync.AutoSyncedComponent; import net.minecraft.scoreboard.Team; diff --git a/src/testmod/java/dev/onyxstudios/componenttest/vita/Vita.java b/src/testmod/java/dev/onyxstudios/componenttest/content/vita/Vita.java similarity index 93% rename from src/testmod/java/dev/onyxstudios/componenttest/vita/Vita.java rename to src/testmod/java/dev/onyxstudios/componenttest/content/vita/Vita.java index 5f0cc2c2..a55ba74a 100644 --- a/src/testmod/java/dev/onyxstudios/componenttest/vita/Vita.java +++ b/src/testmod/java/dev/onyxstudios/componenttest/content/vita/Vita.java @@ -20,10 +20,10 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE * OR OTHER DEALINGS IN THE SOFTWARE. */ -package dev.onyxstudios.componenttest.vita; +package dev.onyxstudios.componenttest.content.vita; import dev.onyxstudios.cca.api.v3.component.ComponentV3; -import dev.onyxstudios.componenttest.TestComponents; +import dev.onyxstudios.componenttest.content.TestComponents; public interface Vita extends ComponentV3 { diff --git a/src/test/java/dev/onyxstudios/cca/api/v3/util/util/impl/package-info.java b/src/testmod/java/dev/onyxstudios/componenttest/content/vita/package-info.java similarity index 96% rename from src/test/java/dev/onyxstudios/cca/api/v3/util/util/impl/package-info.java rename to src/testmod/java/dev/onyxstudios/componenttest/content/vita/package-info.java index 37d257ec..eb442b90 100644 --- a/src/test/java/dev/onyxstudios/cca/api/v3/util/util/impl/package-info.java +++ b/src/testmod/java/dev/onyxstudios/componenttest/content/vita/package-info.java @@ -22,7 +22,7 @@ */ @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault -package dev.onyxstudios.cca.api.v3.util.util.impl; +package dev.onyxstudios.componenttest.content.vita; import dev.onyxstudios.cca.api.v3.util.MethodsReturnNonnullByDefault; diff --git a/src/testmod/java/dev/onyxstudios/componenttest/package-info.java b/src/testmod/java/dev/onyxstudios/componenttest/package-info.java deleted file mode 100644 index 1efbedb8..00000000 --- a/src/testmod/java/dev/onyxstudios/componenttest/package-info.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Cardinal-Components-API - * Copyright (C) 2019-2021 OnyxStudios - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE - * OR OTHER DEALINGS IN THE SOFTWARE. - */ -@MethodsReturnNonnullByDefault -@ParametersAreNonnullByDefault -package dev.onyxstudios.componenttest; - -import dev.onyxstudios.cca.api.v3.util.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/testmod/java/dev/onyxstudios/componenttest/tests/CardinalGameTest.java b/src/testmod/java/dev/onyxstudios/componenttest/tests/CardinalGameTest.java new file mode 100644 index 00000000..2f09f089 --- /dev/null +++ b/src/testmod/java/dev/onyxstudios/componenttest/tests/CardinalGameTest.java @@ -0,0 +1,65 @@ +/* + * Cardinal-Components-API + * Copyright (C) 2019-2021 OnyxStudios + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE + * OR OTHER DEALINGS IN THE SOFTWARE. + */ +package dev.onyxstudios.componenttest.tests; + +import dev.onyxstudios.componenttest.content.CardinalComponentsTest; +import net.fabricmc.fabric.api.gametest.v1.FabricGameTest; +import net.minecraft.test.GameTestException; +import net.minecraft.test.TestContext; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +public interface CardinalGameTest extends FabricGameTest { + @Override + default void invokeTestMethod(TestContext context, Method method) { + try { + this.setUp(); + if (method.getParameterCount() > 1) { + method.invoke(this, context); + } else { + method.invoke(this); + context.complete(); + } + this.tearDown(); + } catch (Throwable e) { + String message; + if (e instanceof InvocationTargetException) { + message = e.getMessage() + ": " + e.getCause().getMessage(); + e = e.getCause(); + } else { + message = e.getMessage(); + } + CardinalComponentsTest.LOGGER.error("Failed test", e); + throw new GameTestException(message); + } + } + + default void setUp() { + + } + + default void tearDown() { + + } +} diff --git a/src/test/java/dev/onyxstudios/cca/internal/base/asm/CcaBootstrapTest.java b/src/testmod/java/dev/onyxstudios/componenttest/tests/CcaTestSuite.java similarity index 76% rename from src/test/java/dev/onyxstudios/cca/internal/base/asm/CcaBootstrapTest.java rename to src/testmod/java/dev/onyxstudios/componenttest/tests/CcaTestSuite.java index c8e5e48b..f8a58979 100644 --- a/src/test/java/dev/onyxstudios/cca/internal/base/asm/CcaBootstrapTest.java +++ b/src/testmod/java/dev/onyxstudios/componenttest/tests/CcaTestSuite.java @@ -20,14 +20,15 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE * OR OTHER DEALINGS IN THE SOFTWARE. */ -package dev.onyxstudios.cca.internal.base.asm; +package dev.onyxstudios.componenttest.tests; -import net.minecraft.util.Identifier; +import net.fabricmc.fabric.api.gametest.v1.FabricGameTest; +import net.minecraft.test.GameTest; +import net.minecraft.test.TestContext; -import java.util.List; - -public class CcaBootstrapTest { - public static void addStaticComponentInitializers(Identifier... id) { - CcaBootstrap.INSTANCE.additionalComponentIds.addAll(List.of(id)); +public final class CcaTestSuite implements FabricGameTest { + @GameTest(structureName = EMPTY_STRUCTURE) + public void complete(TestContext context) { + context.complete(); } } diff --git a/src/testmod/java/dev/onyxstudios/componenttest/vita/package-info.java b/src/testmod/java/dev/onyxstudios/componenttest/vita/package-info.java deleted file mode 100644 index 7606232e..00000000 --- a/src/testmod/java/dev/onyxstudios/componenttest/vita/package-info.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Cardinal-Components-API - * Copyright (C) 2019-2021 OnyxStudios - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE - * OR OTHER DEALINGS IN THE SOFTWARE. - */ -@MethodsReturnNonnullByDefault -@ParametersAreNonnullByDefault -package dev.onyxstudios.componenttest.vita; - -import dev.onyxstudios.cca.api.v3.util.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/testmod/readme.md b/src/testmod/readme.md index 6946104a..8902c823 100644 --- a/src/testmod/readme.md +++ b/src/testmod/readme.md @@ -4,7 +4,7 @@ This test mod adds a new component type called Vita. Two entities can hold it: Vita Zombies and Players. Players do not naturally have vita, vita zombies are the only source. Hitting a vita holder with a -vita stick will transfer some of it to the stick. Subsequently right clicking the stick will transfer +vita stick will transfer some of it to the stick. Subsequently right-clicking the stick will transfer the collected vita to the player. Vita sticks also display the player's current (synchronized) vita in their tooltip. When shift-right-clicking a non-empty vita stick, a sliver of vita will be released in the world, and a title @@ -18,20 +18,22 @@ vita available in the chunk. ## Code map - `dev.onyxstudios.componenttest`: root package - - `vita`: component classes - - `Vita`: the interface defining the vita component - - `BaseVita`: base implementation - - `AmbientVita`: abstract synchronized extension of `BaseVita` with custom behaviour - - `LevelVita`: global implementation of `AmbientVita` - - `WorldVita`: world-aware implementation of `AmbientVita` - - `SyncedVita`: synchronized implementation of `BaseVita` - - `EntityVita`: entity-specific extension of `BaseVita` with custom behaviour - - `PlayerVita`: player-specific, synchronized extension of `EntityVita` with custom respawn behaviour - - `CardinalComponentsTest`: mod initialization - - `TestComponents`: component registration - - `VitalityCondenser`: a custom block re-implementing `BlockProvider`, interacting with chunk and ambient vita - - `VitalityStickItem`: a custom item that attaches a `BaseVita` instance to its item stacks - - `VitalityZombieEntity`: a custom entity that attaches an `EntityVita` instance to itself + - `content`: implementation of the content in the test mod + - `vita`: component classes + - `Vita`: the interface defining the vita component + - `BaseVita`: base implementation + - `AmbientVita`: abstract synchronized extension of `BaseVita` with custom behaviour + - `LevelVita`: global implementation of `AmbientVita` + - `WorldVita`: world-aware implementation of `AmbientVita` + - `SyncedVita`: synchronized implementation of `BaseVita` + - `EntityVita`: entity-specific extension of `BaseVita` with custom behaviour + - `PlayerVita`: player-specific, synchronized extension of `EntityVita` with custom respawn behaviour + - `CardinalComponentsTest`: mod initialization + - `TestComponents`: component registration + - `VitalityCondenser`: a custom block re-implementing `BlockProvider`, interacting with chunk and ambient vita + - `VitalityStickItem`: a custom item that attaches a `BaseVita` instance to its item stacks + - `VitalityZombieEntity`: a custom entity that attaches an `EntityVita` instance to itself + - `tests`: unit test suite using Minecraft's gametest API ## Notes diff --git a/src/testmod/resources/fabric.mod.json b/src/testmod/resources/fabric.mod.json index 27333355..6ee29b92 100644 --- a/src/testmod/resources/fabric.mod.json +++ b/src/testmod/resources/fabric.mod.json @@ -7,22 +7,30 @@ "version": "${version}", "entrypoints": { "main": [ - "dev.onyxstudios.componenttest.CardinalComponentsTest::init" + "dev.onyxstudios.componenttest.content.CardinalComponentsTest::init" ], "client": [ - "dev.onyxstudios.componenttest.CCATestClient::clientInit" + "dev.onyxstudios.componenttest.content.CCATestClient::clientInit" ], "cardinal-components:static-init": [ - "dev.onyxstudios.componenttest.TestStaticComponentInitializer" + "dev.onyxstudios.componenttest.content.TestStaticComponentInitializer" ], "cardinal-components": [ - "dev.onyxstudios.componenttest.TestComponents" + "dev.onyxstudios.componenttest.content.TestComponents" + ], + "fabric-gametest": [ + "dev.onyxstudios.componenttest.tests.CcaTestSuite", + "dev.onyxstudios.cca.internal.base.ComponentRegistryImplTest", + "dev.onyxstudios.cca.internal.base.QualifiedComponentFactoryTest" ] }, "custom": { "cardinal-components": [ "componenttest:vita", - "componenttest:vita_compound" + "componenttest:vita_compound", + "testmod:test", + "testmod:test_2", + "testmod:test_3" ] }, "depends": {