diff options
| author | DioEgizio <83089242+DioEgizio@users.noreply.github.com> | 2025-12-22 16:40:10 +0100 |
|---|---|---|
| committer | DioEgizio <83089242+DioEgizio@users.noreply.github.com> | 2025-12-22 17:14:51 +0100 |
| commit | b640188e1f14bb5b04201875bb08df35c5443e01 (patch) | |
| tree | 50e4c8be5a1bada5fdd1a99796adbc728122df49 /meta | |
| parent | c857d1c5f64638a37f4685519cdc9f9bf54ae8de (diff) | |
| download | Project-Tick-b640188e1f14bb5b04201875bb08df35c5443e01.tar.gz Project-Tick-b640188e1f14bb5b04201875bb08df35c5443e01.zip | |
feat+fix: get minecraft version from profile json instead of regex
makes the code less sus and makes meta generate for new neoforge versions
Signed-off-by: DioEgizio <83089242+DioEgizio@users.noreply.github.com>
Diffstat (limited to 'meta')
| -rw-r--r-- | meta/model/neoforge.py | 9 | ||||
| -rw-r--r-- | meta/run/generate_neoforge.py | 32 | ||||
| -rw-r--r-- | meta/run/update_neoforge.py | 48 |
3 files changed, 22 insertions, 67 deletions
diff --git a/meta/model/neoforge.py b/meta/model/neoforge.py index 5f5237fa5f..53bf67ba43 100644 --- a/meta/model/neoforge.py +++ b/meta/model/neoforge.py @@ -31,10 +31,7 @@ class NeoForgeFile(MetaBase): class NeoForgeEntry(MetaBase): artifact: str long_version: str = Field(alias="longversion") - mc_version: str = Field(alias="mcversion") version: str - build: int - branch: Optional[str] latest: Optional[bool] recommended: Optional[bool] files: Optional[Dict[str, NeoForgeFile]] @@ -48,8 +45,6 @@ class NeoForgeMCVersionInfo(MetaBase): class DerivedNeoForgeIndex(MetaBase): versions: Dict[str, NeoForgeEntry] = Field({}) - by_mc_version: Dict[str, NeoForgeMCVersionInfo] = Field({}, alias="by_mcversion") - class FMLLib( MetaBase @@ -181,14 +176,10 @@ class InstallerInfo(MetaBase): class NeoForgeVersion: def __init__(self, entry: NeoForgeEntry): self.artifact = entry.artifact - self.build = entry.build self.rawVersion = entry.version if self.artifact == "neoforge": self.rawVersion = entry.long_version - self.mc_version = entry.mc_version - self.mc_version_sane = self.mc_version.replace("_pre", "-pre", 1) - self.branch = entry.branch self.installer_filename = None self.installer_url = None self.universal_filename = None diff --git a/meta/run/generate_neoforge.py b/meta/run/generate_neoforge.py index 6937ab01ba..41ac950b7d 100644 --- a/meta/run/generate_neoforge.py +++ b/meta/run/generate_neoforge.py @@ -48,7 +48,6 @@ def version_from_build_system_installer( version: NeoForgeVersion, ) -> MetaVersion: v = MetaVersion(name="NeoForge", version=version.rawVersion, uid=NEOFORGE_COMPONENT) - v.requires = [Dependency(uid=MINECRAFT_COMPONENT, equals=version.mc_version_sane)] v.main_class = "io.github.zekerzhayard.forgewrapper.installer.Main" # FIXME: Add the size and hash here @@ -108,10 +107,6 @@ def main(): recommended_versions = [] for key, entry in remote_versions.versions.items(): - if entry.mc_version is None: - eprint("Skipping %s with invalid MC version" % key) - continue - version = NeoForgeVersion(entry) if version.url() is None: @@ -134,18 +129,6 @@ def main(): if entry.recommended: recommended_versions.append(version.rawVersion) - # If we do not have the corresponding Minecraft version, we ignore it - if not os.path.isfile( - os.path.join( - LAUNCHER_DIR, MINECRAFT_COMPONENT, f"{version.mc_version_sane}.json" - ) - ): - eprint( - "Skipping %s with no corresponding Minecraft version %s" - % (key, version.mc_version_sane) - ) - continue - # Path for new-style build system based installers installer_version_filepath = os.path.join( UPSTREAM_DIR, VERSION_MANIFEST_DIR, f"{version.long_version}.json" @@ -161,7 +144,20 @@ def main(): installer = MojangVersion.parse_file(installer_version_filepath) profile = NeoForgeInstallerProfileV2.parse_file(profile_filepath) v = version_from_build_system_installer(installer, profile, version) - + + #we can get the minecraft version from the profile json info, so let's just do that instead of hacky regex + v.requires = [Dependency(uid=MINECRAFT_COMPONENT, equals=profile.minecraft)] + # If we do not have the corresponding Minecraft version, we ignore it + if not os.path.isfile( + os.path.join( + LAUNCHER_DIR, MINECRAFT_COMPONENT, f"{profile.minecraft}.json" + ) + ): + eprint( + "Skipping %s with no corresponding Minecraft version %s" + % (key, profile.minecraft) + ) + continue v.write(os.path.join(LAUNCHER_DIR, NEOFORGE_COMPONENT, f"{v.version}.json")) recommended_versions.sort() diff --git a/meta/run/update_neoforge.py b/meta/run/update_neoforge.py index 1cf3a29b60..24a0da017e 100644 --- a/meta/run/update_neoforge.py +++ b/meta/run/update_neoforge.py @@ -140,43 +140,24 @@ def main(): new_index = DerivedNeoForgeIndex() + #let's keep the regex here to remove the 1.20.1- version_expression = re.compile( r"^(?P<mc>[0-9a-zA-Z_\.]+)-(?P<ver>[0-9\.]+\.(?P<build>[0-9]+))(-(?P<branch>[a-zA-Z0-9\.]+))?$" ) - neoforge_version_re = re.compile( - r"^(?P<mcminor>\d+).(?:(?P<mcpatch>\d+)|(?P<snapshot>[0-9a-z]+)).(?P<number>\d+)(?:-(?P<tag>\w+))?$" - ) print("") print("Processing versions:") for long_version in main_json: assert type(long_version) == str - match = version_expression.match(long_version) - if match: - mc_version = match.group("mc") - build = int(match.group("build")) - version = match.group("ver") - branch = match.group("branch") + legacyMatch = version_expression.match(long_version) + if legacyMatch: + version = legacyMatch.group("ver") artifact = "forge" - - match_nf = neoforge_version_re.match(long_version) - if match_nf: - mc_version = match_nf.group("snapshot") - if not mc_version: - mc_version = f"1.{match_nf.group('mcminor')}" - if match_nf.group("mcpatch") != "0": - mc_version += f".{match_nf.group('mcpatch')}" - build = int(match_nf.group("number")) - version = match_nf.group("number") - branch = match_nf.group("tag") - match = match_nf + else: + version = long_version artifact = "neoforge" - if not match and not match_nf: - print(f"Skipping {long_version} as it does not match regex") - continue - try: files = get_single_forge_files_manifest(long_version, artifact) except: @@ -188,26 +169,16 @@ def main(): entry = NeoForgeEntry( artifact=artifact, long_version=long_version, - mc_version=mc_version, version=version, - build=build, - branch=branch, # NOTE: we add this later after the fact. The forge promotions file lies about these. latest=False, recommended=is_recommended, files=files, ) new_index.versions[long_version] = entry - if not new_index.by_mc_version: - new_index.by_mc_version = dict() - if mc_version not in new_index.by_mc_version: - new_index.by_mc_version.setdefault(mc_version, NeoForgeMCVersionInfo()) - new_index.by_mc_version[mc_version].versions.append(long_version) - # NOTE: we add this later after the fact. The forge promotions file lies about these. - # if entry.latest: - # new_index.by_mc_version[mc_version].latest = long_version + if entry.recommended: - new_index.by_mc_version[mc_version].recommended = long_version + new_index.recommended = long_version print("") print("Dumping index files...") @@ -223,9 +194,6 @@ def main(): # get the installer jars - if needed - and get the installer profiles out of them for key, entry in new_index.versions.items(): eprint("Updating NeoForge %s" % key) - if entry.mc_version is None: - eprint("Skipping %d with invalid MC version" % entry.build) - continue version = NeoForgeVersion(entry) if version.url() is None: |
