diff --git a/flake.nix b/flake.nix index 55c8d2a..fba329c 100644 --- a/flake.nix +++ b/flake.nix @@ -90,7 +90,22 @@ in { devShell = with pkgs; mkShell { - buildInputs = [ nixfmt git-lfs ]; + buildInputs = [ + nixfmt + git-lfs + + # For the minecraft mod update script + (python3.withPackages (pypkgs: + with pypkgs; [ + requests + + ipython + python-language-server + pyls-black + pyls-isort + pyls-mypy + ])) + ]; shellHook = '' export QEMU_OPTS="-m 3941 -smp 2 -curses" export QEMU_NET_OPTS="hostfwd=::3022-:2222,hostfwd=::3080-:80,hostfwd=::3443-:443,hostfwd=::3021-:2221,hostfwd=::25565-:25565" diff --git a/lib/minecraft.nix b/lib/minecraft.nix index 87d5402..ef50b3d 100644 --- a/lib/minecraft.nix +++ b/lib/minecraft.nix @@ -27,4 +27,25 @@ cp * $out/mods ''; }; + + mkModpackZip = { name, version, mods }: + pkgs.stdenv.mkDerivation { + inherit name version; + srcs = map pkgs.local.fetchFromCurseForge mods; + + sourceRoot = "src/"; + preUnpack = "mkdir -p src/"; + unpackCmd = "cp $curSrc src/"; + + buildInputs = [ pkgs.zip]; + + buildPhase = '' + zip voor-kia-mods.zip *.jar + ''; + + installPhase = '' + mkdir -p $out/ + cp voor-kia-mods.zip $out/ + ''; + }; } diff --git a/pkgs/build-support/fetchFromCurseForge.nix b/pkgs/build-support/fetchFromCurseForge.nix index 4fde62e..e3e5b51 100644 --- a/pkgs/build-support/fetchFromCurseForge.nix +++ b/pkgs/build-support/fetchFromCurseForge.nix @@ -10,14 +10,17 @@ let # # Note that if it's zero-prefixed we need to remove the zeroes. It's # really an odd one... - a = head (match "0*([[:digit:]]+)" (substring 0 4 id)); - b = head (match "0*([[:digit:]]+)" (substring 4 7 id)); + a = head (match "0*([[:digit:]]+)" (substring 0 4 (toString id))); + b = head (match "0*([[:digit:]]+)" (substring 4 7 (toString id))); + encoded-filename = replaceStrings [ " " ] [ "%20" ] filename; - url = "https://media.forgecdn.net/files/${a}/${b}/${filename}"; - otherArgs = removeAttrs args [ "project" "id" "filename" ]; + url = "https://media.forgecdn.net/files/${a}/${b}/${encoded-filename}"; + otherArgs = removeAttrs args [ "project" "project_id" "id" "filename" ]; in fetchurl (otherArgs // { inherit url; # Rename files to avoid names incompatible with the nix store name = "${project}.jar"; + # Avoid accidental URL globbing + curlOpts = "--globoff"; }) diff --git a/pkgs/default.nix b/pkgs/default.nix index 0748ae6..88a0112 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -12,4 +12,5 @@ in { # Minecraft modpacks voor-kia = callPackage ./minecraft/voor-kia.nix { }; + voor-kia-client = callPackage ./minecraft/voor-kia-client.nix { }; } diff --git a/pkgs/minecraft/forge-server.nix b/pkgs/minecraft/forge-server.nix index d91c5e6..22df91f 100644 --- a/pkgs/minecraft/forge-server.nix +++ b/pkgs/minecraft/forge-server.nix @@ -3,12 +3,12 @@ let name = "forge-server"; - version = "1.16.5-36.1.65"; + version = "1.16.5-36.2.2"; mirror = "https://files.minecraftforge.net/maven/net/minecraftforge/forge"; src = fetchurl { url = "${mirror}/${version}/forge-${version}-installer.jar"; # Forge doesn't seem to like newer shas - sha1 = "9aedcd5e64bfc12483b9c51bc4cf18e551ad054a"; + sha1 = "e97821e5431bdcaa46e12048769922e2cdb5e2e1"; }; unpackCmd = "mkdir -p src; cp $curSrc src/forge-${version}-installer.jar"; @@ -40,7 +40,7 @@ let outputHashAlgo = "sha256"; outputHashMode = "recursive"; - outputHash = "lHAuKgwD2gzTb+n3pLgpXsDGYSLF/EYlGy0TfCoU5uQ="; + outputHash = "VuUGc5JnzcRhDt9aaGrU+yUrJILVdU2vzv1PxLwdAig="; }; in stdenv.mkDerivation rec { diff --git a/pkgs/minecraft/voor-kia-client.nix b/pkgs/minecraft/voor-kia-client.nix new file mode 100644 index 0000000..8d0c687 --- /dev/null +++ b/pkgs/minecraft/voor-kia-client.nix @@ -0,0 +1,8 @@ +{ lib, local-lib, stdenv }: + +local-lib.minecraft.mkModpackZip { + name = "voor-kia-client"; + version = "1.1"; + mods = (builtins.fromJSON (builtins.readFile ./voor-kia/mods.json)) + ++ (builtins.fromJSON (builtins.readFile ./voor-kia/client-mods.json)); +} diff --git a/pkgs/minecraft/voor-kia/client-mods.json b/pkgs/minecraft/voor-kia/client-mods.json new file mode 100644 index 0000000..960f7ab --- /dev/null +++ b/pkgs/minecraft/voor-kia/client-mods.json @@ -0,0 +1,86 @@ +[ + { + "filename": "AmbientSounds_v3.1.9_mc1.16.5.jar", + "id": 3334857, + "project": "ambientsounds", + "project_id": 254284, + "sha256": "c8ed21587fe96745695aa9a8f23b6effbcc6a5c5340aed11b8515c0e0aa2c310" + }, + { + "filename": "BackTools-1.16.5-10.1.0.jar", + "id": 3224955, + "project": "back-tools", + "project_id": 229061, + "sha256": "cd5ed82919dd8acf2874c7edadba5bacfaffa898e572f8574241329e4478518e" + }, + { + "filename": "BetterAdvancements-1.16.5-0.1.1.111.jar", + "id": 3400299, + "project": "better-advancements", + "project_id": 272515, + "sha256": "83c159f83bebc1d0f72c9de465bdcbeb2b02a56b88dcaa6661fe54df50a9aab5" + }, + { + "filename": "Controlling-7.0.0.23.jar", + "id": 3348514, + "project": "controlling", + "project_id": 250398, + "sha256": "627308ed0b4fc1fdcc75113db8412c0684c3a774d1c6a07ae993543e605f5655" + }, + { + "filename": "EntityCulling-1.16.5-2.1.6.jar", + "id": 3328602, + "project": "entity-culling", + "project_id": 409087, + "sha256": "eede3bfc68f48acb3e06fec2ea280510287cd5d492a02b8ace8e0dda742d7342" + }, + { + "filename": "ftb-library-forge-1605.3.1-build.48.jar", + "id": 3373833, + "project": "ftb-library-forge", + "project_id": 404465, + "sha256": "f4f87f464796ee6ff7c80fb1fbc5753ac191138b6aa6b1a30c1b55252b3bf0a8" + }, + { + "filename": "InventoryHud_[1.16.2-1.16.5].forge-3.3.0.jar", + "id": 3296748, + "project": "inventory-hud-forge", + "project_id": 357540, + "sha256": "2b3a4f02fe84b717c9273ea14cea0912267c2c093fc2cdfcde2b6f032c9762e7" + }, + { + "filename": "MouseTweaks-2.14-mc1.16.2.jar", + "id": 3202662, + "project": "mouse-tweaks", + "project_id": 60089, + "sha256": "9d7e1aaee9f814c26d896e084e6e86930ab99e19fe547a1d350a6e25e4267092" + }, + { + "filename": "namepain-1.4.0 forge-1.16.x.jar", + "id": 3356725, + "project": "name-pain", + "project_id": 366263, + "sha256": "5cc9e83b6d06810cbfcc155ddcfbe417cd4553a2665025affd1b71bee0138f68" + }, + { + "filename": "overloadedarmorbar-5.1.0.jar", + "id": 3055679, + "project": "overloaded-armor-bar", + "project_id": 314002, + "sha256": "8aff59f170ef2c7598dc0f2367842f4384e57c13111507468da32498fc0ac4ea" + }, + { + "filename": "shutupexperimentalsettings-1.0.3.jar", + "id": 3188120, + "project": "shutup-experimental-settings", + "project_id": 407174, + "sha256": "22ce84a0d424c2d48e483cb873909ac5c8c322bc793d09365ad44b901f43de62" + }, + { + "filename": "Toast-Control-1.16.4-4.3.1.jar", + "id": 3172881, + "project": "toast-control", + "project_id": 271740, + "sha256": "b1cb36b7615c846f08c72423b2b52417b55eea91ca812bb7629a8f3060f5efae" + } +] \ No newline at end of file diff --git a/pkgs/minecraft/voor-kia/mods.json b/pkgs/minecraft/voor-kia/mods.json index db5efa7..96d0231 100644 --- a/pkgs/minecraft/voor-kia/mods.json +++ b/pkgs/minecraft/voor-kia/mods.json @@ -1,512 +1,625 @@ [ { - "project": "ai-improvements", - "id": "3031978", "filename": "AI-Improvements-1.16.2-0.3.0.jar", + "id": 3031978, + "project": "ai-improvements", + "project_id": 233019, "sha256": "47526292ea2f11dd18a8da8863b40ba81a93601f03aa4abcc742ac62ea599c69" }, { + "filename": "alexsmobs-1.11.1.jar", + "id": 3371504, "project": "alexs-mobs", - "id": "3230693", - "filename": "alexsmobs-1.7.1.jar", - "sha256": "e8066d512f53b80a796e5b83db27246aa5fe4b055929475e7efe5ff6dd090f42" + "project_id": 426558, + "sha256": "4daf19a04317c5a399d38c2c397ead8cce9a9eb6c09fdb5bd7bd6dec8c911167" }, { + "filename": "Apotheosis-1.16.4-4.6.1.jar", + "id": 3332235, "project": "apotheosis", - "id": "3095843", - "filename": "Apotheosis-1.16.3-4.4.1.jar", - "sha256": "de5ed7501bc17196cca7bddabace3464cbdbf8afba63385d260804ad013ba836" + "project_id": 313970, + "sha256": "a15e9faf743d237063221c0d9ab0b75acf86ba5c3bfde08a42922c3b108bca80" }, { + "filename": "appleskin-forge-mc1.16.x-2.1.0.jar", + "id": 3395800, "project": "appleskin", - "id": "3035787", - "filename": "AppleSkin-mc1.16.2-forge-1.0.14.jar", - "sha256": "e0d39f6b138e853d6171bd51fa158545d68cab5e718a01feb919d37964e5eb4f" + "project_id": 248787, + "sha256": "d98f34b1a97a66ea5e33eda7e744f1382d325c7de51db57285d1a0888c0e8496" }, { + "filename": "architectury-1.20.28-forge.jar", + "id": 3385660, "project": "architectury-forge", - "id": "3208686", - "filename": "architectury-1.7.117-forge.jar", - "sha256": "6cdbdb32b958ca5cec46c92eaa3c5d2c33404b20f5080bc7c612ba7e3fa4bf57" + "project_id": 419699, + "sha256": "0a89b6a6d12596bf288411fd740cbc44f3fe63c3f4665f7fd3f46f65f52cf138" }, { + "filename": "Artifacts-1.16.5-2.10.0.jar", + "id": 3374317, "project": "artifacts", - "id": "3208854", - "filename": "Artifacts-1.16.5-2.8.1.jar", - "sha256": "6c74163a75a2303b3fce04c098efad6de0c345059e279a7e5858a1200779d423" + "project_id": 312353, + "sha256": "70e2945f8200f7ad3cb46436a998acd37ebec318d08e7a578ca39e8115414b1c" }, { + "filename": "AttributeFix-1.16.5-10.1.3.jar", + "id": 3348562, "project": "attributefix", - "id": "3170246", - "filename": "AttributeFix-1.16.5-10.0.1.jar", - "sha256": "8492d282ca55c1e01fad6fd4ae8bd66e418128ccf9044a150af7b4526e02d906" + "project_id": 280510, + "sha256": "aabf99d65e4ccfc08a67dc378f447eef613ac50924587a33aef68d4467e1a7c0" }, { + "filename": "AutoRegLib-1.6-49.jar", + "id": 3326041, "project": "autoreglib", - "id": "3128555", - "filename": "AutoRegLib-1.6-47.jar", - "sha256": "bacb22ec651ca70462e0128d6e6e800cee69b125cd078b9cf6d3a45de3e403fc" + "project_id": 250363, + "sha256": "2760b765dccf1fad36e74f747ee9b1a2923e2d09eb281c72258c15bb4ed427d5" }, { + "filename": "bedspreads-forge-1.16.5-5.1.0.2.jar", + "id": 3258439, "project": "bedspreads", - "id": "3118466", - "filename": "bedspreads-forge-1.16.4-5.1.0.1.jar", - "sha256": "7844407085109d10ba87faf21816fb89fc411ff82ea7f0b761e2bd4f987987d2" + "project_id": 308653, + "sha256": "fa823abf9efef6818079d1c0cf123e9edccdac81fddf09b2ef931f21f4c58e9d" }, { + "filename": "BetterBurning-1.16.5-6.0.7.jar", + "id": 3348573, "project": "better-burning", - "id": "3181436", - "filename": "BetterBurning-1.16.5-6.0.2.jar", - "sha256": "e81297506876a623e9e770222d6c053eb33ac5451a3905454c2befd69115ae19" + "project_id": 353434, + "sha256": "4b089ce99e48cf72bf817cbc26a0e23b297b5b451bbd80b46091cd5a290524ff" }, { + "filename": "BetterCaves-Forge-1.16.4-1.1.2.jar", + "id": 3307879, "project": "yungs-better-caves", - "id": "3170047", - "filename": "BetterCaves-Forge-1.16.4-1.1.1.jar", - "sha256": "f5bc8ba0f46acab08e79f95e8ff980b2629fd678ea25e9068d2d96823c1ba983" + "project_id": 340583, + "sha256": "5182379427440bb4198790856c01f28c085365cc37ad3a05a9cd82dfdf068454" }, { + "filename": "BetterMineshafts-Forge-1.16.4-2.0.4.jar", + "id": 3344719, "project": "yungs-better-mineshafts-forge", - "id": "3175671", - "filename": "BetterMineshafts-Forge-1.16.4-2.0.1.jar", - "sha256": "a640f45962f8a1abc60f83c8632e558b541b6ba0238d6297912814dec2d0bdc7" + "project_id": 389665, + "sha256": "19b9b7f87da2bb76574e9f3e3d18d445189a4627cfd0d8188ae88eb681b578b8" }, { + "filename": "BetterPortals-1.16.4-0.3.7.jar", + "id": 3396844, "project": "yungs-better-portals", - "id": "3221299", - "filename": "BetterPortals-1.16.4-0.3.1.jar", - "sha256": "a86ddf3cbc066d15562e4136717d061861dfb77a2da7b4f112a2b290073c47d9" + "project_id": 443723, + "sha256": "4695da7e9212d79c9fc8350e9b4ec2600631ff858ee10d146d4a69f20dfc9c6e" }, { + "filename": "Bookshelf-1.16.5-10.2.15.jar", + "id": 3402183, "project": "bookshelf", - "id": "3170154", - "filename": "Bookshelf-1.16.5-10.0.1.jar", - "sha256": "33bade36884a25cbf3bac3bdd2e762a2c5fcc1840f613ab5aaaf57642ffc0c68" + "project_id": 228525, + "sha256": "0674174797835d3371d1421cbf6232276451edca0b6f16b85bb3519e65622ea4" }, { - "project": "bad-wither-no-cookie-reloaded", - "id": "3101531", "filename": "bwncr-1.16.4-3.9.16.jar", + "id": 3101531, + "project": "bad-wither-no-cookie-reloaded", + "project_id": 261251, "sha256": "91c4df24466b958d36d41ce886e5d8b0839a07b73d58248a0dcb84a67279b81f" }, { + "filename": "byg-1.2.9.jar", + "id": 3337158, "project": "oh-the-biomes-youll-go", - "id": "3197729", - "filename": "byg-1.1.10.jar", - "sha256": "28db347d22ea27167cdbf107180b01b53003d98739189a66ef6c1e4f21e4b436" + "project_id": 247560, + "sha256": "13007c914d142b4e19f92213970edf22094ad9f48e1e7e7c27e1355eb7248086" }, { - "project": "callable-horses", - "id": "3090832", "filename": "callablehorses-1.16.3-1.2.1.4.jar", + "id": 3090832, + "project": "callable-horses", + "project_id": 331746, "sha256": "639778fd58667aa560d333a2490352e34c1c32e897d9f8204e52df305ca5e879" }, { + "filename": "citadel-1.7.1-1.16.5.jar", + "id": 3346836, "project": "citadel", - "id": "3198842", - "filename": "citadel-1.6.1.jar", - "sha256": "e13434097199a926a565a109b5c7b82b5e0308efa88dbc2a4d030d78d8f1ac37" + "project_id": 331936, + "sha256": "2977c084dcbd23c4fa1ea00ea152f1792b38781eff8f0234de4d67b1ee35b849" }, { + "filename": "cloth-config-4.11.26-forge.jar", + "id": 3311352, "project": "cloth-config-forge", - "id": "3203817", - "filename": "cloth-config-4.10.13-forge.jar", - "sha256": "d47bf12ed961fac529064254931308d1ca20d08f411718563827141175daf32b" + "project_id": 348521, + "sha256": "815ba5d61416d9bbd53b830509b9f3d74d59c1720cf9a6b002a3e66eb1453196" }, { + "filename": "Clumps-6.0.0.25.jar", + "id": 3348509, "project": "clumps", - "id": "3205705", - "filename": "Clumps-6.0.0.17.jar", - "sha256": "a9535cf8df267bb2e2ffb46a278aa67f4b6e447d0bc1140205f98257dc108d58" + "project_id": 256717, + "sha256": "1039d9ae78873107ee82c799e586c71dfe284d5bb58f89895a3a510f8f33c765" }, { + "filename": "flywheel-1.16-0.2.0.jar", + "id": 3406855, + "project": "flywheel", + "project_id": 486392, + "sha256": "7abc741d731b207ab3e1c6776786af6cd2150d57c140090285293a593e82b669" + }, + { + "filename": "expandability-2.0.1-forge.jar", + "id": 3277762, + "project": "expandability", + "project_id": 465066, + "sha256": "0959cffb3a545730e6b2e1377bb89b59ff96e7f9142f54cc8035ab4fa2fc76e1" + }, + { + "filename": "CodeChickenLib-1.16.5-4.0.2.429-universal.jar", + "id": 3398096, "project": "codechicken-lib-1-8", - "id": "3175750", - "filename": "CodeChickenLib-1.16.4-3.5.1.408-universal.jar", - "sha256": "6b88e5f13ceb642734d3f3168da706a80ae2a2d538ba8dd958eb73b3d8911ab3" + "project_id": 242818, + "sha256": "0254c780c5f20653cab34f6bc8178b1de1ce44de082dcd42ff1e1ee9ba9d5e3a" }, { + "filename": "CookingForBlockheads_1.16.5-9.3.3.jar", + "id": 3368022, "project": "cooking-for-blockheads", - "id": "3098223", - "filename": "CookingForBlockheads_1.16.3-9.2.2.jar", - "sha256": "5b15a1e4bac72160ed1ef1042c2cef5eeca5d8dbfecb6620511caa1cf644adaa" + "project_id": 231484, + "sha256": "6adc6a882c2647ecda2345321ec77572a7f0a3fcdeadae24fa5dc71f0e5af9bb" }, { + "filename": "CosmeticArmorReworked-1.16.5-v4.jar", + "id": 3398000, "project": "cosmetic-armor-reworked", - "id": "3205904", - "filename": "CosmeticArmorReworked-1.16.5-v1b.jar", - "sha256": "6535b9077d0b64c2cc3392c145f558492c47280eb4a38672c6b6a4897fee7ec7" + "project_id": 237307, + "sha256": "83a24d226acd7c86b94b4a8eac716b8a306c96e7d76a1a06bdcc2e2be9df9b21" }, { - "project": "crafting-station", - "id": "3084325", "filename": "craftingstation-4.1.1.jar", + "id": 3084325, + "project": "crafting-station", + "project_id": 318551, "sha256": "a3516650a1c5e76b47b9efd69a4cfa9cda4f85250bf217fa7186f74ef375a7e4" }, { + "filename": "create-mc1.16.5_v0.3.2c.jar", + "id": 3406857, "project": "create", - "id": "3167531", - "filename": "create-mc1.16.3_v0.3e.jar", - "sha256": "8c24ee59c3d1c74fb2047564d0aa6935862b2b85fb478dadf19798f7cc08944f" + "project_id": 328085, + "sha256": "5cec00aa769b9edf9c85235742d593b00eefd4f3f0ed93cac412d633c23c6558" }, { + "filename": "CreativeCore_v2.2.0_mc1.16.5.jar", + "id": 3338971, "project": "creativecore", - "id": "3128357", - "filename": "CreativeCore_v2.0.10_mc1.16.4.jar", - "sha256": "85210df1f6abe5befc7afbb9150e5639f885c229ba3018bd6f40fd142468f377" + "project_id": 257814, + "sha256": "8155f7a84695a68fd2e8b8f6fab0377b9d78cfbab9d8c125e6a9b58238d1eacc" }, { + "filename": "curios-forge-1.16.5-4.0.5.2.jar", + "id": 3343065, "project": "curios", - "id": "3186427", - "filename": "curios-forge-1.16.5-4.0.4.0.jar", - "sha256": "4d6d63c432e24d295a410ec9eb24054123094db4913e76f564adfa188cf59d29" + "project_id": 309927, + "sha256": "08d7558df6c621fca29758c349b95b137d2977cf1f3f61323fff4d85630d0641" }, { + "filename": "dankstorage-3.16.jar", + "id": 3250771, "project": "dank-storage", - "id": "3161863", - "filename": "dankstorage-3.14.jar", - "sha256": "2ff74a22f0a90f9daed9a0632133b14868ad47500f378326f2a0faedc6029684" + "project_id": 335673, + "sha256": "bd5734d8ee8caf3a20574699d91f95b9e53df6b4d13f196f087d3f4bfe867621" }, { - "project": "decorative-blocks", - "id": "3166283", "filename": "decorative_blocks-1.16.4-1.7.2.jar", + "id": 3166283, + "project": "decorative-blocks", + "project_id": 362528, "sha256": "f12dbfe76e36cdec65b8a575fc671f0291323a0de5ff420ff196d16bd19e6f84" }, { + "filename": "DoggyTalents-1.16.5-2.0.1.10.jar", + "id": 3399830, "project": "doggy-talents", - "id": "3203941", - "filename": "DoggyTalents-1.16.4-2.0.1.3.jar", - "sha256": "59d8c5f058ef329bf6363fa8d300da3e876c523f9cc6229e0524317207442489" + "project_id": 271050, + "sha256": "dab81029d8e1155749ec7144b39e578980456fd8b59461e218ed930d72e80cbd" }, { + "filename": "easy_piglins-1.16.5-1.0.2.jar", + "id": 3309363, "project": "easy-piglins", - "id": "3169792", - "filename": "easy_piglins-1.16.5-1.0.0.jar", - "sha256": "b048630085695a5e8846cc2b8cc1bb6f1bcb59f0077ab63394a803c905df1006" + "project_id": 419372, + "sha256": "66ac62e343203ed217a27a9038155192d4b3ee87908f7000347c5ee50526e5b5" }, { + "filename": "easy_villagers-1.16.5-1.0.11.jar", + "id": 3327024, "project": "easy-villagers", - "id": "3171686", - "filename": "easy_villagers-1.16.4-1.1.28.jar", - "sha256": "3b8eff14b2b83f5cfe178f03076fa37c49add5dc05836b3151c7077f65a96dff" + "project_id": 400514, + "sha256": "845e937a59e1c3b2423aff0129248b82ae9bdd3a618f43645cc7be6fe974c183" }, { + "filename": "EnchantmentDescriptions-1.16.5-7.0.14.jar", + "id": 3363585, "project": "enchantment-descriptions", - "id": "3191059", - "filename": "EnchantmentDescriptions-1.16.5-7.0.2.jar", - "sha256": "890db07c51b07fb5921c8ae9e6352987c705625ca27f3d23bdfd313115a6a94b" + "project_id": 250419, + "sha256": "60405ac61dbfb1e3c5d90479c2248f3e9408ca1089c524cefd021760c152f50c" }, { + "filename": "EnderStorage-1.16.5-2.8.0.168-universal.jar", + "id": 3361748, "project": "ender-storage-1-8", - "id": "3175751", - "filename": "EnderStorage-1.16.4-2.7.1.166-universal.jar", - "sha256": "fbb861b85858f7a118a442d5577a53e5415c1f1b6ba7c4ade942d5512706f40d" + "project_id": 245174, + "sha256": "31725d5af63fda688f38c7546a1e210332339fadd5fedc3144f9fb0b643bf8d2" }, { - "project": "extended-lights-mod", - "id": "3144281", "filename": "extlights-3.3.jar", + "id": 3144281, + "project": "extended-lights-mod", + "project_id": 335051, "sha256": "7f210f8e8bc451df301a6a2c22f81e434dd1835699444e5c0ed2bb2620847a6b" }, { + "filename": "ExtraStorage-1.16.5-1.4.1.jar", + "id": 3336746, "project": "extrastorage", - "id": "3179402", - "filename": "ExtraStorage-1.16.4-1.3.1.jar", - "sha256": "30a78eb59482d393c7471a3b834e49e2dc6a70998be8ece9ba2c487abb5c92a5" + "project_id": 410168, + "sha256": "0c3ecafbcc4c7f8a91479d389add57d0db2943cf182352065535d6b5511bce4f" }, { + "filename": "FarmingForBlockheads_1.16.5-7.3.1.jar", + "id": 3332379, "project": "farming-for-blockheads", - "id": "3098206", - "filename": "FarmingForBlockheads_1.16.3-7.2.1.jar", - "sha256": "2225906be3306bb1066b58ebb97b998ebb679ef7fc2dcab6be53129675c44867" + "project_id": 261924, + "sha256": "94668c62457b655cf4bb2ff651adc43a2c2379e1ee4d545c57ff0d01c45db61e" }, { - "project": "fast-leaf-decay", - "id": "3052146", "filename": "FastLeafDecay-v25.jar", + "id": 3052146, + "project": "fast-leaf-decay", + "project_id": 230976, "sha256": "0abd12217bd7e83d5427a4aca6acec27241bb4a7272ef79958a692bd60fe1d86" }, { + "filename": "FastWorkbench-1.16.4-4.5.1.jar", + "id": 3245271, "project": "fastworkbench", - "id": "3171218", - "filename": "FastWorkbench-1.16.4-4.5.0.jar", - "sha256": "0f4dc32d33512193a3f53ef4e2432bce921ffc047590e1734d3763b8dbd0a547" + "project_id": 288885, + "sha256": "99488d96c13fb062fc7d1281957d72f69fca0f1fa07f54c480337282a5092f23" }, { - "project": "fishing-real", - "id": "3074201", "filename": "fishingreal-1.16.3-1.0.0.jar", + "id": 3074201, + "project": "fishing-real", + "project_id": 348834, "sha256": "1c2f868ee221e59407f6c8f1ec07fa7ccca49a819559dad818713a6778291fc5" }, { + "filename": "HardcoreRevival_1.16.5-6.0.1.jar", + "id": 3344257, "project": "hardcore-revival", - "id": "3066098", - "filename": "HardcoreRevival_1.16.3-5.2.0.jar", - "sha256": "c7d20cad7f9d5e9dd36252c3735568b8e7a9a214bc543356b8429b6748f5ae49" + "project_id": 274036, + "sha256": "4a76642dd343070261f9151a37c2deb7e2c9efc031d4127f91b8b6d9b7614670" }, { + "filename": "iceandfire-2.1.8-1.16.5.jar", + "id": 3361256, "project": "ice-and-fire-dragons", - "id": "3162719", - "filename": "iceandfire-2.1.5-1.16.4.jar", - "sha256": "eb67d6808d9ae4d32b92d26a9a4561549e5e3fbeacf23ed614b19786c2172c76" + "project_id": 264231, + "sha256": "37d849bc66e32b1de6ff52c2002714a49673b08f4fd84f36a7e1a6fdbf20f69e" }, { + "filename": "iChunUtil-1.16.5-10.4.1.jar", + "id": 3346209, "project": "ichunutil", - "id": "3062089", - "filename": "iChunUtil-1.16.3-10.0.0.jar", - "sha256": "015b4cb31362e323ccdd84e3f865137bd7c32a8a1adcb9f9b77c4e6301a56a25" + "project_id": 229060, + "sha256": "d5a1be183d5f68ff520ddfa6a5db55dfe7d76f327fa98fd0a82209330815b5d9" }, { + "filename": "ironchest-1.16.5-11.2.13.jar", + "id": 3405717, "project": "iron-chests", - "id": "3105315", - "filename": "ironchest-1.16.4-11.2.10.jar", - "sha256": "5208572a3f07647ca3cfed9f7414957acd0059b7f708d2518f4c73c98beae6be" + "project_id": 228756, + "sha256": "535b48cc3f12acacf42c2daff8709e45131d34bcc218a05203f62ce091e92a11" }, { + "filename": "ironfurnaces-1.16.5-2.6.9.jar", + "id": 3387531, "project": "iron-furnaces", - "id": "3152441", - "filename": "ironfurnaces-1.16.4-2.5.6.jar", - "sha256": "042dcb6eca515f814b2093a600cca23a42fef71e4dbaf53b301369018ac5f288" + "project_id": 237664, + "sha256": "f9347a04dece94e645b581091f94cd33396e93a91209eb55cc6933e09196b0a1" }, { + "filename": "jei-1.16.5-7.7.1.116.jar", + "id": 3401260, "project": "jei", - "id": "3192904", - "filename": "jei-1.16.4-7.6.1.71.jar", - "sha256": "a4f1cc91214605b7d9b840a4a8ffd910c0eccc9db7f6ce82964bba9f3ca661e5" + "project_id": 238222, + "sha256": "d2c8b8e08646e060a053cb9eaba70229540a7fc0204287e561dfd91bbff2c29b" }, { - "project": "jei-integration", - "id": "3202331", "filename": "jeiintegration_1.16.5-7.0.1.15.jar", + "id": 3202331, + "project": "jei-integration", + "project_id": 265917, "sha256": "0b45fe2858a8e9f97bf10fb218975a48a7d228ca27d274194c4dfaa91534bdfd" }, { + "filename": "JustEnoughResources-1.16.5-0.12.1.121.jar", + "id": 3336760, "project": "just-enough-resources-jer", - "id": "3066754", - "filename": "JustEnoughResources-1.16.3-0.12.0.100.jar", - "sha256": "d09fe055704075044e76e38c315ef410b8fc3587b1e24e500d540b57365ceb66" + "project_id": 240630, + "sha256": "1fa5dce078ff98fb172ca658aa7c70345fb8af969c506d5125b419da93448d61" }, { + "filename": "Kiwi-1.16.5-3.5.2.jar", + "id": 3377053, "project": "kiwi", - "id": "3103509", - "filename": "Kiwi-1.16.3-3.4.1.jar", - "sha256": "8e03a2109cb60117f6020a8943a19dc354a2cf2e1b83a0523169fece4ef06757" + "project_id": 303657, + "sha256": "1a175d5f6ca5329c5ef92c853b3112a6a4d4284b7896aeb4b60c21381f2c8caf" }, { + "filename": "Lollipop-1.16.5-3.2.9.jar", + "id": 3232534, "project": "lollipop", - "id": "3209431", - "filename": "Lollipop-1.16.4-3.2.6.jar", - "sha256": "5eb4c5c6947cfdcd26014a3209aff91653fe13044436dbfd0c310bcbf8abf701" + "project_id": 347954, + "sha256": "bba84ef5f76510595f1ee693f650d4ee4202cea290b4139233ca26060a14e12b" }, { + "filename": "lottaterracotta-1.16.5-1.3.2.jar", + "id": 3364628, "project": "lotta-terracotta", - "id": "3186253", - "filename": "lottaterracotta-1.16.5-1.3.1.jar", - "sha256": "8a5879733d8c35129c999d6524f0b7c1b49482076e1104c0c873f70267ea22d5" + "project_id": 351060, + "sha256": "2a305378e261dee335fb680b4ac1cc362bed0b599a9fce6e248decbe1fa56c84" }, { + "filename": "mcw-doors-1.0.3-mc1.16.5.jar", + "id": 3340793, "project": "macaws-doors", - "id": "3182357", - "filename": "mcw-doors-1.0.2-mc1.16.5.jar", - "sha256": "cea684ad9bf1fa75ba2685b3e521b2e1806f428681f7d929e3f937b161fb397e" + "project_id": 378646, + "sha256": "fb23ffda5f8407a01bbb8a1ec5b08dff1a8772a6e7a726dd085920be62337982" }, { - "project": "macaws-furniture", - "id": "3182349", "filename": "mcw-furniture-2.0.1-mc1.16.5.jar", + "id": 3182349, + "project": "macaws-furniture", + "project_id": 359540, "sha256": "7f81b95c128ce97f3c41e29a4e98618c591f96321b53b718b5c3b6b8d3cb619e" }, { - "project": "metal-barrels", - "id": "3055811", "filename": "metalbarrels-3.3a.jar", + "id": 3055811, + "project": "metal-barrels", + "project_id": 324985, "sha256": "9bec62579ec71be41a303519e3b7944df0f3ee23a5b03ac7c0d0b27fe7c66150" }, { - "project": "pams-harvestcraft-2-crops", - "id": "3076451", - "filename": "pamhc2crops-1.16.3-1.0.1.jar", - "sha256": "d987b59e46c36c3461ee913729e9eb3d808e3e2c71499ef6e517c1b3f55ee093" + "filename": "overworld_two-1.0-Forge-1.16.4.jar", + "id": 3149167, + "project": "overworld-two-forge", + "project_id": 431157, + "sha256": "4995b774537ab31de6b98eb15aad3fbbfe6d3aa4e57108a9b3fe3abbe3d8da59" + }, + { + "filename": "pamhc2crops-1.16.3-1.0.2.jar", + "id": 3276350, + "project": "pams-harvestcraft-2-crops", + "project_id": 361385, + "sha256": "5ebb51293d3e56ccf93875b7a4943577d78c1ee79401115230bb28cebbc7e832" }, { - "project": "pams-harvestcraft-2-food-core", - "id": "3190867", "filename": "pamhc2foodcore-1.16.3-1.0.2.jar", + "id": 3190867, + "project": "pams-harvestcraft-2-food-core", + "project_id": 372534, "sha256": "e4414d35013e746e5b06256a08dd957a814b17cebcb035899a84a3692d08b544" }, { + "filename": "pamhc2foodextended-1.16.3-1.0.2.jar", + "id": 3260454, "project": "pams-harvestcraft-2-food-extended", - "id": "3190664", - "filename": "pamhc2foodextended-1.16.3-1.0.1.jar", - "sha256": "58a97f94f7087c2e66c9a6b2f33a328619bc544f46134597d3f612387b165668" + "project_id": 402231, + "sha256": "886ec5e6dca66382b99765b0033d17e270b792171a75dd8eb41fcfd86a5641e9" }, { + "filename": "pamhc2trees-1.16.3-1.0.1.jar", + "id": 3281234, "project": "pams-harvestcraft-2-trees", - "id": "3117043", - "filename": "pamhc2trees-1.16.3-1.0.0.jar", - "sha256": "0b18c28cec6212d5256a9abaea13cbac502d329f70797d17a3523d8a662846ce" + "project_id": 365460, + "sha256": "e0f38f6a61e1da87981a249d520f2a8e43c4cefd29693076caf74ab8c5fe697f" }, { + "filename": "PassableFoliage-1.16.5-2.3.1.jar", + "id": 3378277, "project": "passable-foliage", - "id": "3103676", - "filename": "PassableFoliage-1.16.4-2.2.0.jar", - "sha256": "be727b1e5dc0412404af84145180b00222274c1f7d31f5bfed5bc716e6146eeb" + "project_id": 379887, + "sha256": "b18d228f6c8e34b8de54a0b0aa257e1be1eef7b65f8b7f75b3186e46f1b2118b" }, { + "filename": "performant-1.16.2-5-3.72m.jar", + "id": 3401152, "project": "performant", - "id": "3285916", - "filename": "performant-1.16.2-5-3.54m.jar", - "sha256": "N8eUXJtIdbNRqZHLZ2gdj9HgpMYu7tAhMnG5Dw2dgqk=" + "project_id": 354143, + "sha256": "cb3ef5fbedc6c9d7a0e379f7da400e22893a82425f27bd00bfd62e8cd8b35e20" }, { + "filename": "Placebo-1.16.4-4.5.0.jar", + "id": 3331459, "project": "placebo", - "id": "3172794", - "filename": "Placebo-1.16.4-4.4.1.jar", - "sha256": "c57663a0b37260ca0cfaa6a4fb710d58f35866f029e92412b2332587a27d8f5d" + "project_id": 283644, + "sha256": "4a1bebf13a3dde1870fee6da242598f9a1c8005161fdd795052506e0c38fd5da" }, { - "project": "platter", - "id": "3115114", "filename": "Platter-1.16-1.0.0.jar", + "id": 3115114, + "project": "platter", + "project_id": 381581, "sha256": "6e4aee987ac4efa41a1b9cc26a4e4588c79a56bb200402b9fee71e43ab45a533" }, { + "filename": "Powah-1.16.5-2.3.16.jar", + "id": 3232535, "project": "powah", - "id": "3209434", - "filename": "Powah-1.16.4-2.3.12.jar", - "sha256": "83806e56f79cb01382a6f105ffee8bba131afe52b04909138452eaffd0f87d49" + "project_id": 352656, + "sha256": "78b652caa055f67f0479bac9a44e3ed67704bf4e59a48d06c7fd3cfe9ecb2b72" }, { - "project": "quark-oddities", - "id": "3088871", "filename": "QuarkOddities-1.16.3.jar", + "id": 3088871, + "project": "quark-oddities", + "project_id": 301051, "sha256": "5eafd942f2eb9b13edde3bff451ee968c1d0fe549c8decd2f8551e59a079711d" }, { + "filename": "Quark-r2.4-316.jar", + "id": 3394265, "project": "quark", - "id": "3208541", - "filename": "Quark-r2.4-305.jar", - "sha256": "02c6788bc39963b436de77e315808cd05ca09fddf8adeb27be5f5874cfd59b73" + "project_id": 243121, + "sha256": "e5cea2e0aa0c229913dfb2735cc52c3889ad8d448bc1bdd64aa0dda3077b3676" }, { + "filename": "refinedstorage-1.9.15.jar", + "id": 3400575, "project": "refined-storage", - "id": "3196167", - "filename": "refinedstorage-1.9.12.jar", - "sha256": "dbe279c56a44decbbfcaf2b1d8aed84988a5ddb62b0c20ec8777e90ecb58e346" + "project_id": 243076, + "sha256": "d49fc8ff38b973517e60bc5d17a1e98bc8b4c6870ec58d3df7a36ac780474180" }, { + "filename": "RepairChests-1.16.5-1.7.jar", + "id": 3211620, "project": "repair-chests", - "id": "3111984", - "filename": "RepairChests-1.16.4-1.6.jar", - "sha256": "e93bfbadf085764e0f458ab7a77a6c1f7620039390ffa7f60f08914d09124468" + "project_id": 401644, + "sha256": "d25687ae8c7a9caf7491b506852eb7a6edc827230794dca4ddd45628b5674df9" }, { + "filename": "rsgauges-1.16.4-1.2.11.jar", + "id": 3390492, "project": "redstone-gauges-and-switches", - "id": "3179484", - "filename": "rsgauges-1.16.4-1.2.8.jar", - "sha256": "dcac66fb8d65080d5326310c173e215437e0fa15405721f494f6da27e125b785" + "project_id": 296686, + "sha256": "65e6e7a7fac64130de455b8b8e3ec1a16ee48411df0ab3963790038019f69a25" }, { + "filename": "selene-1.16.5-1.3.jar", + "id": 3377212, + "project": "selene", + "project_id": 499980, + "sha256": "49a08a86b9f63170fb1a9bf9c81d6a91157eecfbf150ac04bb010207a0133485" + }, + { + "filename": "SnowRealMagic-1.16.4-2.5.8.jar", + "id": 3391417, "project": "snow-real-magic", - "id": "3196605", - "filename": "SnowRealMagic-1.16.4-2.3.1.jar", - "sha256": "f588ae017f68f85dbdc26374282a0ad728ad44496577001314a2b2e5f22ef33b" + "project_id": 308663, + "sha256": "153ba7328acbc0818361bb6f84fe4546aa1e9ddcd350ab5b6c97c6f7209b36b5" }, { + "filename": "snowundertrees-1.16.5-v1.1.4.jar", + "id": 3247710, "project": "snow-under-trees", - "id": "3152350", - "filename": "snowundertrees-1.16.4-v1.1.3.jar", - "sha256": "6fb11fc0ff8542780796d481cc69549718dc6759b80bec43835003ebd33b8235" + "project_id": 353942, + "sha256": "66cf77b4f9b654648e890fe6c55a3be9b3693f1be505d1c1e7b6ff1b91a1a54d" }, { + "filename": "SoL-Carrot-1.16.5-1.10.0.jar", + "id": 3355731, "project": "spice-of-life-carrot-edition", - "id": "3174886", - "filename": "solcarrot-1.16.3-1.9.9.jar", - "sha256": "541ef38547ec17fb7cc485474747623d2dcc963a788c5ea300b39e31612e9022" + "project_id": 277616, + "sha256": "b92f394d72b58e59e14d6cc337edf93d79617b02169ac44a3ec2a68820543d3a" }, { - "project": "spark", - "id": "3245792", "filename": "spark-forge.jar", - "sha256": "9BSMsIoiLWFFQje2jhnVqFNiFTXKITTAlIuDxUOgtds=" + "id": 3337641, + "project": "spark", + "project_id": 361579, + "sha256": "a162f9caf81073429bcb8df4844ef8eb43828c57d2956f55675499bc004e4802" }, { + "filename": "StorageDrawers-1.16.3-8.3.0.jar", + "id": 3402515, "project": "storage-drawers", - "id": "3180569", - "filename": "StorageDrawers-1.16.3-8.2.2.jar", - "sha256": "e8775a6bd6b4c61f2df6efe22294d41e390b1aef79d744233948cc1e2bb07651" + "project_id": 223852, + "sha256": "79ab53ab8d46aa517025fc4ecbb05b8492daff5f252aa4884ba46e8fefc3b794" }, { + "filename": "supplementaries-1.16.5-0.14.3.jar", + "id": 3377218, "project": "supplementaries", - "id": "3281805", - "filename": "supplementaries-1.16.5-0.12.1.jar", - "sha256": "sOjCHEhL1x/jF4D/HuYiKdXvFIZyPFeKk0ihY6SUqcI=" + "project_id": 412082, + "sha256": "42e91d1c58b9bd292263410e75971de8a59ce0c1f2d7979a2222591fc55eba28" }, { + "filename": "sweetconcrete-1.16.5-1.7.2.jar", + "id": 3364624, "project": "sweet-concrete", - "id": "3186255", - "filename": "sweetconcrete-1.16.5-1.7.1.jar", - "sha256": "6333aeb7dbdf3d2c5365bc7679ef91d0eec1c6d1ac6ff2f86c19139abbb02afe" + "project_id": 351052, + "sha256": "6836f7f2a6f04edf6fe1efd4a6341c3c486c6c1ff824a858927375a45a121e33" }, { - "project": "swingthroughgrass", - "id": "3103028", "filename": "swingthroughgrass-1.16.4-1.5.3.jar", + "id": 3103028, + "project": "swingthroughgrass", + "project_id": 264353, "sha256": "d47132c8e97989f6f1b4c3c2c0736bf9e16e9a72970b3953fc80dcf8b1a4e31d" }, { + "filename": "the_bumblezone-1.16.5-2.4.10-forge.jar", + "id": 3404007, "project": "the-bumblezone-forge", - "id": "3389654", - "filename": "the_bumblezone-1.16.5-2.4.9-forge.jar", - "sha256": "51b2b5860ee391df2ea76c235c6614b34225312ebadaca4893c8ff16b0e9242a" + "project_id": 362479, + "sha256": "71fb56ddca8d5f671b1c5e588b60e352bb80fba135aab74056b4daa0ed44cefd" }, { - "project": "the-undergarden", - "id": "3361666", "filename": "The_Undergarden-1.16.5-0.5.4.jar", + "id": 3361666, + "project": "the-undergarden", + "project_id": 379849, "sha256": "b596836a5c1d50cf1c65c50ea728b0e295965cf9a4091a8eb1caac517aad5c50" }, { - "project": "towers-of-the-wild", - "id": "3103750", "filename": "towers_of_the_wild-1.16.4-2.0.1.jar", + "id": 3103750, + "project": "towers-of-the-wild", + "project_id": 386415, "sha256": "fcd0e3f808569f0e547313a1ea3563c9a5d2fa8fbb638678eed6e46c1d8cfaf1" }, { + "filename": "TravelersBackpack-1.16.5-5.4.2.jar", + "id": 3316664, "project": "travelers-backpack", - "id": "3171745", - "filename": "TravelersBackpack-1.16.4-5.3.8.jar", - "sha256": "cd15a1bef4388bfc492c96dab510d32fff17cd921a06393bbb7ab25f6f25fc88" + "project_id": 321117, + "sha256": "e07aad8653f037ad96639a602fa260684f89757c905d6a47e1193154d274875e" }, { - "project": "the-weirding-gadget", - "id": "3116235", "filename": "weirdinggadget-1.16.(2-4)-2.2.7.jar", + "id": 3116235, + "project": "the-weirding-gadget", + "project_id": 258914, "sha256": "fe9b2d4f39020a4239a19ea0e7229beec29eb8f1ef2b2b198b9aa5aad0b13318" }, { - "project": "wither-skeleton-tweaks", - "id": "3172803", "filename": "Wither-Skeleton-Tweaks-1.16.4-5.3.0.jar", + "id": 3172803, + "project": "wither-skeleton-tweaks", + "project_id": 255902, "sha256": "e6375312aeb188cda4951a4c4935343a64785303129dbb47f49f59768d0865d3" }, { + "filename": "Xaeros_Minimap_21.14.1_Forge_1.16.5.jar", + "id": 3405505, "project": "xaeros-minimap", - "id": "3200201", - "filename": "Xaeros_Minimap_21.3.0.2_Forge_1.16.5.jar", - "sha256": "d477b6838bc27bfc759dc8601582683fdc7d425736656d304a1cbae4d932c6f0" + "project_id": 263420, + "sha256": "97278ddc89fe70b81387fc2ae45d986eb07e373b49977de5d358b8addf1103a2" }, { + "filename": "XaerosWorldMap_1.16.0_Forge_1.16.5.jar", + "id": 3405517, "project": "xaeros-world-map", - "id": "3200214", - "filename": "XaerosWorldMap_1.12.0.2_Forge_1.16.5.jar", - "sha256": "d4cc27d1646ce8bb5411261b31f1a13b11b7ad709fe7d9be43c4c7c8caa529f1" + "project_id": 317780, + "sha256": "b4bceb6ebebf9a6c67a2e750e98d5cf2c1fe53fc66e487a79ac0d7a0664a8a12" }, { + "filename": "YungsApi-1.16.4-Forge-11.jar", + "id": 3386962, "project": "yungs-api", - "id": "3186128", - "filename": "YungsApi-1.16.4-Forge-4.jar", - "sha256": "5a78eec5576ed162def18849bb604d5c69ec73b8715ab28ad41174ad0a673304" + "project_id": 421850, + "sha256": "d280edabd1f83ff45831e8c79dfdc5e9ca17158fa2ed1d05025afcea23ad83a9" } ] diff --git a/pkgs/minecraft/voor-kia/update-mods.py b/pkgs/minecraft/voor-kia/update-mods.py new file mode 100644 index 0000000..df32d86 --- /dev/null +++ b/pkgs/minecraft/voor-kia/update-mods.py @@ -0,0 +1,153 @@ +import argparse +import json +import hashlib +import pathlib +from copy import deepcopy +from enum import Enum +from typing import Dict, Generator, NamedTuple, Optional, Union + +import requests + + +API = "https://addons-ecs.forgesvc.net/api/v2" + + +class ModLoader(Enum): + FORGE = 1 + FABRIC = 4 + + +class File(NamedTuple): + id: int + gameVersion: str + name: str + modLoader: Optional[ModLoader] + + @classmethod + def from_json(cls, f: Dict[str, Union[str, int]]): + modLoader = f.get("modLoader", None) + + assert isinstance(f["gameVersion"], str) + assert isinstance(f["projectFileId"], int) + assert isinstance(f["projectFileName"], str) + if modLoader is not None: + assert isinstance(modLoader, int) + + return cls( + f["projectFileId"], + f["gameVersion"], + f["projectFileName"], + ModLoader(modLoader) if modLoader is not None else None, + ) + + +class CurseAPI: + def __init__(self): + self._session = requests.Session() + self._session.headers[ + "User-Agent" + ] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0" + + def get_latest_files(self, mod_id: int) -> Generator[File, None, None]: + res = self._session.get(f"{API}/addon/{mod_id}") + res.raise_for_status() + + latest_files = res.json().get("gameVersionLatestFiles", None) + + if latest_files is None: + return (_ for _ in []) + else: + return (File.from_json(f) for f in latest_files) + + def get_file_url(self, mod_id: int, file_id: int) -> str: + res = self._session.get(f"{API}/addon/{mod_id}/file/{file_id}/download-url") + res.raise_for_status() + return res.text.rstrip("\n") + + def download_file(self, mod_id: int, file_id: int) -> bytes: + url = self.get_file_url(mod_id, file_id) + file_ = self._session.get(url) + file_.raise_for_status() + return file_.content + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("version", help="The minecraft version to limit updates to") + parser.add_argument( + "--mod-loader", choices=["none", "forge", "fabric"], default="forge" + ) + parser.add_argument("--infile", type=pathlib.Path) + args = parser.parse_args() + + if args.mod_loader == "forge": + mod_loader = ModLoader.FORGE + elif args.mod_loader == "fabric": + mod_loader = ModLoader.FABRIC + else: + raise AssertionError("Unreachable") + + update(args.infile, args.version, mod_loader) + + +def update(infile: pathlib.Path, version: str, mod_loader: ModLoader): + with open(infile) as mods_json: + mods = json.load(mods_json) + + curse = CurseAPI() + new_mods = [] + + for mod in mods: + print(f"Checking for updates to {mod['project']}...") + + try: + latest_files = list(curse.get_latest_files(mod["project_id"])) + except requests.HTTPError as err: + print(f"WARNING: Could not access curse API for {mod['project']}: {err}") + latest_files = [_ for _ in []] + + def compatible(file_: File) -> bool: + file_version = file_.gameVersion.split(".") + target_version = version.split(".") + + # We assume that major + minor version are compatible; + # this seems to generally be true, but check the output + # for possible mistakes. + # + # The patch version is completely ignored since mod + # authors generally don't register versions properly + # enough to match this. + # + # Being more strict than this usually results in + # technically compatible mods with no available versions. + return ( + (file_.modLoader is None or file_.modLoader == mod_loader) + and file_version[0] == target_version[0] + and file_version[1] == target_version[1] + ) + + latest = max(filter(compatible, latest_files), key=lambda f: f.gameVersion) + + if latest is None: + print(f"WARNING: No compatible files found for {mod['project']}") + print( + f"Versions available: {[(f.name, f.gameVersion) for f in latest_files]}" + ) + new_mods.append(mod) + elif latest.id != mod["id"]: + print(f"Updating {mod['project']}...") + contents = curse.download_file(mod["project_id"], latest.id) + sha256 = hashlib.sha256(contents).hexdigest() + + new_mod = deepcopy(mod) + new_mod.update({"filename": latest.name, "id": latest.id, "sha256": sha256}) + new_mods.append(new_mod) + else: + new_mods.append(mod) + + with open("temp.json", "w") as out: + json.dump(new_mods, out, sort_keys=True, indent=2) + + +if __name__ == "__main__": + main()