-
-
Notifications
You must be signed in to change notification settings - Fork 36
Support for packwiz-based modpacks #577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
jcotton42
wants to merge
5
commits into
itzg:master
Choose a base branch
from
jcotton42:pack-type-packwiz
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or 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
diff --git a/src/main/java/me/itzg/helpers/packwiz/InstallPackwizModpackCommand.java b/src/main/java/me/itzg/helpers/packwiz/InstallPackwizModpackCommand.java index 84d9a0d..032bd27 100644 --- a/src/main/java/me/itzg/helpers/packwiz/InstallPackwizModpackCommand.java +++ b/src/main/java/me/itzg/helpers/packwiz/InstallPackwizModpackCommand.java @@ -2,15 +2,21 @@ package me.itzg.helpers.packwiz; import com.fasterxml.jackson.dataformat.toml.TomlMapper; import lombok.extern.slf4j.Slf4j; +import me.itzg.helpers.errors.GenericException; import me.itzg.helpers.errors.InvalidParameterException; +import me.itzg.helpers.fabric.FabricLauncherInstaller; import me.itzg.helpers.files.Manifests; import me.itzg.helpers.files.ResultsFileWriter; +import me.itzg.helpers.forge.ForgeInstaller; +import me.itzg.helpers.forge.ForgeInstallerResolver; +import me.itzg.helpers.forge.NeoForgeInstallerResolver; import me.itzg.helpers.http.Fetch; import me.itzg.helpers.http.SharedFetch; import me.itzg.helpers.http.SharedFetchArgs; import me.itzg.helpers.modrinth.ModrinthModpackManifest; import me.itzg.helpers.packwiz.model.PackwizModLoader; import me.itzg.helpers.packwiz.model.PackwizPack; +import me.itzg.helpers.quilt.QuiltInstaller; import org.apache.commons.lang3.tuple.Pair; import picocli.CommandLine.ArgGroup; import picocli.CommandLine.Command; @@ -61,15 +67,19 @@ public final class InstallPackwizModpackCommand implements Callable<Integer> { return ExitCode.OK; } + final String minecraftVersion = newManifest.minecraftVersion(); + if (minecraftVersion == null) { + throw new GenericException("Minecraft version not set in packwiz pack"); + } + // TODO might need to set/save the Minecraft version somewhere + final Pair<PackwizModLoader, String> loaderInfo = getModLoader(newManifest); if (loaderInfo != null) { final PackwizModLoader loader = loaderInfo.getLeft(); final String version = loaderInfo.getRight(); - // TODO install modloader, see ModrinthPackInstaller::applyModLoader + installModLoader(fetch, loader, version, minecraftVersion); } - // might need to set the Minecraft version somewhere - final String minecraftVersion = newManifest.minecraftVersion(); // populate the results file // run packwiz bootstrap } @@ -80,6 +90,35 @@ public final class InstallPackwizModpackCommand implements Callable<Integer> { return ExitCode.OK; } + private void installModLoader(SharedFetch fetch, PackwizModLoader loader, String loaderVersion, String minecraftVersion) { + // TODO support forceReinstall parameters (the falses) + switch (loader) { + case NEOFORGE: + new ForgeInstaller(new NeoForgeInstallerResolver(fetch, minecraftVersion, loaderVersion)) + .install(outputDirectory, resultsFile, false, "NeoForge"); + break; + case FORGE: + new ForgeInstaller(new ForgeInstallerResolver(fetch, minecraftVersion, loaderVersion)) + .install(outputDirectory, resultsFile, false, "Forge"); + break; + case FABRIC: + new FabricLauncherInstaller(outputDirectory) + .setResultsFile(resultsFile) + .installUsingVersions(sharedFetchArgs.options(), minecraftVersion, loaderVersion, null); + break; + case QUILT: + try (QuiltInstaller installer = new QuiltInstaller( + QuiltInstaller.DEFAULT_REPO_URL, + sharedFetchArgs.options(), + outputDirectory, + minecraftVersion + ).setResultsFile(resultsFile)) { + installer.installWithVersion(null, loaderVersion); + } + break; + } + } + private Pair<PackwizModLoader, String> getModLoader(PackwizModpackManifest manifest) { // check NeoForge and Forge first, in case the pack is using Fabric mods on (Neo)Forge via Sinytra Connector or similar // (packwiz requires you to declare a fabric version in your pack.toml to add fabric mods to a (neo)forge-based pack)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Part of itzg/docker-minecraft-server#1818.
Still needs tests and fixing of TODOs, but opening this in draft as @ryleu expressed interest.