Manually replace FLK deps with QKL when using Quilt >=1.19.2 (fixes #212)

This commit is contained in:
comp500
2023-04-13 17:12:44 +01:00
parent bd71ad5679
commit e966eaffc0
4 changed files with 31 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"github.com/spf13/viper"
"github.com/unascribed/FlexVer/go/flexver"
"golang.org/x/exp/slices"
"io"
"path/filepath"
@@ -590,10 +591,17 @@ func (m *cfDownloadMetadata) DownloadFile() (io.ReadCloser, error) {
return resp.Body, nil
}
func mapDepOverride(depID uint32, isQuilt bool) uint32 {
// mapDepOverride transforms manual dependency overrides (which will likely be removed when packwiz is able to determine provided mods)
func mapDepOverride(depID uint32, isQuilt bool, mcVersion string) uint32 {
if isQuilt && depID == 306612 {
// Transform FAPI dependencies to QFAPI/QSL dependencies when using Quilt
return 634179
}
if isQuilt && depID == 308769 {
// Transform FLK dependencies to QKL dependencies when using Quilt >=1.19.2 non-snapshot
if flexver.Less("1.19.1", mcVersion) && flexver.Less(mcVersion, "2.0.0") {
return 720410
}
}
return depID
}

View File

@@ -44,6 +44,11 @@ var installCmd = &cobra.Command{
fmt.Println(err)
os.Exit(1)
}
primaryMCVersion, err := pack.GetMCVersion()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
game := gameFlag
category := categoryFlag
@@ -128,7 +133,7 @@ var installCmd = &cobra.Command{
var depIDPendingQueue []uint32
for _, dep := range fileInfoData.Dependencies {
if dep.Type == dependencyTypeRequired {
depIDPendingQueue = append(depIDPendingQueue, mapDepOverride(dep.ModID, isQuilt))
depIDPendingQueue = append(depIDPendingQueue, mapDepOverride(dep.ModID, isQuilt, primaryMCVersion))
}
}
@@ -192,7 +197,7 @@ var installCmd = &cobra.Command{
for _, dep := range depFileInfo.Dependencies {
if dep.Type == dependencyTypeRequired {
depIDPendingQueue = append(depIDPendingQueue, mapDepOverride(dep.ModID, isQuilt))
depIDPendingQueue = append(depIDPendingQueue, mapDepOverride(dep.ModID, isQuilt, primaryMCVersion))
}
}