From f5ea374e402abb6524e196d3c18d4ab368599c98 Mon Sep 17 00:00:00 2001 From: RedNesto Date: Sat, 5 Oct 2024 13:18:05 +0200 Subject: [PATCH] Fix #2385 Support ModDevGradle Vanilla-Mode --- changelog.md | 1 + .../NeoModDevGradleModelBuilderImpl.groovy | 8 +++----- .../neomoddev/NeoModDevGradleModelImpl.groovy | 16 +++------------- .../platform/mcp/gradle/tooling/McpModelNMD.java | 5 ++++- .../mcp/gradle/datahandler/McpModelNMDHandler.kt | 8 +++++++- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/changelog.md b/changelog.md index 9e603ff54..00be33178 100644 --- a/changelog.md +++ b/changelog.md @@ -13,6 +13,7 @@ - Mixin injection signature fix preview - Loom 1.8 support - K2 mode compatibility +- [#2385](https://github.com/minecraft-dev/MinecraftDev/issues/2385) ModDevGradle Vanilla-Mode support ### Changed diff --git a/src/gradle-tooling-extension/groovy/com/demonwav/mcdev/platform/mcp/gradle/tooling/neomoddev/NeoModDevGradleModelBuilderImpl.groovy b/src/gradle-tooling-extension/groovy/com/demonwav/mcdev/platform/mcp/gradle/tooling/neomoddev/NeoModDevGradleModelBuilderImpl.groovy index 46dc6669a..c9631e26c 100644 --- a/src/gradle-tooling-extension/groovy/com/demonwav/mcdev/platform/mcp/gradle/tooling/neomoddev/NeoModDevGradleModelBuilderImpl.groovy +++ b/src/gradle-tooling-extension/groovy/com/demonwav/mcdev/platform/mcp/gradle/tooling/neomoddev/NeoModDevGradleModelBuilderImpl.groovy @@ -47,10 +47,8 @@ final class NeoModDevGradleModelBuilderImpl implements ModelBuilderService { return null } - def neoforgeVersion = extension.version.get() - if (neoforgeVersion == null) { - return null - } + def neoforgeVersion = extension.version.getOrNull() + def neoFormVersion = extension.neoFormVersion.getOrNull() def accessTransformersRaw = extension.accessTransformers List accessTransformers @@ -74,7 +72,7 @@ final class NeoModDevGradleModelBuilderImpl implements ModelBuilderService { } //noinspection GroovyAssignabilityCheck - return new NeoModDevGradleModelImpl(neoforgeVersion, mappingsFile, accessTransformers) + return new NeoModDevGradleModelImpl(neoforgeVersion, neoFormVersion, mappingsFile, accessTransformers) } @Override diff --git a/src/gradle-tooling-extension/groovy/com/demonwav/mcdev/platform/mcp/gradle/tooling/neomoddev/NeoModDevGradleModelImpl.groovy b/src/gradle-tooling-extension/groovy/com/demonwav/mcdev/platform/mcp/gradle/tooling/neomoddev/NeoModDevGradleModelImpl.groovy index 5640af6fd..27770b087 100644 --- a/src/gradle-tooling-extension/groovy/com/demonwav/mcdev/platform/mcp/gradle/tooling/neomoddev/NeoModDevGradleModelImpl.groovy +++ b/src/gradle-tooling-extension/groovy/com/demonwav/mcdev/platform/mcp/gradle/tooling/neomoddev/NeoModDevGradleModelImpl.groovy @@ -20,24 +20,14 @@ package com.demonwav.mcdev.platform.mcp.gradle.tooling.neomoddev - import com.demonwav.mcdev.platform.mcp.gradle.tooling.McpModelNMD -import groovy.transform.CompileStatic +import groovy.transform.Immutable -@CompileStatic +@Immutable(knownImmutableClasses = [File]) final class NeoModDevGradleModelImpl implements McpModelNMD, Serializable { final String neoForgeVersion + final String neoFormVersion final File mappingsFile final List accessTransformers - - NeoModDevGradleModelImpl( - final String neoForgeVersion, - final File mappingsFile, - final List accessTransformers - ) { - this.neoForgeVersion = neoForgeVersion - this.mappingsFile = mappingsFile - this.accessTransformers = accessTransformers - } } diff --git a/src/gradle-tooling-extension/java/com/demonwav/mcdev/platform/mcp/gradle/tooling/McpModelNMD.java b/src/gradle-tooling-extension/java/com/demonwav/mcdev/platform/mcp/gradle/tooling/McpModelNMD.java index beff8af28..5eab5ba70 100644 --- a/src/gradle-tooling-extension/java/com/demonwav/mcdev/platform/mcp/gradle/tooling/McpModelNMD.java +++ b/src/gradle-tooling-extension/java/com/demonwav/mcdev/platform/mcp/gradle/tooling/McpModelNMD.java @@ -20,11 +20,14 @@ package com.demonwav.mcdev.platform.mcp.gradle.tooling; +import org.jetbrains.annotations.Nullable; + import java.io.File; import java.util.List; public interface McpModelNMD { - String getNeoForgeVersion(); + @Nullable String getNeoForgeVersion(); + @Nullable String getNeoFormVersion(); File getMappingsFile(); List getAccessTransformers(); } diff --git a/src/main/kotlin/platform/mcp/gradle/datahandler/McpModelNMDHandler.kt b/src/main/kotlin/platform/mcp/gradle/datahandler/McpModelNMDHandler.kt index 37e655c67..2275aeb91 100644 --- a/src/main/kotlin/platform/mcp/gradle/datahandler/McpModelNMDHandler.kt +++ b/src/main/kotlin/platform/mcp/gradle/datahandler/McpModelNMDHandler.kt @@ -44,8 +44,14 @@ object McpModelNMDHandler : McpModelDataHandler { ) { val data = resolverCtx.getExtraProject(gradleModule, McpModelNMD::class.java) ?: return + val minecraftVersion = when { + data.neoForgeVersion != null -> "1." + data.neoForgeVersion!!.substringBeforeLast('.').removeSuffix(".0") + data.neoFormVersion != null -> data.neoFormVersion!!.substringBeforeLast('-').removeSuffix(".0") + else -> null + } + val state = McpModuleSettings.State( - "1." + data.neoForgeVersion.substringBeforeLast('.').removeSuffix(".0"), + minecraftVersion, null, data.mappingsFile?.absolutePath, SrgType.TSRG,