Skip to content

Commit 3e800fc

Browse files
committed
even more fixes
1 parent 7b52708 commit 3e800fc

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "simplelauncher",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "Launcher for SimpleClient",
55
"main": "src/main.js",
66
"scripts": {

src/minecraft.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { existsSync } = require("original-fs")
22
const { getDirectory, runSync, runAsync, getPath } = require("./util")
33
const { join, dirname } = require("path")
44
const { spawnSync, spawn, } = require("child_process")
5-
const { mkdirSync, readFileSync, statSync, writeFileSync } = require("fs")
5+
const { mkdirSync, readFileSync, statSync, writeFileSync, renameSync, rmdirSync, rm, rmSync, rename, copyFileSync, cp, cpSync, readdirSync } = require("fs")
66
const { homedir, platform } = require("os")
77
const { downloadJava, getJavaVersion } = require("./java")
88
const { arch, env, stdout } = require("process")
@@ -222,18 +222,14 @@ const launch = async (version, account, statusCallback) => {
222222
var jvmArguments = [
223223
`-Xmx${memory}M`,
224224
'-Dlog4j2.formatMsgNoLookups=true',
225-
'-Dfabric.addMods=' + version.mods.map(mod => {
226-
const fileName = mod.split('/')[mod.split('/').length - 1]
227-
return join(dir, 'mods', fileName)
228-
}).join(separator)
225+
'-Dfabric.addMods=' + readdirSync(join(dir, 'mods')).map(mod => join(dir, 'mods', mod)).join(separator)
229226
]
230227
meta.arguments.jvm.filter(arg => !arg.rules || arg.rules.every(checkRule)).forEach(arg => {
231228
if (arg.value) {
232229
if (Array.isArray(arg.value)) for (value of arg.value) jvmArguments.push(value)
233230
else jvmArguments.push(arg.value)
234231
} else jvmArguments.push(arg)
235232
})
236-
console.log(jvmArguments)
237233
var arguments = []
238234
arguments = arguments.concat(jvmArguments)
239235
arguments.push(meta.mainClass)
@@ -243,10 +239,19 @@ const launch = async (version, account, statusCallback) => {
243239
else arguments.push(arg.value)
244240
} else arguments.push(arg)
245241
})
242+
if (existsSync(join(getDirectory(), 'tmpmods'))) rmSync(join(getDirectory(), 'tmpmods'), {recursive: true, force: true})
243+
cpSync(join(getMinecraftDir(), 'mods'), join(getDirectory(), 'tmpmods'), {recursive: true, force: true})
244+
rmSync(join(getMinecraftDir(), 'mods'), {recursive: true, force: true})
246245
spawn('java', insertValues(arguments, values), {
247246
cwd: getMinecraftDir(),
248247
env: {PATH: path}
249-
}).stdout.pipe(stdout)
248+
}).stdout.on('data', data => {
249+
if (data.toString().includes('Loading ') &&
250+
data.toString().includes(' mods:')) {
251+
cp(join(getDirectory(), 'tmpmods'), join(getMinecraftDir(), 'mods'), {recursive: true, force: true}, () => {})
252+
rm(join(getDirectory(), 'tmpmods'), {recursive: true, force: true}, () => {})
253+
}
254+
}).pipe(stdout)
250255
statusCallback('done')
251256
}
252257

0 commit comments

Comments
 (0)