Support 1.19.
This commit is contained in:
parent
a6e3d2b85c
commit
8e76d6a2b9
@ -709,6 +709,7 @@ class ProcessBuilder {
|
|||||||
* @returns {{[id: string]: string}} An object containing the paths of each library mojang declares.
|
* @returns {{[id: string]: string}} An object containing the paths of each library mojang declares.
|
||||||
*/
|
*/
|
||||||
_resolveMojangLibraries(tempNativePath){
|
_resolveMojangLibraries(tempNativePath){
|
||||||
|
const nativesRegex = /.+:natives-([^-]+)(?:-(.+))?/
|
||||||
const libs = {}
|
const libs = {}
|
||||||
|
|
||||||
const libArr = this.versionData.libraries
|
const libArr = this.versionData.libraries
|
||||||
@ -716,13 +717,9 @@ class ProcessBuilder {
|
|||||||
for(let i=0; i<libArr.length; i++){
|
for(let i=0; i<libArr.length; i++){
|
||||||
const lib = libArr[i]
|
const lib = libArr[i]
|
||||||
if(Library.validateRules(lib.rules, lib.natives)){
|
if(Library.validateRules(lib.rules, lib.natives)){
|
||||||
if(lib.natives == null){
|
|
||||||
const dlInfo = lib.downloads
|
// Pre-1.19 has a natives object.
|
||||||
const artifact = dlInfo.artifact
|
if(lib.natives != null) {
|
||||||
const to = path.join(this.libPath, artifact.path)
|
|
||||||
const versionIndependentId = lib.name.substring(0, lib.name.lastIndexOf(':'))
|
|
||||||
libs[versionIndependentId] = to
|
|
||||||
} else {
|
|
||||||
// Extract the native library.
|
// Extract the native library.
|
||||||
const exclusionArr = lib.extract != null ? lib.extract.exclude : ['META-INF/']
|
const exclusionArr = lib.extract != null ? lib.extract.exclude : ['META-INF/']
|
||||||
const artifact = lib.downloads.classifiers[lib.natives[Library.mojangFriendlyOS()].replace('${arch}', process.arch.replace('x', ''))]
|
const artifact = lib.downloads.classifiers[lib.natives[Library.mojangFriendlyOS()].replace('${arch}', process.arch.replace('x', ''))]
|
||||||
@ -757,6 +754,65 @@ class ProcessBuilder {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 1.19+ logic
|
||||||
|
else if(lib.name.includes('natives-')) {
|
||||||
|
|
||||||
|
const regexTest = nativesRegex.exec(lib.name)
|
||||||
|
// const os = regexTest[1]
|
||||||
|
const arch = regexTest[2] ?? 'x64'
|
||||||
|
|
||||||
|
if(arch != process.arch) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract the native library.
|
||||||
|
const exclusionArr = lib.extract != null ? lib.extract.exclude : ['META-INF/', '.git', '.sha1']
|
||||||
|
const artifact = lib.downloads.artifact
|
||||||
|
|
||||||
|
// Location of native zip.
|
||||||
|
const to = path.join(this.libPath, artifact.path)
|
||||||
|
|
||||||
|
let zip = new AdmZip(to)
|
||||||
|
let zipEntries = zip.getEntries()
|
||||||
|
|
||||||
|
// Unzip the native zip.
|
||||||
|
for(let i=0; i<zipEntries.length; i++){
|
||||||
|
if(zipEntries[i].isDirectory) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
const fileName = zipEntries[i].entryName
|
||||||
|
|
||||||
|
let shouldExclude = false
|
||||||
|
|
||||||
|
// Exclude noted files.
|
||||||
|
exclusionArr.forEach(function(exclusion){
|
||||||
|
if(fileName.indexOf(exclusion) > -1){
|
||||||
|
shouldExclude = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const extractName = fileName.includes('/') ? fileName.substring(fileName.lastIndexOf('/')) : fileName
|
||||||
|
|
||||||
|
// Extract the file.
|
||||||
|
if(!shouldExclude){
|
||||||
|
fs.writeFile(path.join(tempNativePath, extractName), zipEntries[i].getData(), (err) => {
|
||||||
|
if(err){
|
||||||
|
logger.error('Error while extracting native library:', err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// No natives
|
||||||
|
else {
|
||||||
|
const dlInfo = lib.downloads
|
||||||
|
const artifact = dlInfo.artifact
|
||||||
|
const to = path.join(this.libPath, artifact.path)
|
||||||
|
const versionIndependentId = lib.name.substring(0, lib.name.lastIndexOf(':'))
|
||||||
|
libs[versionIndependentId] = to
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user