-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
1,632 additions
and
1,072 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/LegacyForgeExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package net.neoforged.moddevgradle.legacyforge.dsl; | ||
|
||
import net.neoforged.moddevgradle.dsl.DataFileCollection; | ||
import net.neoforged.moddevgradle.internal.ModDevExtension; | ||
import net.neoforged.moddevgradle.internal.utils.ExtensionUtils; | ||
import net.neoforged.moddevgradle.legacyforge.internal.LegacyForgeModDevPlugin; | ||
import org.gradle.api.Action; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.tasks.SourceSet; | ||
|
||
import javax.inject.Inject; | ||
import java.util.List; | ||
|
||
/** | ||
* This is the top-level {@code legacyForge} extension, used to configure the moddev plugin. | ||
*/ | ||
public abstract class LegacyForgeExtension extends ModDevExtension { | ||
private final Project project; | ||
|
||
private final Obfuscation obfuscation; | ||
|
||
@Inject | ||
public LegacyForgeExtension(Project project, | ||
DataFileCollection accessTransformers, | ||
DataFileCollection interfaceInjectionData, | ||
Obfuscation obfuscation) { | ||
super(project, accessTransformers, interfaceInjectionData); | ||
this.project = project; | ||
this.obfuscation = obfuscation; | ||
} | ||
|
||
public void setVersion(String version) { | ||
enableModding(settings -> { | ||
settings.setForgeVersion(version); | ||
}); | ||
} | ||
|
||
public void enableModding(Action<LegacyForgeModdingSettings> customizer) { | ||
var plugin = project.getPlugins().getPlugin(LegacyForgeModDevPlugin.class); | ||
|
||
var settings = project.getObjects().newInstance(LegacyForgeModdingSettings.class); | ||
// By default, enable modding deps only for the main source set | ||
settings.getEnabledSourceSets().convention(project.provider(() -> { | ||
var sourceSets = ExtensionUtils.getSourceSets(project); | ||
return List.of(sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME)); | ||
})); | ||
customizer.execute(settings); | ||
|
||
plugin.enableModding(project, settings, this); | ||
} | ||
|
||
public Obfuscation getObfuscation() { | ||
return obfuscation; | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/LegacyForgeModdingSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package net.neoforged.moddevgradle.legacyforge.dsl; | ||
|
||
import org.gradle.api.provider.ListProperty; | ||
import org.gradle.api.tasks.SourceSet; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public abstract class LegacyForgeModdingSettings { | ||
@Nullable | ||
private String neoForgeVersion; | ||
|
||
private String forgeVersion; | ||
|
||
@Nullable | ||
private String mcpVersion; | ||
|
||
public @Nullable String getNeoForgeVersion() { | ||
return neoForgeVersion; | ||
} | ||
|
||
public @Nullable String getForgeVersion() { | ||
return forgeVersion; | ||
} | ||
|
||
public @Nullable String getMcpVersion() { | ||
return mcpVersion; | ||
} | ||
|
||
/** | ||
* NeoForge version number. You have to set either this, {@link #setForgeVersion} or {@link #setMcpVersion}. | ||
* Only NeoForge for Minecraft 1.20.1 is supported when using this plugin. | ||
*/ | ||
public void setNeoForgeVersion(String version) { | ||
this.neoForgeVersion = version; | ||
} | ||
|
||
/** | ||
* Minecraft Forge version. You have to set either this, {@link #setNeoForgeVersion} or {@link #setMcpVersion}. | ||
*/ | ||
public void setForgeVersion(String version) { | ||
this.forgeVersion = version; | ||
} | ||
|
||
/** | ||
* You can set this property to a version of <a href="https://maven.neoforged.net/#/releases/de/oceanlabs/mcp/mcp">MCP</a> | ||
* to either override the version used in the version of Forge you set, or to compile against | ||
* Vanilla artifacts that have no Forge code added. | ||
*/ | ||
public void setMcpVersion(String version) { | ||
this.mcpVersion = version; | ||
} | ||
|
||
/** | ||
* Contains the list of source sets for which access to Minecraft classes should be configured. | ||
* Defaults to the main source set, but can also be set to an empty list. | ||
*/ | ||
public abstract ListProperty<SourceSet> getEnabledSourceSets(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.