From e21e15ee41f256c65e1b283d894b020be6b1593b Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Mon, 25 Nov 2024 14:11:42 +0000 Subject: [PATCH] More mdg-related stuff (broken ATM) --- build.gradle | 135 ++++++++++-------- gradle.properties | 6 +- settings.gradle | 2 +- .../item/module/adapter/IItemAdapter.java | 1 - .../test/ModularRoutersTest.java | 1 - .../desht/modularrouters/test/RouterTest.java | 10 +- 6 files changed, 88 insertions(+), 67 deletions(-) diff --git a/build.gradle b/build.gradle index 8a7d89a0..3985a369 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { id 'eclipse' id 'idea' id 'maven-publish' - id 'net.neoforged.gradle.userdev' version '7.0.165' + id 'net.neoforged.moddev' version '2.0.47-beta' id "me.modmuss50.mod-publish-plugin" version "0.5.1" } @@ -14,15 +14,10 @@ ext.isAlpha = ext.releaseTag.contains("alpha") ext.isBeta = ext.releaseTag.contains("beta") def relType = ext.isAlpha ? "alpha" : (ext.isBeta ? "beta" : "release") -// All jar files from this folder will be added automatically as runtime-only mod dependencies -def extraModsDir = "extra-mods-${minecraft_version}" +version = mod_version repositories { mavenLocal() - flatDir { - name "extra-mods" - dir file(extraModsDir) - } maven { name "K-4u Mod maven" url "https://modmaven.dev/" @@ -54,11 +49,7 @@ repositories { } sourceSets { - test { - runs { - modIdentifier 'modularrouterstest' - } - } + test } group = project.mod_group_id @@ -77,62 +68,86 @@ java { } } -minecraft { - accessTransformers.file(project.file('src/main/resources/META-INF/accesstransformer.cfg')) -} +neoForge { + version = "${neo_version}" -runs { - // applies to all the run configs below - configureEach { - // Recommended logging data for a userdev environment - // The markers can be added/remove as needed separated by commas. - // "SCAN": For mods scan. - // "REGISTRIES": For firing of registry events. - // "REGISTRYDUMP": For getting the contents of all registries. - systemProperty 'forge.logging.markers', 'REGISTRIES' - - // Recommended logging level for the console - // You can set various levels here. - // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels - systemProperty 'forge.logging.console.level', 'debug' - - jvmArguments.addAll '-Xmx4G' - - modSource project.sourceSets.test - modSource project.sourceSets.main + parchment { + mappingsVersion = project.parchment_mappings_version + minecraftVersion = project.parchment_minecraft_version } - client { - systemProperty 'neoforge.enableGameTest', 'true' - // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. - systemProperty 'forge.enabledGameTestNamespaces', project.mod_id - } + addModdingDependenciesTo(sourceSets.test) - server { - systemProperty 'forge.enabledGameTestNamespaces', project.mod_id - argument '--nogui' - } + validateAccessTransformers = true + + runs { + // applies to all the run configs below + configureEach { + // Recommended logging data for a userdev environment + // The markers can be added/remove as needed separated by commas. + // "SCAN": For mods scan. + // "REGISTRIES": For firing of registry events. + // "REGISTRYDUMP": For getting the contents of all registries. + systemProperty 'forge.logging.markers', 'REGISTRIES' + + // Recommended logging level for the console + // You can set various levels here. + // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels + systemProperty 'forge.logging.console.level', 'debug' + + jvmArguments.addAll '-Xmx4G' + } + + client { + client() + systemProperty 'neoforge.enableGameTest', 'true' + // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id + loadedMods = [mods.modularrouters, mods.modularrouterstest] + } + + server { + server() + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id + programArgument '--nogui' + } - // This run config launches GameTestServer and runs all registered gametests, then exits. - // By default, the server will crash when no gametests are provided. - // The gametest system is also enabled by default for other run configs under the /test command. - gameTestServer { - systemProperty 'forge.enabledGameTestNamespaces', project.mod_id + // This run config launches GameTestServer and runs all registered gametests, then exits. + // By default, the server will crash when no gametests are provided. + // The gametest system is also enabled by default for other run configs under the /test command. + gameTestServer { + type = "gameTestServer" + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id + } + + data { + data() + // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. + programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() + } } - data { - // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. - arguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() + mods { + "${mod_id}" { + sourceSet sourceSets.main + sourceSet sourceSets.test + } } } // Include resources generated by data generators. sourceSets.main.resources { srcDir 'src/generated/resources' } +configurations { + runtimeClasspath.extendsFrom localRuntime +} + dependencies { - implementation "net.neoforged:neoforge:${neo_version}" +// implementation "net.neoforged:neoforge:${neo_version}" localRuntime(testImplementation("net.neoforged:testframework:${neo_version}")) +// implementation sourceSets.test.output + compileOnly("mcjty.theoneprobe:theoneprobe:${top_version}") { transitive = false } @@ -150,14 +165,14 @@ dependencies { // runtimeOnly "mezz.jei:jei-${minecraft_version}-neoforge:${jei_version}" // Locally sourced extra mods for runtime (i.e. testing) - thanks AE2 for this idea - for (extraModJar in fileTree(dir: extraModsDir, include: '*.jar')) { - def basename = extraModJar.name.substring(0, extraModJar.name.length() - ".jar".length()) - def versionSep = basename.lastIndexOf('-') - assert versionSep != -1 - def artifactId = basename.substring(0, versionSep) - def version = basename.substring(versionSep + 1) - runtimeOnly "extra-mods:$artifactId:$version" - } +// for (extraModJar in fileTree(dir: extraModsDir, include: '*.jar')) { +// def basename = extraModJar.name.substring(0, extraModJar.name.length() - ".jar".length()) +// def versionSep = basename.lastIndexOf('-') +// assert versionSep != -1 +// def artifactId = basename.substring(0, versionSep) +// def version = basename.substring(versionSep + 1) +// runtimeOnly "extra-mods:$artifactId:$version" +// } } tasks.withType(ProcessResources).configureEach { diff --git a/gradle.properties b/gradle.properties index d049bc11..24d9f114 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,12 +18,12 @@ curse_project_id=250294 # Minecraft/Forge minecraft_version=1.21.3 minecraft_version_range=[1.21.3,) -neo_version=21.3.34-beta +neo_version=21.3.40-beta neo_version_range=[21.3.0,) loader_version_range=[4,) pack_format_number=18 -neogradle.subsystems.parchment.minecraftVersion=1.21 -neogradle.subsystems.parchment.mappingsVersion=2024.07.28 +parchment_minecraft_version=1.21.1 +parchment_mappings_version=2024.11.17 # Dependencies top_version=1.21_neo-12.0.3-5 diff --git a/settings.gradle b/settings.gradle index accdc4a1..203448c1 100644 --- a/settings.gradle +++ b/settings.gradle @@ -10,7 +10,7 @@ pluginManagement { } plugins { - id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0' + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0' } rootProject.name = 'modular-routers' diff --git a/src/main/java/me/desht/modularrouters/item/module/adapter/IItemAdapter.java b/src/main/java/me/desht/modularrouters/item/module/adapter/IItemAdapter.java index a8281333..8c0d99c5 100644 --- a/src/main/java/me/desht/modularrouters/item/module/adapter/IItemAdapter.java +++ b/src/main/java/me/desht/modularrouters/item/module/adapter/IItemAdapter.java @@ -4,7 +4,6 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.context.UseOnContext; diff --git a/src/test/java/me/desht/modularrouters/test/ModularRoutersTest.java b/src/test/java/me/desht/modularrouters/test/ModularRoutersTest.java index 182e2e7b..79712836 100644 --- a/src/test/java/me/desht/modularrouters/test/ModularRoutersTest.java +++ b/src/test/java/me/desht/modularrouters/test/ModularRoutersTest.java @@ -8,7 +8,6 @@ import net.neoforged.testframework.conf.ClientConfiguration; import net.neoforged.testframework.conf.Feature; import net.neoforged.testframework.conf.FrameworkConfiguration; -import net.neoforged.testframework.conf.MissingDescriptionAction; import net.neoforged.testframework.impl.MutableTestFramework; import net.neoforged.testframework.summary.GitHubActionsStepSummaryDumper; import org.lwjgl.glfw.GLFW; diff --git a/src/test/java/me/desht/modularrouters/test/RouterTest.java b/src/test/java/me/desht/modularrouters/test/RouterTest.java index 0ba8ed30..14067412 100644 --- a/src/test/java/me/desht/modularrouters/test/RouterTest.java +++ b/src/test/java/me/desht/modularrouters/test/RouterTest.java @@ -6,7 +6,11 @@ import me.desht.modularrouters.core.ModItems; import me.desht.modularrouters.item.module.ModuleItem; import me.desht.modularrouters.logic.compiled.CompiledModule; +import net.minecraft.core.registries.Registries; import net.minecraft.gametest.framework.GameTest; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.neoforged.neoforge.attachment.AttachmentType; import net.neoforged.neoforge.registries.NeoForgeRegistries; @@ -17,6 +21,10 @@ import org.jetbrains.annotations.NotNull; public class RouterTest { + private static final ResourceKey TEST_ID = ResourceKey.create(Registries.ITEM, ResourceLocation.parse("modularrouterstest:testmodule")); + + private static final Item.Properties TEST_PROPS = new Item.Properties().setId(TEST_ID); + @GameTest @TestHolder @EmptyTemplate @@ -25,7 +33,7 @@ static void testRouterSpeed(DynamicTest test, RegistrationHelper reg) { .register("counter", () -> AttachmentType.builder(() -> 0) .serialize(Codec.INT).build()); - var module = reg.items().register("test_module", () -> new ModuleItem(ModItems.moduleProps(), (r, s) -> new CompiledModule(r, s) { + var module = reg.items().register("test_module", () -> new ModuleItem(TEST_PROPS, (r, s) -> new CompiledModule(r, s) { @Override public boolean execute(@NotNull ModularRouterBlockEntity router) { router.setData(counter, router.getData(counter.get()) + 1);