Skip to content

Commit

Permalink
Fix #2385 Support ModDevGradle Vanilla-Mode
Browse files Browse the repository at this point in the history
  • Loading branch information
RedNesto committed Oct 5, 2024
1 parent e97dfd5 commit f5ea374
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 20 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<File> accessTransformers
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<File> accessTransformers

NeoModDevGradleModelImpl(
final String neoForgeVersion,
final File mappingsFile,
final List<File> accessTransformers
) {
this.neoForgeVersion = neoForgeVersion
this.mappingsFile = mappingsFile
this.accessTransformers = accessTransformers
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<File> getAccessTransformers();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f5ea374

Please sign in to comment.