Support vanilla profile launches
This commit is contained in:
@@ -68,7 +68,16 @@ class ProcessBuilder {
|
||||
this.commonDir = ConfigManager.getCommonDirectory()
|
||||
this.server = distroServer
|
||||
this.vanillaManifest = vanillaManifest
|
||||
this.modManifest = modManifest
|
||||
this.usingModLoader = modManifest != null
|
||||
this.modManifest = modManifest ?? {
|
||||
id: vanillaManifest.id,
|
||||
mainClass: vanillaManifest.mainClass,
|
||||
arguments: {
|
||||
jvm: [],
|
||||
game: []
|
||||
},
|
||||
minecraftArguments: vanillaManifest.minecraftArguments ?? ''
|
||||
}
|
||||
this.authUser = authUser
|
||||
this.launcherVersion = launcherVersion
|
||||
this.forgeModListFile = path.join(this.gameDir, 'forgeMods.list') // 1.13+
|
||||
@@ -90,13 +99,13 @@ class ProcessBuilder {
|
||||
process.throwDeprecation = true
|
||||
this.setupLiteLoader()
|
||||
logger.info('Using liteloader:', this.usingLiteLoader)
|
||||
this.usingFabricLoader = this.server.modules.some(mdl => mdl.rawModule.type === Type.Fabric)
|
||||
this.usingFabricLoader = this.usingModLoader && this.server.modules.some(mdl => mdl.rawModule.type === Type.Fabric)
|
||||
logger.info('Using fabric loader:', this.usingFabricLoader)
|
||||
const modObj = this.resolveModConfiguration(ConfigManager.getModConfiguration(this.server.rawServer.id).mods, this.server.modules)
|
||||
|
||||
// Mod list below 1.13
|
||||
// Fabric only supports 1.14+
|
||||
if(!mcVersionAtLeast('1.13', this.server.rawServer.minecraftVersion)){
|
||||
if(this.usingModLoader && !mcVersionAtLeast('1.13', this.server.rawServer.minecraftVersion)){
|
||||
this.constructJSONModList('forge', modObj.fMods, true)
|
||||
if(this.usingLiteLoader){
|
||||
this.constructJSONModList('liteloader', modObj.lMods, true)
|
||||
@@ -106,7 +115,7 @@ class ProcessBuilder {
|
||||
const uberModArr = modObj.fMods.concat(modObj.lMods)
|
||||
let args = this.constructJVMArguments(uberModArr, tempNativePath)
|
||||
|
||||
if(mcVersionAtLeast('1.13', this.server.rawServer.minecraftVersion)){
|
||||
if(this.usingModLoader && mcVersionAtLeast('1.13', this.server.rawServer.minecraftVersion)){
|
||||
//args = args.concat(this.constructModArguments(modObj.fMods))
|
||||
args = args.concat(this.constructModList(modObj.fMods))
|
||||
}
|
||||
@@ -484,7 +493,7 @@ class ProcessBuilder {
|
||||
// Debug securejarhandler
|
||||
// args.push('-Dbsl.debug=true')
|
||||
|
||||
if(this.modManifest.arguments.jvm != null) {
|
||||
if(this.usingModLoader && this.modManifest.arguments.jvm != null) {
|
||||
for(const argStr of this.modManifest.arguments.jvm) {
|
||||
args.push(argStr
|
||||
.replaceAll('${library_directory}', this.libPath)
|
||||
@@ -621,7 +630,9 @@ class ProcessBuilder {
|
||||
|
||||
|
||||
// Forge Specific Arguments
|
||||
args = args.concat(this.modManifest.arguments.game)
|
||||
if(this.usingModLoader){
|
||||
args = args.concat(this.modManifest.arguments.game)
|
||||
}
|
||||
|
||||
// Filter null values
|
||||
args = args.filter(arg => {
|
||||
@@ -637,7 +648,10 @@ class ProcessBuilder {
|
||||
* @returns {Array.<string>} An array containing the arguments required by forge.
|
||||
*/
|
||||
_resolveForgeArgs(){
|
||||
const mcArgs = this.modManifest.minecraftArguments.split(' ')
|
||||
const baseMinecraftArguments = this.usingModLoader
|
||||
? this.modManifest.minecraftArguments
|
||||
: (this.vanillaManifest.minecraftArguments ?? '')
|
||||
const mcArgs = baseMinecraftArguments.split(' ')
|
||||
const argDiscovery = /\${*(.*)}/
|
||||
|
||||
// Replace the declared variables with their proper values.
|
||||
@@ -699,22 +713,23 @@ class ProcessBuilder {
|
||||
}
|
||||
|
||||
// Mod List File Argument
|
||||
mcArgs.push('--modListFile')
|
||||
if(this._lteMinorVersion(9)) {
|
||||
mcArgs.push(path.basename(this.fmlDir))
|
||||
} else {
|
||||
mcArgs.push('absolute:' + this.fmlDir)
|
||||
}
|
||||
if(this.usingModLoader){
|
||||
mcArgs.push('--modListFile')
|
||||
if(this._lteMinorVersion(9)) {
|
||||
mcArgs.push(path.basename(this.fmlDir))
|
||||
} else {
|
||||
mcArgs.push('absolute:' + this.fmlDir)
|
||||
}
|
||||
|
||||
// LiteLoader
|
||||
if(this.usingLiteLoader){
|
||||
mcArgs.push('--modRepo')
|
||||
mcArgs.push(this.llDir)
|
||||
|
||||
// LiteLoader
|
||||
if(this.usingLiteLoader){
|
||||
mcArgs.push('--modRepo')
|
||||
mcArgs.push(this.llDir)
|
||||
|
||||
// Set first arg to liteloader tweak class
|
||||
mcArgs.unshift('com.mumfrey.liteloader.launch.LiteLoaderTweaker')
|
||||
mcArgs.unshift('--tweakClass')
|
||||
// Set first arg to liteloader tweak class
|
||||
mcArgs.unshift('com.mumfrey.liteloader.launch.LiteLoaderTweaker')
|
||||
mcArgs.unshift('--tweakClass')
|
||||
}
|
||||
}
|
||||
|
||||
return mcArgs
|
||||
@@ -750,7 +765,7 @@ class ProcessBuilder {
|
||||
classpathArg(mods, tempNativePath){
|
||||
let cpArgs = []
|
||||
|
||||
if(!mcVersionAtLeast('1.17', this.server.rawServer.minecraftVersion) || this.usingFabricLoader) {
|
||||
if(!mcVersionAtLeast('1.17', this.server.rawServer.minecraftVersion) || this.usingFabricLoader || !this.usingModLoader) {
|
||||
// Add the version.jar to the classpath.
|
||||
// Must not be added to the classpath for Forge 1.17+.
|
||||
const version = this.vanillaManifest.id
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
*/
|
||||
(() => {
|
||||
// Requirements
|
||||
require('./assets/js/vanillapatch')
|
||||
|
||||
const path = require('path')
|
||||
const { URL } = require('url')
|
||||
const {
|
||||
MojangRestAPI
|
||||
@@ -689,7 +692,15 @@ async function dlAsync(login = true) {
|
||||
DistroAPI.isDevMode()
|
||||
)
|
||||
|
||||
fullRepairModule.spawnReceiver()
|
||||
const receiverPatchPath = path.join(__dirname, '..', 'vanillapatch.js')
|
||||
const existingNodeOptions = process.env.NODE_OPTIONS?.trim()
|
||||
const receiverNodeOptions = `--require=\"${receiverPatchPath}\"`
|
||||
|
||||
fullRepairModule.spawnReceiver({
|
||||
NODE_OPTIONS: existingNodeOptions != null && existingNodeOptions.length > 0
|
||||
? `${existingNodeOptions} ${receiverNodeOptions}`
|
||||
: receiverNodeOptions
|
||||
})
|
||||
|
||||
fullRepairModule.childProcess.on('error', (err) => {
|
||||
loggerLaunchSuite.error('Error during launch', err)
|
||||
@@ -751,7 +762,7 @@ async function dlAsync(login = true) {
|
||||
serv.rawServer.id
|
||||
)
|
||||
|
||||
const modLoaderData = await distributionIndexProcessor.loadModLoaderVersionJson(serv)
|
||||
const modLoaderData = await distributionIndexProcessor.loadModLoaderVersionJson()
|
||||
const versionData = await mojangIndexProcessor.getVersionJson()
|
||||
|
||||
if(login) {
|
||||
|
||||
23
app/assets/js/vanillapatch.js
Normal file
23
app/assets/js/vanillapatch.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const { DistributionIndexProcessor } = require('helios-core/dl')
|
||||
const { Type } = require('helios-distribution-types')
|
||||
|
||||
if(!DistributionIndexProcessor.prototype.__mrsVanillaPatchApplied){
|
||||
const originalLoadModLoaderVersionJson = DistributionIndexProcessor.prototype.loadModLoaderVersionJson
|
||||
|
||||
DistributionIndexProcessor.prototype.loadModLoaderVersionJson = async function(...args){
|
||||
const server = this.distribution?.getServerById?.(this.serverId)
|
||||
const hasModLoader = server?.modules?.some(({ rawModule }) => {
|
||||
return rawModule?.type === Type.ForgeHosted
|
||||
|| rawModule?.type === Type.Forge
|
||||
|| rawModule?.type === Type.Fabric
|
||||
}) === true
|
||||
|
||||
if(!hasModLoader){
|
||||
return null
|
||||
}
|
||||
|
||||
return originalLoadModLoaderVersionJson.apply(this, args)
|
||||
}
|
||||
|
||||
DistributionIndexProcessor.prototype.__mrsVanillaPatchApplied = true
|
||||
}
|
||||
Reference in New Issue
Block a user