Skip to content

dynamic_repo

AdamCalculator edited this page Mar 24, 2024 · 18 revisions

Dynamic repo

Dynamic repositories are repositories that require participation from their owner, but in return, when updating, only the missing files are downloaded, and not the entire package.

CursedEveryday

I support my resource pack CursedEveryday.zip You can test the mod on it, and also view its source code files

There are also python scripts to make work easier

Configure resourcepack

.minecraft/resourcepack/MyRP.zip!/dynamicmcpack.json

{
  "current": {
    "build": 12,
    // this key mod manage automatically. You may not set it
    "known_contents": {
      "id_of_content": {
        "hash": "sha1hash here equals with dynamcmcpack.repo.json{}.contents[\"hash\"]",
        "required": true // if key missing, required=false equals in repo.
      }
    },
  },
  "remote": {
    "type": "dynamic_repo",
    "url": "https://myrp.github.io/repo",

    // select one of: sign_no_required is true or public_key
    // WIKI: https://github.com/AdamCalculator/DynamicPack/wiki/dynamic_repo_secure
    "sign_no_required": true, 
    "public_key": "BASE64 RSA OpenPGP PUBLIC KEY HERE",
    
    "content_override": {
      "content_sounds": false
    }
  },
  "formatVersion": 1
}

-------

Mod support verify uploader by OpenPGP use public_key for it, OR enable flag sign_no_required to true. See wiki:dynamic_repo_security

-------

In this example, the repository will be hosted on GitHub pages https://myrp.github.io/repo

But you can use any site, or its separate folder, for example you can use it like this: https://raw.githubusercontent.com/AdamCalculator/DynamicPack/main/

After the link there should be some mod files, and they will be accessed like this:

Let's look at the contents of the first file dynamicmcpack.repo.json

{
  "formatVersion": 1, // mandatory
  "build": 12,
  "name": "MyRP",
  "minimal_mod_build": 0, // (optional)
  "contents": [
    {
      "id": "generic",
      "url": "content_generic.json",
      "hash": "hash_of_file_at_url_or_hash_of_uncompressed_file_if_you_uses_url_compressed",
      "required": true, // (optional) cannot be disabled by client remote.content_override and in settings this button will not be active
      "name": "" // (optional) visible name in "Contents..." screen
    },
    {
      "id": "content_sounds",
      "url": "content_sounds.json",
      "hash": "hash_of_file_at_url_or_hash_of_uncompressed_file_if_you_uses_url_compressed",
    }
  ]
}

Important

Since the content file can become very large (you will soon find out) the "url_compressed" key is supported, it must contain a link to a gzip-compressed json file (.json.gz)

it can contain a lot of content, which can be enabled and disabled in the future in the GUI of the mod. The important stuff starts in the content file

https://myrp.github.io/repo/content_generic.json

{
  "formatVersion": 1,
  "content": {
    "parent": "",
    "remote_parent": "pack_folder",
    "files": {
      "pack.png": {
        "hash": "66a7820917394710ab341a84ea38e7f2daf8288e"
      },
      "pack.mcmeta": {
        "hash": "0095cbc21092b960a390737fa0989ebfcbd146ab"
      },
      "assets/minecraft/optifine/emissive.properties": {
        "hash": "577d89738e60ebfbf2dbbdd5b2ff2c3400933a10"
      },
      "assets/minecraft/optifine/cem/armor_stand4.jem": {
        "hash": "9a51c3128c9c2a04a8d0b09ddb5415e57211ef7a"
      },
      "assets/minecraft/optifine/cem/armor_stand.properties": {
        "hash": "175f0a1d0e319a5cbed2d4d0964986f950141580"
      },
      "assets/minecraft/optifine/cem/armor_stand6.jem": {
        "hash": "0978feb0de7d24adabbb7385aa8d4be16d175888"
      },
      "assets/minecraft/optifine/lang/de_de.lang": {
        "hash": "468026c26e07f34cf8e92e6e6869e76510029c85"
      },
      "assets/minecraft/optifine/lang/en_us.lang": {
        "hash": "3089ef2df146fdf54c0ebe364c7840eb891766a8"
      }
    }
  }
}

the "parent" key can be used in cases where EVERY element begins with the same letter, let's say pack.mcmeta and the icon were added in another content pack, and in this one all content is stored in /assets/minecraft/optifine/contentpack83 then you write this in the "parent" value and in other places you skip it.

the "hash" key is a sha1 hashsum.

"remote_parent" is a dir inside you https://yourrp.github.io/repo/ for example "remote_parent" is "folder_pack". Then mod be download files from https://yourrp.github.io/repo/folder_pack/

File "assets/minecraft/optifine/lang/en_us.lang" should be here https://yourrp.github.io/repo/folder_pack/assets/minecraft/optifine/lang/en_us.lang

This file contain duplicate of json "build" value as plain text!

Clone this wiki locally