Able to install correct version of minecraft + loader from mrpack
This commit is contained in:
parent
ad84711646
commit
f905d617a8
@ -14,8 +14,27 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
wruntime "github.com/wailsapp/wails/v2/pkg/runtime"
|
wruntime "github.com/wailsapp/wails/v2/pkg/runtime"
|
||||||
|
"github.com/zhyee/zipstream"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type MrData struct {
|
||||||
|
FormatVersion int
|
||||||
|
Game string
|
||||||
|
VersionId string
|
||||||
|
Name string
|
||||||
|
Summary string
|
||||||
|
Files []MrFile
|
||||||
|
Dependencies map[string]string
|
||||||
|
}
|
||||||
|
|
||||||
|
type MrFile struct {
|
||||||
|
Path string
|
||||||
|
Hashes map[string]string
|
||||||
|
Env map[string]string
|
||||||
|
Downloads []string
|
||||||
|
FileSize int
|
||||||
|
}
|
||||||
|
|
||||||
type Instance struct {
|
type Instance struct {
|
||||||
InstanceName string
|
InstanceName string
|
||||||
ModpackId string
|
ModpackId string
|
||||||
@ -460,3 +479,42 @@ outer:
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (i *InstanceManager) ImportModpack(modpack Modpack, name string) {
|
||||||
|
buff := new(bytes.Buffer)
|
||||||
|
HttpDownload(filepath.Join(modpack.Id, modpack.Versions[len(modpack.Versions)-1].File), buff, i.app.Ctx)
|
||||||
|
i.ImportMrpack(buff, name)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *InstanceManager) ImportMrpack(data io.Reader, name string) {
|
||||||
|
zr := zipstream.NewReader(data)
|
||||||
|
mrdata := MrData{}
|
||||||
|
for {
|
||||||
|
entry, err := zr.GetNextEntry()
|
||||||
|
if err == io.EOF {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if entry.Name == "modrinth.index.json" {
|
||||||
|
file, _ := entry.Open()
|
||||||
|
data, _ := io.ReadAll(file)
|
||||||
|
json.Unmarshal(data, &mrdata)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fmt.Printf("Installing minecraft %s\n", mrdata.Dependencies["minecraft"])
|
||||||
|
i.InstallVanilla(mrdata.Dependencies["minecraft"], name)
|
||||||
|
if mrdata.Dependencies["forge"] != "" {
|
||||||
|
fmt.Printf("Forge not implemented!")
|
||||||
|
//implement forge
|
||||||
|
} else if mrdata.Dependencies["neoforge"] != "" {
|
||||||
|
fmt.Printf("Neoforge not implemented!")
|
||||||
|
//implement neoforge
|
||||||
|
} else if mrdata.Dependencies["fabric-loader"] != "" {
|
||||||
|
fmt.Printf("Installing fabric %s\n", mrdata.Dependencies["fabric-loader"])
|
||||||
|
i.InstallFabric(name, mrdata.Dependencies["fabric-loader"])
|
||||||
|
} else if mrdata.Dependencies["quilt-loader"] != "" {
|
||||||
|
fmt.Printf("Installing quilt %s\n", mrdata.Dependencies["quilt-loader"])
|
||||||
|
i.InstallQuilt(name, mrdata.Dependencies["quilt-loader"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
import Instancepage from './Instancepage.svelte'
|
import Instancepage from './Instancepage.svelte'
|
||||||
import { set_attributes, set_style } from 'svelte/internal';
|
import { set_attributes, set_style } from 'svelte/internal';
|
||||||
|
|
||||||
let width: int = 10
|
let width: number = 10
|
||||||
let navMargin = document.getElementById("body") as HTMLElement;
|
let navMargin = document.getElementById("body") as HTMLElement;
|
||||||
let r
|
let r
|
||||||
|
|
||||||
|
@ -1,16 +1,24 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {onMount} from 'svelte'
|
import {onMount} from 'svelte'
|
||||||
import {GetModpacks} from '../wailsjs/go/main/ModpackManager.js'
|
import {GetModpacks} from '../wailsjs/go/main/ModpackManager.js'
|
||||||
|
import {ImportModpack} from '../wailsjs/go/main/InstanceManager.js'
|
||||||
import { main } from '../wailsjs/go/models';
|
import { main } from '../wailsjs/go/models';
|
||||||
|
import {loading} from './global.js'
|
||||||
let modpacks: main.Modpack[] = []
|
let modpacks: main.Modpack[] = []
|
||||||
let pack: main.Modpack
|
let pack: main.Modpack
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
GetModpacks().then((result) => {
|
GetModpacks().then((result) => {
|
||||||
modpacks = result
|
modpacks = result
|
||||||
|
pack = result[0]
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function AddModpack(){
|
||||||
|
$loading = true
|
||||||
|
ImportModpack(pack, pack.Name).then(() => $loading = false)
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
@ -19,4 +27,5 @@
|
|||||||
<option value={pack}>{pack.Name}</option>
|
<option value={pack}>{pack.Name}</option>
|
||||||
{/each}
|
{/each}
|
||||||
</select>
|
</select>
|
||||||
|
<button on:click={AddModpack}>Add Modpack</button>
|
||||||
</main>
|
</main>
|
@ -1,6 +1,7 @@
|
|||||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||||
// This file is automatically generated. DO NOT EDIT
|
// This file is automatically generated. DO NOT EDIT
|
||||||
import {main} from '../models';
|
import {main} from '../models';
|
||||||
|
import {io} from '../models';
|
||||||
|
|
||||||
export function CheckUpdate(arg1:main.Instance):Promise<void>;
|
export function CheckUpdate(arg1:main.Instance):Promise<void>;
|
||||||
|
|
||||||
@ -8,6 +9,10 @@ export function GetInstance(arg1:string):Promise<main.Instance>;
|
|||||||
|
|
||||||
export function GetInstances():Promise<Array<string>>;
|
export function GetInstances():Promise<Array<string>>;
|
||||||
|
|
||||||
|
export function ImportModpack(arg1:main.Modpack,arg2:string):Promise<void>;
|
||||||
|
|
||||||
|
export function ImportMrpack(arg1:io.Reader,arg2:string):Promise<void>;
|
||||||
|
|
||||||
export function InstallFabric(arg1:string,arg2:string):Promise<void>;
|
export function InstallFabric(arg1:string,arg2:string):Promise<void>;
|
||||||
|
|
||||||
export function InstallForge(arg1:string,arg2:string):Promise<void>;
|
export function InstallForge(arg1:string,arg2:string):Promise<void>;
|
||||||
|
@ -14,6 +14,14 @@ export function GetInstances() {
|
|||||||
return window['go']['main']['InstanceManager']['GetInstances']();
|
return window['go']['main']['InstanceManager']['GetInstances']();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function ImportModpack(arg1, arg2) {
|
||||||
|
return window['go']['main']['InstanceManager']['ImportModpack'](arg1, arg2);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ImportMrpack(arg1, arg2) {
|
||||||
|
return window['go']['main']['InstanceManager']['ImportMrpack'](arg1, arg2);
|
||||||
|
}
|
||||||
|
|
||||||
export function InstallFabric(arg1, arg2) {
|
export function InstallFabric(arg1, arg2) {
|
||||||
return window['go']['main']['InstanceManager']['InstallFabric'](arg1, arg2);
|
return window['go']['main']['InstanceManager']['InstallFabric'](arg1, arg2);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user