Skip to content

Commit

Permalink
Add NeoForge support
Browse files Browse the repository at this point in the history
  • Loading branch information
triphora committed Jul 23, 2023
1 parent 9fb247f commit e5d93d6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id 'com.gradle.plugin-publish' version '1.2.0'
}

version = '2.8.2'
version = '2.8.3'
group = 'com.modrinth.minotaur'
archivesBaseName = 'Minotaur'
description = 'Modrinth plugin for publishing builds to the website!'
Expand Down
29 changes: 14 additions & 15 deletions src/main/java/com/modrinth/minotaur/TaskModrinthUpload.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public void apply() {
if (ext.getLoaders().get().isEmpty() && ext.getDetectLoaders().get()) {
Map<String, String> pluginLoaderMap = new HashMap<>();
pluginLoaderMap.put("net.minecraftforge.gradle", "forge");
pluginLoaderMap.put("net.neoforged.gradle", "neoforge");
pluginLoaderMap.put("org.quiltmc.loom", "quilt");
pluginLoaderMap.put("org.spongepowered.gradle.plugin", "sponge");
pluginLoaderMap.put("io.papermc.paperweight.userdev", "paper");
Expand Down Expand Up @@ -139,34 +140,32 @@ && getProject().getExtensions().findByName("loom") != null) {

// Attempt to automatically resolve the game version if none were specified.
if (ext.getGameVersions().get().isEmpty()) {
if (ext.getLoaders().get().contains("forge") && pluginManager.hasPlugin("net.minecraftforge.gradle")) {
if (pluginManager.hasPlugin("net.minecraftforge.gradle") ||
pluginManager.hasPlugin("net.neoforged.gradle")) {
// ForgeGradle will store the game version here.
// https://github.com/MinecraftForge/ForgeGradle/blob/FG_5.0/src/userdev/java/net/minecraftforge/gradle/userdev/MinecraftUserRepo.java#L199
String version = (String) getProject().getExtensions().getExtraProperties().get("MC_VERSION");

if (version != null) {
getLogger().debug("Adding fallback game version {} from ForgeGradle.", version);
getLogger().debug("Adding fallback game version {} from ForgeGradle/NeoGradle.", version);
add(ext.getGameVersions(), version);
}
}

if (ext.getLoaders().get().contains("fabric") || ext.getLoaders().get().contains("quilt")
|| (ext.getLoaders().get().contains("forge") && !pluginManager.hasPlugin("net.minecraftforge.gradle"))) {
if (getProject().getExtensions().findByName("loom") != null) {
// Use the same method Loom uses to get the version.
// https://github.com/FabricMC/fabric-loom/blob/97f594da8e132c3d33cf39fe8d7cc0e76d84aeb6/src/main/java/net/fabricmc/loom/configuration/DependencyInfo.java#LL60C26-L60C56
String version = getProject().getConfigurations().getByName("minecraft")
.getDependencies().iterator().next().getVersion();
if (getProject().getExtensions().findByName("loom") != null) {
// Use the same method Loom uses to get the version.
// https://github.com/FabricMC/fabric-loom/blob/97f594da8e132c3d33cf39fe8d7cc0e76d84aeb6/src/main/java/net/fabricmc/loom/configuration/DependencyInfo.java#LL60C26-L60C56
String version = getProject().getConfigurations().getByName("minecraft")
.getDependencies().iterator().next().getVersion();

if (version != null) {
getLogger().debug("Adding fallback game version {} from Loom.", version);
add(ext.getGameVersions(), version);
}
if (version != null) {
getLogger().debug("Adding fallback game version {} from Loom.", version);
add(ext.getGameVersions(), version);
}
}

if (ext.getLoaders().get().contains("paper") && getProject().getExtensions().findByName("paperweight") != null) {
final String mcVer = getProject().getExtensions().getByType(PaperweightUserExtension.class).getMinecraftVersion().get();
if (getProject().getExtensions().findByName("paperweight") != null) {
String mcVer = getProject().getExtensions().getByType(PaperweightUserExtension.class).getMinecraftVersion().get();
getLogger().debug("Adding fallback game version {} from paperweight-userdev.", mcVer);
add(ext.getGameVersions(), mcVer);
}
Expand Down

0 comments on commit e5d93d6

Please sign in to comment.