From f6b68b0b43435afc77d2b4a1f5acc71c6619531f Mon Sep 17 00:00:00 2001 From: Samuel Walker Date: Thu, 31 Oct 2024 18:21:09 -0600 Subject: [PATCH] working on quilt --- fclauncher/InstanceManager.go | 58 ++++++++ fclauncher/frontend/src/Instances.svelte | 26 +++- .../wailsjs/go/main/InstanceManager.d.ts | 2 + .../wailsjs/go/main/InstanceManager.js | 4 + .../frontend/wailsjs/go/main/Quilt.d.ts | 5 + fclauncher/frontend/wailsjs/go/main/Quilt.js | 7 + fclauncher/frontend/wailsjs/go/models.ts | 139 ++++++++++++++++++ fclauncher/main.go | 1 + fclauncher/quilt.go | 111 ++++++++++++++ 9 files changed, 352 insertions(+), 1 deletion(-) create mode 100755 fclauncher/frontend/wailsjs/go/main/Quilt.d.ts create mode 100755 fclauncher/frontend/wailsjs/go/main/Quilt.js create mode 100644 fclauncher/quilt.go diff --git a/fclauncher/InstanceManager.go b/fclauncher/InstanceManager.go index eebd2c1..77f3bcd 100644 --- a/fclauncher/InstanceManager.go +++ b/fclauncher/InstanceManager.go @@ -354,3 +354,61 @@ func (i *InstanceManager)InstallFabric(instance string, fabricVersion string) { } } } + +func (i *InstanceManager)InstallQuilt(instance string, quiltVersion string) { + i.app.Status("Installing Quilt") + instanceObject, err := i.GetInstance(instance) + if err != nil { + fmt.Printf("Instance does not exist\n") + } + metadata, err := GetQuiltMetadata(instanceObject.MinecraftVersion, quiltVersion) + if err != nil { + fmt.Printf("unable to get version metadata\n") + } + client: + for _, lib := range metadata.LauncherMeta.Libraries.Client { + tokens := strings.Split(ProcessMavenPath(lib.Name), string(os.PathSeparator)) + pkg := tokens[len(tokens)-2] + instanceObject.Libraries = append(instanceObject.Libraries, filepath.Join(ProcessMavenPath(lib.Name), ProcessMavenFilename(lib.Name))) + for ind, path := range instanceObject.Libraries { + tokens := strings.Split(path, string(os.PathSeparator)) + if pkg == tokens[len(tokens)-3] { + instanceObject.Libraries[ind] = filepath.Join(ProcessMavenPath(lib.Name), ProcessMavenFilename(lib.Name)) + fmt.Printf("duplicate library %s\n", pkg) + continue client + } + } + } + common: + for _, lib := range metadata.LauncherMeta.Libraries.Common { + tokens := strings.Split(ProcessMavenPath(lib.Name), string(os.PathSeparator)) + pkg := tokens[len(tokens)-2] + instanceObject.Libraries = append(instanceObject.Libraries, filepath.Join(ProcessMavenPath(lib.Name), ProcessMavenFilename(lib.Name))) + for ind, path := range instanceObject.Libraries { + tokens := strings.Split(path, string(os.PathSeparator)) + if pkg == tokens[len(tokens)-3] { + instanceObject.Libraries[ind] = filepath.Join(ProcessMavenPath(lib.Name), ProcessMavenFilename(lib.Name)) + fmt.Printf("duplicate library %s\n", pkg) + continue common + } + } + } + instanceObject.Libraries = append(instanceObject.Libraries, filepath.Join(ProcessMavenPath(metadata.Loader.Maven), ProcessMavenFilename(metadata.Loader.Maven))) + + instanceObject.Libraries = append(instanceObject.Libraries, filepath.Join(ProcessMavenPath(metadata.Intermediary.Maven), ProcessMavenFilename(metadata.Intermediary.Maven))) + + instanceObject.MainClass = metadata.LauncherMeta.MainClass["client"] + instanceObject.QuiltVersion = quiltVersion + dir, _ := os.UserConfigDir() + InstallQuiltLibs(instanceObject.MinecraftVersion, quiltVersion, filepath.Join(dir, "FCLauncher", "lib")) + f, _ := os.OpenFile(filepath.Join(dir, "FCLauncher", "instances", instance, "instance.json"), os.O_CREATE|os.O_RDWR, 0755) + data, _ := json.Marshal(instanceObject) + defer f.Close() + f.Write(data) + for ind, inst := range i.instances { + if inst.InstanceName == instance { + i.instances[ind] = instanceObject + break + } + } +} diff --git a/fclauncher/frontend/src/Instances.svelte b/fclauncher/frontend/src/Instances.svelte index 12043b6..25f9f0a 100644 --- a/fclauncher/frontend/src/Instances.svelte +++ b/fclauncher/frontend/src/Instances.svelte @@ -1,7 +1,8 @@