Update to v0.1.2-alpha
- Fix glitches in some themes. - Add multi-platform library deduplication and comparison logic - Enhance mod and library merging logic with platform and loader preferences (prepare for forge/neoforge support) - Fix certain runtime detect/inspect issues. CoreLib update to 0.1.5
This commit is contained in:
1 parent
c55f559989
commit
ef3667ae5e
16 files changed
+693
-111
No files matched your search
@@ -140,6 +140,20 @@ def is_library_allowed(rules, platform_rule_name, platform_arch_type, platform_v
|
||||
|
||||
return allowed
|
||||
|
||||
def filter_platform_libraries(libraries: list[dict]) -> list[dict]:
|
||||
_, _, os_version = get_platform_info()
|
||||
_, platform_rule_name, platform_arch_type = get_natives_platform_info()
|
||||
|
||||
return [
|
||||
library
|
||||
for library in libraries
|
||||
if is_library_allowed(
|
||||
library.get("rules") or [],
|
||||
platform_rule_name,
|
||||
platform_arch_type,
|
||||
os_version,
|
||||
)
|
||||
]
|
||||
|
||||
def get_natives_platform_info():
|
||||
"""
|
||||
@@ -277,7 +291,8 @@ def is_legacy_native_allowed(natives, classifiers, platform_rule_name, platform_
|
||||
return False, None, None
|
||||
|
||||
|
||||
def generate_relative_path_by_maven_coordinate(maven_coordinate: str, extra=None) -> str | None:
|
||||
def generate_relative_path_by_maven_coordinate(maven_coordinate: str, extra=None,
|
||||
extension: str = "jar") -> str | None:
|
||||
parts = maven_coordinate.split(":")
|
||||
|
||||
if len(parts) not in (3, 4):
|
||||
@@ -293,7 +308,7 @@ def generate_relative_path_by_maven_coordinate(maven_coordinate: str, extra=None
|
||||
if classifier:
|
||||
filename += f"-{classifier}"
|
||||
|
||||
return f"{base_path}/{artifact}/{version}/{filename}.jar"
|
||||
return f"{base_path}/{artifact}/{version}/{filename}.{extension}"
|
||||
|
||||
|
||||
def remove_duplicate_artifacts(artifacts: list[dict], ignore_null=False, compare_by_name=False) -> list[dict]:
|
||||
|
||||
+117
-13
@@ -1,12 +1,14 @@
|
||||
"""
|
||||
This module provide some advanced function for library parse/download process use.
|
||||
This module provides some advanced function for library parse/download process use.
|
||||
"""
|
||||
import logging
|
||||
import re
|
||||
from copy import deepcopy
|
||||
from enum import StrEnum
|
||||
|
||||
from .library import (convert_maven_version, parse_maven_coordinate, generate_relative_path_by_maven_coordinate,
|
||||
is_complete_maven_url, generate_repo_url)
|
||||
from .library import (convert_maven_version, parse_maven_coordinate, is_complete_maven_url,
|
||||
generate_repo_url, generate_filename_from_maven_coordinate,
|
||||
generate_repo_path)
|
||||
from .version_info import MOJANG_LIBRARIES_ENDPOINT
|
||||
from ..common.exception import VersionDataKeyNotFoundException, DependencyException
|
||||
|
||||
@@ -46,16 +48,18 @@ def generate_unique_library_key(group: str, artifact: str, classifier: str | Non
|
||||
return key
|
||||
|
||||
|
||||
def normalize_library_to_common_struct(library: dict, default_maven_url: str = MOJANG_LIBRARIES_ENDPOINT) -> dict:
|
||||
def normalize_library_to_common_struct(library: dict, default_maven_url: str | None = MOJANG_LIBRARIES_ENDPOINT,
|
||||
default_extension: str = "jar") -> dict:
|
||||
result = deepcopy(library)
|
||||
name: str = library.get("name")
|
||||
name: str | None = library.get("name")
|
||||
|
||||
if name is None:
|
||||
raise VersionDataKeyNotFoundException(
|
||||
"Provided mod loader version manifest library does not contain key \"name\"."
|
||||
)
|
||||
|
||||
group, artifact, version, classifier, extension = parse_maven_coordinate(name)
|
||||
group, artifact, version, classifier, extension = parse_maven_coordinate(name,
|
||||
default_extension=default_extension)
|
||||
|
||||
downloads_raw = result.setdefault("downloads", {})
|
||||
|
||||
@@ -68,15 +72,21 @@ def normalize_library_to_common_struct(library: dict, default_maven_url: str = M
|
||||
|
||||
# Generate new relative path and put back
|
||||
if not artifact_raw.get("path"):
|
||||
path = generate_relative_path_by_maven_coordinate(name)
|
||||
if not path:
|
||||
raise DependencyException(
|
||||
f"Unable to generate artifact path for {name}"
|
||||
)
|
||||
artifact_raw["path"] = path
|
||||
filename = generate_filename_from_maven_coordinate(
|
||||
artifact,
|
||||
version,
|
||||
classifier=classifier,
|
||||
extension=extension,
|
||||
)
|
||||
artifact_raw["path"] = generate_repo_path(
|
||||
group,
|
||||
artifact,
|
||||
version,
|
||||
filename,
|
||||
)
|
||||
|
||||
if not artifact_raw.get("url"):
|
||||
top_level_url = result.get("url")
|
||||
top_level_url: str | None = result.get("url")
|
||||
|
||||
if top_level_url:
|
||||
if is_complete_maven_url(
|
||||
@@ -100,6 +110,11 @@ def normalize_library_to_common_struct(library: dict, default_maven_url: str = M
|
||||
extension,
|
||||
)
|
||||
else:
|
||||
if not default_maven_url:
|
||||
raise DependencyException(
|
||||
f"No download source for library {name!r}."
|
||||
)
|
||||
|
||||
# Generate missing url
|
||||
artifact_raw["url"] = generate_repo_url(
|
||||
default_maven_url,
|
||||
@@ -128,3 +143,92 @@ def normalize_library_to_common_struct(library: dict, default_maven_url: str = M
|
||||
result["downloads"] = downloads
|
||||
|
||||
return result
|
||||
|
||||
class LibraryPreference(StrEnum):
|
||||
HIGHER_VERSION = "higher_version"
|
||||
LOWER_VERSION = "lower_version"
|
||||
MOD_LIBRARY = "mod_library"
|
||||
INHERITS_LIBRARY = "inherits_library"
|
||||
|
||||
|
||||
PREFER_BY_HIGHER_VERSION = LibraryPreference.HIGHER_VERSION
|
||||
PREFER_BY_LOWER_VERSION = LibraryPreference.LOWER_VERSION
|
||||
PREFER_MOD_LIBRARY = LibraryPreference.MOD_LIBRARY
|
||||
PREFER_INHERITS_LIBRARY = LibraryPreference.INHERITS_LIBRARY
|
||||
|
||||
LIBRARY_PREFER_OPTIONS = (PREFER_BY_HIGHER_VERSION, PREFER_BY_LOWER_VERSION, PREFER_MOD_LIBRARY, PREFER_INHERITS_LIBRARY,)
|
||||
|
||||
|
||||
def compare_library_versions(left: str, right: str) -> int:
|
||||
"""
|
||||
Compare two library version string.
|
||||
:param left:
|
||||
:param right:
|
||||
:return:
|
||||
result: -1 if left < right, 0 if left == right, 1 if left > right. If parse failed, throw DependencyException.
|
||||
"""
|
||||
if left == right:
|
||||
return 0
|
||||
|
||||
numeric_version = r"[0-9]+(?:\.[0-9]+)*"
|
||||
|
||||
if not (re.fullmatch(numeric_version, left) and re.fullmatch(numeric_version, right)):
|
||||
raise DependencyException(f"Cannot compare library versions {left!r} and {right!r}."
|
||||
f" Use PREFER_MOD_LIBRARY or PREFER_INHERITS_LIBRARY may solve this issue.")
|
||||
|
||||
left_parts = tuple(map(int, left.split(".")))
|
||||
right_parts = tuple(map(int, right.split(".")))
|
||||
|
||||
length = max(len(left_parts), len(right_parts))
|
||||
left_parts += (0,) * (length - len(left_parts))
|
||||
right_parts += (0,) * (length - len(right_parts))
|
||||
|
||||
return (left_parts > right_parts) - (left_parts < right_parts)
|
||||
|
||||
def deduplicate_libraries(libraries: list[dict], preference: LibraryPreference,
|
||||
default_extension: str = "jar") -> list[dict]:
|
||||
indexed = {}
|
||||
|
||||
preference = LibraryPreference(preference)
|
||||
|
||||
for library in libraries:
|
||||
name: str | None = library.get("name")
|
||||
if not name:
|
||||
raise DependencyException("Library is missing its name.")
|
||||
|
||||
group, artifact, version, classifier, extension = parse_maven_coordinate(name,
|
||||
default_extension=default_extension)
|
||||
key = generate_unique_library_key(
|
||||
group=group,
|
||||
artifact=artifact,
|
||||
classifier=classifier,
|
||||
extension=extension,
|
||||
)
|
||||
|
||||
previous = indexed.get(key)
|
||||
|
||||
if previous is not None:
|
||||
logger.warning(
|
||||
"Duplicate library: %s / %s",
|
||||
previous["name"],
|
||||
name,
|
||||
)
|
||||
|
||||
# Skip/Replace library depend by the library preference
|
||||
if preference in (PREFER_BY_HIGHER_VERSION, PREFER_BY_LOWER_VERSION,):
|
||||
previous_version = parse_maven_coordinate(previous["name"], default_extension=default_extension)[2]
|
||||
|
||||
comparison = compare_library_versions(previous_version, version,)
|
||||
|
||||
keep_previous = (
|
||||
comparison > 0
|
||||
if preference == PREFER_BY_HIGHER_VERSION
|
||||
else comparison < 0
|
||||
)
|
||||
|
||||
if keep_previous:
|
||||
continue
|
||||
|
||||
indexed[key] = library
|
||||
|
||||
return list(indexed.values())
|
||||
+156
-77
@@ -4,13 +4,45 @@ import shlex
|
||||
|
||||
from core_lib.common.exception import VersionDataKeyNotFoundException, DependencyException
|
||||
from core_lib.game.library import parse_maven_coordinate, generate_repo_url, \
|
||||
is_complete_maven_url
|
||||
is_complete_maven_url, filter_platform_libraries
|
||||
from core_lib.game.libraryx import convert_maven_version_with_extra, generate_unique_library_key, \
|
||||
normalize_library_to_common_struct
|
||||
normalize_library_to_common_struct, compare_library_versions, LibraryPreference, PREFER_MOD_LIBRARY, \
|
||||
PREFER_INHERITS_LIBRARY, PREFER_BY_HIGHER_VERSION, deduplicate_libraries
|
||||
from core_lib.game.version_info import MOJANG_LIBRARIES_ENDPOINT
|
||||
|
||||
logger = logging.getLogger("Launcher.CoreLib")
|
||||
|
||||
LOADER_LIBRARY_MARKERS = {
|
||||
("net.fabricmc", "fabric-loader"): "fabric",
|
||||
("org.quiltmc", "quilt-loader"): "quilt",
|
||||
("net.minecraftforge", "forge"): "forge",
|
||||
("net.neoforged", "neoforge"): "neoforge",
|
||||
("net.neoforged", "forge"): "neoforge",
|
||||
}
|
||||
|
||||
|
||||
def detect_loader_name(manifest: dict) -> str | None:
|
||||
candidates = set()
|
||||
|
||||
for library in manifest.get("libraries", []):
|
||||
name = library.get("name", "")
|
||||
parts = name.split(":")
|
||||
|
||||
if len(parts) < 3:
|
||||
continue
|
||||
|
||||
loader_name = LOADER_LIBRARY_MARKERS.get(
|
||||
(parts[0], parts[1])
|
||||
)
|
||||
if loader_name:
|
||||
candidates.add(loader_name)
|
||||
|
||||
# Return None if no loader is found or multiple loaders are found.
|
||||
if len(candidates) != 1:
|
||||
return None
|
||||
|
||||
return next(iter(candidates))
|
||||
|
||||
def find_useful_part_in_mod_version_manifest(mod_version_manifest: dict):
|
||||
ver_id = mod_version_manifest.get("id", None)
|
||||
inherits_from = mod_version_manifest.get("inheritsFrom", None)
|
||||
@@ -61,8 +93,9 @@ def find_useful_part_in_mod_version_manifest(mod_version_manifest: dict):
|
||||
}
|
||||
|
||||
|
||||
def merge_necessary_dependencies(inherits_libraries: list, mod_libraries: list, mod_maven_url=None,
|
||||
inherits_maven_url=MOJANG_LIBRARIES_ENDPOINT, default_extension="jar") -> list[dict]:
|
||||
def merge_necessary_dependencies(inherits_libraries: list, mod_libraries: list, inherits_maven_url=MOJANG_LIBRARIES_ENDPOINT,
|
||||
mod_maven_url=None, default_extension="jar",
|
||||
prefer_libraries_by: LibraryPreference = PREFER_MOD_LIBRARY) -> list[dict]:
|
||||
|
||||
inherits = {}
|
||||
result_pre = []
|
||||
@@ -72,43 +105,70 @@ def merge_necessary_dependencies(inherits_libraries: list, mod_libraries: list,
|
||||
inherits_libraries = deepcopy(inherits_libraries)
|
||||
mod_libraries = deepcopy(mod_libraries)
|
||||
|
||||
def check_lib(lib: dict):
|
||||
url: str = lib.get("url", "")
|
||||
source_from = lib["sourceFrom"]
|
||||
lib_group=lib["parsed"]["group"]
|
||||
lib_artifact=lib["parsed"]["artifact"]
|
||||
lib_version=lib["parsed"]["versionRaw"]
|
||||
lib_classifier=lib["parsed"]["classifier"]
|
||||
lib_extension=lib["parsed"]["extension"]
|
||||
# Filter platform (natives) libraries
|
||||
inherits_libraries = filter_platform_libraries(inherits_libraries)
|
||||
mod_libraries = filter_platform_libraries(mod_libraries)
|
||||
|
||||
recreated = False
|
||||
preference = LibraryPreference(prefer_libraries_by)
|
||||
|
||||
if not url:
|
||||
if source_from == "official":
|
||||
new_url = generate_repo_url(inherits_maven_url, lib_group, lib_artifact, lib_version, lib_classifier,
|
||||
lib_extension)
|
||||
else:
|
||||
new_url = generate_repo_url(mod_maven_url, lib_group, lib_artifact, lib_version, lib_classifier,
|
||||
lib_extension)
|
||||
# Remove duplicate libraries
|
||||
inherits_libraries = deduplicate_libraries(
|
||||
inherits_libraries,
|
||||
preference,
|
||||
default_extension,
|
||||
)
|
||||
mod_libraries = deduplicate_libraries(
|
||||
mod_libraries,
|
||||
preference,
|
||||
default_extension,
|
||||
)
|
||||
|
||||
lib["url"] = new_url
|
||||
|
||||
recreated = True
|
||||
|
||||
if not recreated:
|
||||
url_result = is_complete_maven_url(url, lib_group, lib_artifact, lib_version, lib_classifier, lib_extension)
|
||||
|
||||
if not url_result:
|
||||
# deal with some weird maven url that don't contain repo path
|
||||
# Some mod loader (such as fabric), did not contain a full path inside the library. We will need to
|
||||
# generate it from maven coordinate (aka lib_name)
|
||||
target_maven = mod_maven_url or url
|
||||
repo_url = generate_repo_url(target_maven, lib_group, lib_artifact, lib_version, lib_classifier,
|
||||
lib_extension)
|
||||
lib["url"] = repo_url
|
||||
# def check_lib(lib: dict):
|
||||
# url: str = lib.get("url", "")
|
||||
# source_from = lib["sourceFrom"]
|
||||
# lib_group=lib["parsed"]["group"]
|
||||
# lib_artifact=lib["parsed"]["artifact"]
|
||||
# lib_version=lib["parsed"]["versionRaw"]
|
||||
# lib_classifier=lib["parsed"]["classifier"]
|
||||
# lib_extension=lib["parsed"]["extension"]
|
||||
# lib_downloads = lib["downloads"]
|
||||
#
|
||||
# recreated = False
|
||||
#
|
||||
# if not url:
|
||||
# artifact_url = lib_downloads.get("artifact", {}).get("url", "")
|
||||
# is_completed = is_complete_maven_url(artifact_url, lib_group, lib_artifact, lib_version, lib_classifier, lib_extension)
|
||||
#
|
||||
# if is_completed:
|
||||
# lib["url"] = artifact_url
|
||||
# else:
|
||||
# if source_from == "official":
|
||||
# new_url = generate_repo_url(inherits_maven_url, lib_group, lib_artifact, lib_version,
|
||||
# lib_classifier,
|
||||
# lib_extension)
|
||||
# else:
|
||||
# new_url = generate_repo_url(mod_maven_url, lib_group, lib_artifact, lib_version, lib_classifier,
|
||||
# lib_extension)
|
||||
#
|
||||
# lib["url"] = new_url
|
||||
#
|
||||
# recreated = True
|
||||
#
|
||||
# if not recreated:
|
||||
# url_result = is_complete_maven_url(url, lib_group, lib_artifact, lib_version, lib_classifier, lib_extension)
|
||||
#
|
||||
# if not url_result:
|
||||
# # deal with some weird maven url that don't contain srepo path
|
||||
# # Some mod loader (such as fabric), did not contain a full path inside the library. We will need to
|
||||
# # generate it from maven coordinate (aka lib_name)
|
||||
# target_maven = url or mod_maven_url
|
||||
# repo_url = generate_repo_url(target_maven, lib_group, lib_artifact, lib_version, lib_classifier,
|
||||
# lib_extension)
|
||||
# lib["url"] = repo_url
|
||||
|
||||
for library in inherits_libraries:
|
||||
name = library.get("name", None)
|
||||
name: str | None = library.get("name", None)
|
||||
downloads = library.get("downloads", {})
|
||||
|
||||
if not name:
|
||||
raise DependencyException(
|
||||
@@ -116,15 +176,16 @@ def merge_necessary_dependencies(inherits_libraries: list, mod_libraries: list,
|
||||
)
|
||||
|
||||
group, artifact, version_raw, classifier, extension = parse_maven_coordinate(name, default_extension=default_extension)
|
||||
ver_converted, extra = convert_maven_version_with_extra(version_raw)
|
||||
|
||||
if extra:
|
||||
logger.debug("Found extra version \"{}\" for library {}".format(extra, name))
|
||||
|
||||
if not ver_converted:
|
||||
raise DependencyException(
|
||||
f"Unable to convert provided inherited library name {name}'s version {version_raw} to tuple."
|
||||
)
|
||||
# ver_converted, extra = convert_maven_version_with_extra(version_raw)
|
||||
#
|
||||
# if extra:
|
||||
# logger.debug("Found extra version \"{}\" for library {}".format(extra, name))
|
||||
#
|
||||
# if not ver_converted:
|
||||
# raise DependencyException(
|
||||
# f"Unable to convert provided inherited library name {name}'s version {version_raw} to tuple."
|
||||
# )
|
||||
|
||||
lib_key = generate_unique_library_key(
|
||||
group=group,
|
||||
@@ -139,12 +200,12 @@ def merge_necessary_dependencies(inherits_libraries: list, mod_libraries: list,
|
||||
inherits[lib_key]["parsed"] = {
|
||||
"group": group,
|
||||
"artifact": artifact,
|
||||
"version": ver_converted,
|
||||
"version": version_raw,
|
||||
"versionRaw": version_raw,
|
||||
"versionExtra": extra,
|
||||
"classifier": classifier,
|
||||
"extension": extension,
|
||||
"endpoint": inherits_maven_url
|
||||
"endpoint": inherits_maven_url,
|
||||
"downloads": downloads,
|
||||
}
|
||||
inherits[lib_key]["sourceFrom"] = "official"
|
||||
else:
|
||||
@@ -152,23 +213,22 @@ def merge_necessary_dependencies(inherits_libraries: list, mod_libraries: list,
|
||||
|
||||
for mod_library in mod_libraries:
|
||||
name = mod_library.get("name", None)
|
||||
downloads = mod_library.get("downloads", {})
|
||||
|
||||
if not name:
|
||||
raise DependencyException(
|
||||
"Provided mod library does not contain key \"name\"."
|
||||
)
|
||||
|
||||
group, artifact, version_raw, classifier, extension = parse_maven_coordinate(name, default_extension=default_extension)
|
||||
|
||||
ver_converted, extra = convert_maven_version_with_extra(version_raw)
|
||||
|
||||
if extra:
|
||||
logger.debug("Found extra version \"{}\" for library {}".format(extra, name))
|
||||
|
||||
if ver_converted is None:
|
||||
raise DependencyException(
|
||||
"Unable to convert mod library version {} to tuple".format(version_raw),
|
||||
)
|
||||
# ver_converted, extra = convert_maven_version_with_extra(version_raw)
|
||||
#
|
||||
# if extra:
|
||||
# logger.debug("Found extra version \"{}\" for library {}".format(extra, name))
|
||||
#
|
||||
# if ver_converted is None:
|
||||
# raise DependencyException(
|
||||
# "Unable to convert mod library version {} to tuple".format(version_raw),
|
||||
# )
|
||||
|
||||
group, artifact, version_raw, classifier, extension = parse_maven_coordinate(name, default_extension=default_extension)
|
||||
lib_key = generate_unique_library_key(
|
||||
@@ -183,34 +243,37 @@ def merge_necessary_dependencies(inherits_libraries: list, mod_libraries: list,
|
||||
"group": group,
|
||||
"artifact": artifact,
|
||||
# "version": {"raw": version, "converted": ver_converted, "extra": extra},
|
||||
"version": ver_converted,
|
||||
"version": version_raw,
|
||||
"versionRaw": version_raw,
|
||||
"versionExtra": extra,
|
||||
"classifier": classifier,
|
||||
"extension": extension,
|
||||
"endpoint": mod_maven_url,
|
||||
"downloads": downloads,
|
||||
}
|
||||
|
||||
if lib_key in inherits:
|
||||
found_lib = inherits.pop(lib_key)
|
||||
found_lib_ver = found_lib["parsed"]["version"]
|
||||
found_lib_ver_extra = found_lib["parsed"]["versionExtra"]
|
||||
|
||||
if found_lib_ver is None:
|
||||
raise DependencyException(
|
||||
"Unable to convert mod library version {} to tuple".format(found_lib["versionRaw"])
|
||||
)
|
||||
|
||||
if found_lib_ver > ver_converted:
|
||||
result_pre.append(found_lib)
|
||||
elif found_lib_ver < ver_converted:
|
||||
result_pre.append(mod_library)
|
||||
if preference in (PREFER_MOD_LIBRARY, PREFER_INHERITS_LIBRARY,):
|
||||
selected = mod_library if preference == PREFER_MOD_LIBRARY else found_lib
|
||||
else:
|
||||
# Use mod loader library if extra version is existing
|
||||
if found_lib_ver_extra == mod_library["parsed"]["versionExtra"]:
|
||||
result_pre.append(found_lib)
|
||||
else:
|
||||
result_pre.append(mod_library)
|
||||
comparison = compare_library_versions(
|
||||
found_lib["parsed"]["versionRaw"],
|
||||
mod_library["parsed"]["versionRaw"],
|
||||
)
|
||||
|
||||
if preference == PREFER_BY_HIGHER_VERSION:
|
||||
selected = found_lib if comparison > 0 else mod_library
|
||||
else: # PREFER_BY_LOWER_VERSION
|
||||
selected = found_lib if comparison < 0 else mod_library
|
||||
|
||||
result_pre.append(selected)
|
||||
else:
|
||||
result_pre.append(mod_library)
|
||||
|
||||
@@ -220,13 +283,24 @@ def merge_necessary_dependencies(inherits_libraries: list, mod_libraries: list,
|
||||
result_pre.append(value)
|
||||
|
||||
for library in result_pre:
|
||||
# Cleanup
|
||||
check_lib(library)
|
||||
library_normalized = normalize_library_to_common_struct(library, default_maven_url=library["parsed"]["endpoint"])
|
||||
# Check library download url
|
||||
endpoint = library["parsed"]["endpoint"] # maven url
|
||||
artifact_url = ((library.get("downloads") or {}).get("artifact") or {}).get("url")
|
||||
|
||||
if not artifact_url and not library.get("url") and not endpoint:
|
||||
raise DependencyException(
|
||||
f"No download source for library {library['name']!r}."
|
||||
)
|
||||
|
||||
library_normalized = normalize_library_to_common_struct(
|
||||
library,
|
||||
default_maven_url=endpoint,
|
||||
default_extension=default_extension
|
||||
)
|
||||
|
||||
# Cleanup and append
|
||||
library_normalized.pop("parsed", None)
|
||||
library_normalized.pop("sourceFrom", None)
|
||||
library_normalized.pop("endpoint", None)
|
||||
result.append(library_normalized)
|
||||
|
||||
return result
|
||||
@@ -262,7 +336,8 @@ def merge_game_and_jvm_args(inherits_args: dict[str, list[str]] | str, mod_args:
|
||||
|
||||
return merged
|
||||
|
||||
def merge_manifest(inherits_version_manifest: dict, mod_version_manifest: dict, mod_maven_url=None) -> dict:
|
||||
def merge_manifest(inherits_version_manifest: dict, mod_version_manifest: dict, mod_maven_url=None,
|
||||
*, prefer_libraries_by: LibraryPreference = PREFER_MOD_LIBRARY) -> dict:
|
||||
merged_manifest = deepcopy(inherits_version_manifest)
|
||||
|
||||
# main class
|
||||
@@ -281,8 +356,12 @@ def merge_manifest(inherits_version_manifest: dict, mod_version_manifest: dict,
|
||||
"Inherited (or mod) version manifest does not contain key \"libraries\"."
|
||||
)
|
||||
|
||||
merged_manifest["libraries"] = merge_necessary_dependencies(inherits_libraries, mod_libraries,
|
||||
mod_maven_url=mod_maven_url)
|
||||
merged_manifest["libraries"] = merge_necessary_dependencies(
|
||||
inherits_libraries,
|
||||
mod_libraries,
|
||||
mod_maven_url=mod_maven_url,
|
||||
prefer_libraries_by=prefer_libraries_by
|
||||
)
|
||||
|
||||
# arguments
|
||||
inherits_arguments = inherits_version_manifest.get("arguments", []) or inherits_version_manifest.get("minecraftArguments", "")
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
from core_lib.game.mod.mod_core import PREFER_MOD_LIBRARY
|
||||
|
||||
MOD_LOADER_RULES = {
|
||||
"fabric": {
|
||||
"preferLibraryBy": PREFER_MOD_LIBRARY,
|
||||
},
|
||||
"forge": {
|
||||
"preferLibraryBy": PREFER_MOD_LIBRARY,
|
||||
},
|
||||
"neoforge": {
|
||||
"preferLibraryBy": PREFER_MOD_LIBRARY,
|
||||
},
|
||||
"quilt": {
|
||||
"preferLibraryBy": PREFER_MOD_LIBRARY,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user