-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Matyrobbrt <[email protected]> Co-authored-by: Technici4n <[email protected]>
- Loading branch information
1 parent
19ebb9f
commit a1b3bfd
Showing
37 changed files
with
2,147 additions
and
1,091 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
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 |
---|---|---|
|
@@ -12,8 +12,8 @@ java { | |
} | ||
} | ||
|
||
neoForge { | ||
neoFormVersion = '1.19.2' | ||
legacyForge { | ||
mcpVersion = '1.19.2' | ||
} | ||
|
||
publishing { | ||
|
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
61 changes: 61 additions & 0 deletions
61
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,61 @@ | ||
package net.neoforged.moddevgradle.legacyforge.dsl; | ||
|
||
import net.neoforged.moddevgradle.dsl.DataFileCollection; | ||
import net.neoforged.moddevgradle.dsl.ModDevExtension; | ||
import net.neoforged.moddevgradle.legacyforge.internal.LegacyForgeModDevPlugin; | ||
import org.gradle.api.Action; | ||
import org.gradle.api.Project; | ||
|
||
import javax.inject.Inject; | ||
|
||
/** | ||
* This is the top-level {@code legacyForge} extension, used to configure the moddev plugin. | ||
*/ | ||
public abstract class LegacyForgeExtension extends ModDevExtension { | ||
private final Project project; | ||
|
||
@Inject | ||
public LegacyForgeExtension(Project project, | ||
DataFileCollection accessTransformers, | ||
DataFileCollection interfaceInjectionData) { | ||
super(project, accessTransformers, interfaceInjectionData); | ||
this.project = project; | ||
} | ||
|
||
/** | ||
* Enables modding for the main source-set using the given Forge version. | ||
* <p> | ||
* Shorthand for: | ||
* <code> | ||
* enable { forgeVersion = '...' } | ||
* </code> | ||
*/ | ||
public void setVersion(String version) { | ||
enable(settings -> { | ||
settings.setForgeVersion(version); | ||
}); | ||
} | ||
|
||
/** | ||
* Enables modding for the main source-set in Vanilla-mode. | ||
* <p> | ||
* Shorthand for: | ||
* <code> | ||
* enable { mcpVersion = '...' } | ||
* </code> | ||
*/ | ||
public void setMcpVersion(String version) { | ||
enable(settings -> { | ||
settings.setMcpVersion(version); | ||
}); | ||
} | ||
|
||
public void enable(Action<LegacyForgeModdingSettings> customizer) { | ||
var plugin = project.getPlugins().getPlugin(LegacyForgeModDevPlugin.class); | ||
|
||
var settings = project.getObjects().newInstance(LegacyForgeModdingSettings.class); | ||
customizer.execute(settings); | ||
|
||
plugin.enable(project, settings, this); | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
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,84 @@ | ||
package net.neoforged.moddevgradle.legacyforge.dsl; | ||
|
||
import net.neoforged.moddevgradle.internal.utils.ExtensionUtils; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.tasks.SourceSet; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import javax.inject.Inject; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public abstract class LegacyForgeModdingSettings { | ||
@Nullable | ||
private String neoForgeVersion; | ||
|
||
@Nullable | ||
private String forgeVersion; | ||
|
||
@Nullable | ||
private String mcpVersion; | ||
|
||
private Set<SourceSet> enabledSourceSets = new HashSet<>(); | ||
|
||
@Inject | ||
public LegacyForgeModdingSettings(Project project) { | ||
// By default, enable modding deps only for the main source set | ||
var sourceSets = ExtensionUtils.getSourceSets(project); | ||
var mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME); | ||
enabledSourceSets.add(mainSourceSet); | ||
} | ||
|
||
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. | ||
*/ | ||
|
||
/** | ||
* 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 Set<SourceSet> getEnabledSourceSets() { | ||
return enabledSourceSets; | ||
} | ||
|
||
public void setEnabledSourceSets(Set<SourceSet> enabledSourceSets) { | ||
this.enabledSourceSets = enabledSourceSets; | ||
} | ||
} |
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.