From 5fa3de49f7de0f5a69a42959d72fec678b9b6ec4 Mon Sep 17 00:00:00 2001 From: Aram Date: Mon, 9 Dec 2024 15:06:00 +0100 Subject: [PATCH] Setup a NeoForge Test --- .../src/main/java/software/bluelib/BlueLib.java | 4 ++++ .../java/software/bluelib/test/ExampleTest.java | 15 +++++++++++++++ .../java/software/bluelib/test/TestRegistry.java | 10 ++++++++++ 3 files changed, 29 insertions(+) create mode 100644 neoforge/src/main/java/software/bluelib/test/ExampleTest.java create mode 100644 neoforge/src/main/java/software/bluelib/test/TestRegistry.java diff --git a/neoforge/src/main/java/software/bluelib/BlueLib.java b/neoforge/src/main/java/software/bluelib/BlueLib.java index 62a21ca0..e5c55713 100644 --- a/neoforge/src/main/java/software/bluelib/BlueLib.java +++ b/neoforge/src/main/java/software/bluelib/BlueLib.java @@ -8,6 +8,7 @@ import net.neoforged.fml.common.Mod; import net.neoforged.fml.event.lifecycle.FMLLoadCompleteEvent; import org.spongepowered.asm.launch.MixinBootstrap; +import software.bluelib.test.TestRegistry; /** * The main class of the {@code BlueLib} mod. @@ -44,6 +45,9 @@ public class BlueLib { */ public BlueLib(IEventBus pModEventBus, ModContainer pModContainer) { pModEventBus.register(this); + if (BlueLibCommon.isDeveloperMode()) { + TestRegistry.register(); + } MixinBootstrap.init(); } diff --git a/neoforge/src/main/java/software/bluelib/test/ExampleTest.java b/neoforge/src/main/java/software/bluelib/test/ExampleTest.java new file mode 100644 index 00000000..60409a6d --- /dev/null +++ b/neoforge/src/main/java/software/bluelib/test/ExampleTest.java @@ -0,0 +1,15 @@ +package software.bluelib.test; + +import net.minecraft.gametest.framework.GameTest; +import net.minecraft.gametest.framework.GameTestHelper; +import net.neoforged.neoforge.gametest.GameTestHolder; +import software.bluelib.BlueLibConstants; + +@GameTestHolder +public class ExampleTest { + + @GameTest(templateNamespace = BlueLibConstants.MOD_ID) + public void alwaysSucceed(GameTestHelper pHelper) { + pHelper.succeed(); + } +} diff --git a/neoforge/src/main/java/software/bluelib/test/TestRegistry.java b/neoforge/src/main/java/software/bluelib/test/TestRegistry.java new file mode 100644 index 00000000..119d3a94 --- /dev/null +++ b/neoforge/src/main/java/software/bluelib/test/TestRegistry.java @@ -0,0 +1,10 @@ +package software.bluelib.test; + +import net.neoforged.neoforge.gametest.GameTestHooks; + +public class TestRegistry { + + public static void register() { + GameTestHooks.registerGametests(); + } +}