Skip to content

Commit 78df62c

Browse files
committed
Fix for fabric
1 parent b22ef33 commit 78df62c

File tree

6 files changed

+56
-72
lines changed

6 files changed

+56
-72
lines changed

app/assets/js/processbuilder.js

Lines changed: 46 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,32 @@ const ConfigManager = require('./configmanager')
1212

1313
const logger = LoggerUtil.getLogger('ProcessBuilder')
1414

15+
16+
/**
17+
* Only forge and fabric are top level mod loaders.
18+
*
19+
* Forge 1.13+ launch logic is similar to fabrics, for now using usingFabricLoader flag to
20+
* change minor details when needed.
21+
*
22+
* Rewrite of this module may be needed in the future.
23+
*/
1524
class ProcessBuilder {
1625

17-
constructor(distroServer, versionData, forgeData, authUser, launcherVersion){
26+
constructor(distroServer, vanillaManifest, modManifest, authUser, launcherVersion){
1827
this.gameDir = path.join(ConfigManager.getInstanceDirectory(), distroServer.rawServer.id)
1928
this.commonDir = ConfigManager.getCommonDirectory()
2029
this.server = distroServer
21-
this.versionData = versionData
22-
this.forgeData = forgeData
30+
this.vanillaManifest = vanillaManifest
31+
this.modManifest = modManifest
2332
this.authUser = authUser
2433
this.launcherVersion = launcherVersion
2534
this.forgeModListFile = path.join(this.gameDir, 'forgeMods.list') // 1.13+
2635
this.fmlDir = path.join(this.gameDir, 'forgeModList.json')
27-
this.llDir = path.join(this.gameDir, 'liteloaderModList.json')
36+
this.llDir = path.join(this.gameDir, 'liteforgeDataloaderModList.json')
2837
this.libPath = path.join(this.commonDir, 'libraries')
2938

3039
this.usingLiteLoader = false
40+
this.usingFabricLoader = false
3141
this.llPath = null
3242
}
3343

@@ -40,9 +50,12 @@ class ProcessBuilder {
4050
process.throwDeprecation = true
4151
this.setupLiteLoader()
4252
logger.info('Using liteloader:', this.usingLiteLoader)
53+
this.usingFabricLoader = this.server.modules.some(mdl => mdl.rawModule.type === Type.Fabric)
54+
logger.info('Using fabric loader:', this.usingFabricLoader)
4355
const modObj = this.resolveModConfiguration(ConfigManager.getModConfiguration(this.server.rawServer.id).mods, this.server.modules)
4456

4557
// Mod list below 1.13
58+
// Fabric only supports 1.14+
4659
if(!mcVersionAtLeast('1.13', this.server.rawServer.minecraftVersion)){
4760
this.constructJSONModList('forge', modObj.fMods, true)
4861
if(this.usingLiteLoader){
@@ -170,7 +183,7 @@ class ProcessBuilder {
170183

171184
for(let mdl of mdls){
172185
const type = mdl.rawModule.type
173-
if(type === Type.ForgeMod || type === Type.LiteMod || type === Type.LiteLoader){
186+
if(type === Type.ForgeMod || type === Type.LiteMod || type === Type.LiteLoader || type === Type.FabricMod){
174187
const o = !mdl.getRequired().value
175188
const e = ProcessBuilder.isModEnabled(modCfg[mdl.getVersionlessMavenIdentifier()], mdl.getRequired())
176189
if(!o || (o && e)){
@@ -182,7 +195,7 @@ class ProcessBuilder {
182195
continue
183196
}
184197
}
185-
if(type === Type.ForgeMod){
198+
if(type === Type.ForgeMod || type === Type.FabricMod){
186199
fMods.push(mdl)
187200
} else {
188201
lMods.push(mdl)
@@ -198,7 +211,7 @@ class ProcessBuilder {
198211
}
199212

200213
_lteMinorVersion(version) {
201-
return Number(this.forgeData.id.split('-')[0].split('.')[1]) <= Number(version)
214+
return Number(this.modManifest.id.split('-')[0].split('.')[1]) <= Number(version)
202215
}
203216

204217
/**
@@ -210,7 +223,7 @@ class ProcessBuilder {
210223
if(this._lteMinorVersion(9)) {
211224
return false
212225
}
213-
const ver = this.forgeData.id.split('-')[2]
226+
const ver = this.modManifest.id.split('-')[2]
214227
const pts = ver.split('.')
215228
const min = [14, 23, 3, 2655]
216229
for(let i=0; i<pts.length; i++){
@@ -286,18 +299,21 @@ class ProcessBuilder {
286299
// }
287300

288301
/**
289-
* Construct the mod argument list for forge 1.13
302+
* Construct the mod argument list for forge 1.13 and fabric
290303
*
291304
* @param {Array.<Object>} mods An array of mods to add to the mod list.
292305
*/
293306
constructModList(mods) {
294307
const writeBuffer = mods.map(mod => {
295-
return mod.getExtensionlessMavenIdentifier()
308+
return this.usingFabricLoader ? mod.getPath() : mod.getExtensionlessMavenIdentifier()
296309
}).join('\n')
297310

298311
if(writeBuffer) {
299312
fs.writeFileSync(this.forgeModListFile, writeBuffer, 'UTF-8')
300-
return [
313+
return this.usingFabricLoader ? [
314+
'--fabric.addMods',
315+
`@${this.forgeModListFile}`
316+
] : [
301317
'--fml.mavenRoots',
302318
path.join('..', '..', 'common', 'modstore'),
303319
'--fml.modLists',
@@ -360,7 +376,7 @@ class ProcessBuilder {
360376
args.push('-Djava.library.path=' + tempNativePath)
361377

362378
// Main Java Class
363-
args.push(this.forgeData.mainClass)
379+
args.push(this.modManifest.mainClass)
364380

365381
// Forge Arguments
366382
args = args.concat(this._resolveForgeArgs())
@@ -383,17 +399,17 @@ class ProcessBuilder {
383399
const argDiscovery = /\${*(.*)}/
384400

385401
// JVM Arguments First
386-
let args = this.versionData.arguments.jvm
402+
let args = this.vanillaManifest.arguments.jvm
387403

388404
// Debug securejarhandler
389405
// args.push('-Dbsl.debug=true')
390406

391-
if(this.forgeData.arguments.jvm != null) {
392-
for(const argStr of this.forgeData.arguments.jvm) {
407+
if(this.modManifest.arguments.jvm != null) {
408+
for(const argStr of this.modManifest.arguments.jvm) {
393409
args.push(argStr
394410
.replaceAll('${library_directory}', this.libPath)
395411
.replaceAll('${classpath_separator}', ProcessBuilder.getClasspathSeparator())
396-
.replaceAll('${version_name}', this.forgeData.id)
412+
.replaceAll('${version_name}', this.modManifest.id)
397413
)
398414
}
399415
}
@@ -410,10 +426,10 @@ class ProcessBuilder {
410426
args = args.concat(ConfigManager.getJVMOptions(this.server.rawServer.id))
411427

412428
// Main Java Class
413-
args.push(this.forgeData.mainClass)
429+
args.push(this.modManifest.mainClass)
414430

415431
// Vanilla Arguments
416-
args = args.concat(this.versionData.arguments.game)
432+
args = args.concat(this.vanillaManifest.arguments.game)
417433

418434
for(let i=0; i<args.length; i++){
419435
if(typeof args[i] === 'object' && args[i].rules != null){
@@ -480,7 +496,7 @@ class ProcessBuilder {
480496
val = path.join(this.commonDir, 'assets')
481497
break
482498
case 'assets_index_name':
483-
val = this.versionData.assets
499+
val = this.vanillaManifest.assets
484500
break
485501
case 'auth_uuid':
486502
val = this.authUser.uuid.trim()
@@ -492,7 +508,7 @@ class ProcessBuilder {
492508
val = this.authUser.type === 'microsoft' ? 'msa' : 'mojang'
493509
break
494510
case 'version_type':
495-
val = this.versionData.type
511+
val = this.vanillaManifest.type
496512
break
497513
case 'resolution_width':
498514
val = ConfigManager.getGameWidth()
@@ -521,25 +537,11 @@ class ProcessBuilder {
521537
}
522538

523539
// Autoconnect
524-
let isAutoconnectBroken
525-
try {
526-
isAutoconnectBroken = ProcessBuilder.isAutoconnectBroken(this.forgeData.id.split('-')[2])
527-
} catch(err) {
528-
logger.error(err)
529-
logger.error('Forge version format changed.. assuming autoconnect works.')
530-
logger.debug('Forge version:', this.forgeData.id)
531-
}
532-
533-
if(isAutoconnectBroken) {
534-
logger.error('Server autoconnect disabled on Forge 1.15.2 for builds earlier than 31.2.15 due to OpenGL Stack Overflow issue.')
535-
logger.error('Please upgrade your Forge version to at least 31.2.15!')
536-
} else {
537-
this._processAutoConnectArg(args)
538-
}
540+
this._processAutoConnectArg(args)
539541

540542

541543
// Forge Specific Arguments
542-
args = args.concat(this.forgeData.arguments.game)
544+
args = args.concat(this.modManifest.arguments.game)
543545

544546
// Filter null values
545547
args = args.filter(arg => {
@@ -555,7 +557,7 @@ class ProcessBuilder {
555557
* @returns {Array.<string>} An array containing the arguments required by forge.
556558
*/
557559
_resolveForgeArgs(){
558-
const mcArgs = this.forgeData.minecraftArguments.split(' ')
560+
const mcArgs = this.modManifest.minecraftArguments.split(' ')
559561
const argDiscovery = /\${*(.*)}/
560562

561563
// Replace the declared variables with their proper values.
@@ -578,7 +580,7 @@ class ProcessBuilder {
578580
val = path.join(this.commonDir, 'assets')
579581
break
580582
case 'assets_index_name':
581-
val = this.versionData.assets
583+
val = this.vanillaManifest.assets
582584
break
583585
case 'auth_uuid':
584586
val = this.authUser.uuid.trim()
@@ -593,7 +595,7 @@ class ProcessBuilder {
593595
val = '{}'
594596
break
595597
case 'version_type':
596-
val = this.versionData.type
598+
val = this.vanillaManifest.type
597599
break
598600
}
599601
if(val != null){
@@ -668,10 +670,10 @@ class ProcessBuilder {
668670
classpathArg(mods, tempNativePath){
669671
let cpArgs = []
670672

671-
if(!mcVersionAtLeast('1.17', this.server.rawServer.minecraftVersion)) {
673+
if(!mcVersionAtLeast('1.17', this.server.rawServer.minecraftVersion) || this.usingFabricLoader) {
672674
// Add the version.jar to the classpath.
673675
// Must not be added to the classpath for Forge 1.17+.
674-
const version = this.versionData.id
676+
const version = this.vanillaManifest.id
675677
cpArgs.push(path.join(this.commonDir, 'versions', version, version + '.jar'))
676678
}
677679

@@ -710,7 +712,7 @@ class ProcessBuilder {
710712
const nativesRegex = /.+:natives-([^-]+)(?:-(.+))?/
711713
const libs = {}
712714

713-
const libArr = this.versionData.libraries
715+
const libArr = this.vanillaManifest.libraries
714716
fs.ensureDirSync(tempNativePath)
715717
for(let i=0; i<libArr.length; i++){
716718
const lib = libArr[i]
@@ -829,10 +831,10 @@ class ProcessBuilder {
829831
const mdls = this.server.modules
830832
let libs = {}
831833

832-
// Locate Forge/Libraries
834+
// Locate Forge/Fabric/Libraries
833835
for(let mdl of mdls){
834836
const type = mdl.rawModule.type
835-
if(type === Type.ForgeHosted || type === Type.Library){
837+
if(type === Type.ForgeHosted || type === Type.Fabric || type === Type.Library){
836838
libs[mdl.getVersionlessMavenIdentifier()] = mdl.getPath()
837839
if(mdl.subModules.length > 0){
838840
const res = this._resolveModuleLibraries(mdl)
@@ -880,24 +882,6 @@ class ProcessBuilder {
880882
return libs
881883
}
882884

883-
static isAutoconnectBroken(forgeVersion) {
884-
885-
const minWorking = [31, 2, 15]
886-
const verSplit = forgeVersion.split('.').map(v => Number(v))
887-
888-
if(verSplit[0] === 31) {
889-
for(let i=0; i<minWorking.length; i++) {
890-
if(verSplit[i] > minWorking[i]) {
891-
return false
892-
} else if(verSplit[i] < minWorking[i]) {
893-
return true
894-
}
895-
}
896-
}
897-
898-
return false
899-
}
900-
901885
}
902886

903887
module.exports = ProcessBuilder

app/assets/js/scripts/landing.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ let hasRPC = false
448448
// Joined server regex
449449
// Change this if your server uses something different.
450450
const GAME_JOINED_REGEX = /\[.+\]: Sound engine started/
451-
const GAME_LAUNCH_REGEX = /^\[.+\]: (?:MinecraftForge .+ Initialized|ModLauncher .+ starting: .+)$/
451+
const GAME_LAUNCH_REGEX = /^\[.+\]: (?:MinecraftForge .+ Initialized|ModLauncher .+ starting: .+|Loading Minecraft .+ with Fabric Loader .+)$/
452452
const MIN_LINGER = 5000
453453

454454
async function dlAsync(login = true) {
@@ -554,13 +554,13 @@ async function dlAsync(login = true) {
554554
serv.rawServer.id
555555
)
556556

557-
const forgeData = await distributionIndexProcessor.loadForgeVersionJson(serv)
557+
const loaderData = await distributionIndexProcessor.loadModLoaderVersionJson(serv)
558558
const versionData = await mojangIndexProcessor.getVersionJson()
559559

560560
if(login) {
561561
const authUser = ConfigManager.getSelectedAccount()
562562
loggerLaunchSuite.info(`Sending selected account (${authUser.displayName}) to ProcessBuilder.`)
563-
let pb = new ProcessBuilder(serv, versionData, forgeData, authUser, remote.app.getVersion())
563+
let pb = new ProcessBuilder(serv, versionData, loaderData, authUser, remote.app.getVersion())
564564
setLaunchDetails('Lancement...')
565565

566566
// const SERVER_JOINED_REGEX = /\[.+\]: \[CHAT\] [a-zA-Z0-9_]{1,16} joined the game/

app/assets/js/scripts/settings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ function parseModulesForUI(mdls, submodules, servConf){
784784

785785
for(const mdl of mdls){
786786

787-
if(mdl.rawModule.type === Type.ForgeMod || mdl.rawModule.type === Type.LiteMod || mdl.rawModule.type === Type.LiteLoader){
787+
if(mdl.rawModule.type === Type.ForgeMod || mdl.rawModule.type === Type.LiteMod || mdl.rawModule.type === Type.LiteLoader || mdl.rawModule.type === Type.FabricMod){
788788

789789
if(mdl.getRequired().value){
790790

app/assets/js/scripts/uibinder.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ function syncModConfigurations(data){
164164
for(let mdl of mdls){
165165
const type = mdl.rawModule.type
166166

167-
if(type === Type.ForgeMod || type === Type.LiteMod || type === Type.LiteLoader){
167+
if(type === Type.ForgeMod || type === Type.LiteMod || type === Type.LiteLoader || type === Type.FabricMod){
168168
if(!mdl.getRequired().value){
169169
const mdlID = mdl.getVersionlessMavenIdentifier()
170170
if(modsOld[mdlID] == null){
@@ -199,7 +199,7 @@ function syncModConfigurations(data){
199199

200200
for(let mdl of mdls){
201201
const type = mdl.rawModule.type
202-
if(type === Type.ForgeMod || type === Type.LiteMod || type === Type.LiteLoader){
202+
if(type === Type.ForgeMod || type === Type.LiteMod || type === Type.LiteLoader || type === Type.FabricMod){
203203
if(!mdl.getRequired().value){
204204
mods[mdl.getVersionlessMavenIdentifier()] = scanOptionalSubModules(mdl.subModules, mdl)
205205
} else {
@@ -254,7 +254,7 @@ function scanOptionalSubModules(mdls, origin){
254254
for(let mdl of mdls){
255255
const type = mdl.rawModule.type
256256
// Optional types.
257-
if(type === Type.ForgeMod || type === Type.LiteMod || type === Type.LiteLoader){
257+
if(type === Type.ForgeMod || type === Type.LiteMod || type === Type.LiteLoader || type === Type.FabricMod){
258258
// It is optional.
259259
if(!mdl.getRequired().value){
260260
mods[mdl.getVersionlessMavenIdentifier()] = scanOptionalSubModules(mdl.subModules, mdl)

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gaialauncher",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"productName": "Gaïa Launcher",
55
"description": "Modded Minecraft Launcher",
66
"author": "Valbion Group",

0 commit comments

Comments
 (0)