|
1 | 1 | #!/usr/bin/env python3 |
2 | | -# Remove lwjgl3 not supported mods |
| 2 | +# Generate LWJGL3 compatible manifest.json |
3 | 3 |
|
4 | | -## Import library |
5 | 4 | import json |
| 5 | +import json5 |
6 | 6 |
|
7 | 7 |
|
8 | | -## Run main function |
9 | | -projectIDs = [ |
10 | | - 419286, # MixinBooter |
11 | | - 870276, # ConfigAnytime |
12 | | - 873867, # Red Core |
13 | | - 910715, # Alfheim Lighting Engine |
14 | | - 624967, # RenderLib |
15 | | - 409087, # Entity Culling |
16 | | - 408853, # Particle Culling |
17 | | -] |
| 8 | +def main(): |
| 9 | + # Read overrides configuration |
| 10 | + with open('lwjgl3-overrides.jsonc', 'r', encoding='utf-8') as f: |
| 11 | + overrides = json5.load(f) |
18 | 12 |
|
19 | | -# Read manifest.json |
20 | | -with open('../manifest.json', 'r') as f: |
21 | | - data = json.load(f) |
| 13 | + remove_ids = set(overrides.get('remove', [])) |
| 14 | + add_mods = overrides.get('add', []) |
| 15 | + replace_mods = {mod['projectID']: mod['with'] for mod in overrides.get('replace', [])} |
22 | 16 |
|
23 | | -# Remove lwjgl3 not supported mods |
24 | | -data['files'] = [item for item in data['files'] if item['projectID'] not in projectIDs] |
| 17 | + # Read manifest.json |
| 18 | + with open('../manifest.json', 'r', encoding='utf-8') as f: |
| 19 | + data = json.load(f) |
25 | 20 |
|
26 | | -# Write manifest.json |
27 | | -with open('../cmmc/manifest.json', 'w') as f: |
28 | | - json.dump(data, f, indent=2) |
| 21 | + # Remove mods |
| 22 | + data['files'] = [item for item in data['files'] if item['projectID'] not in remove_ids] |
| 23 | + |
| 24 | + # Replace mods (update projectID and/or fileID) |
| 25 | + for item in data['files']: |
| 26 | + if item['projectID'] in replace_mods: |
| 27 | + replacement = replace_mods[item['projectID']] |
| 28 | + item['projectID'] = replacement['projectID'] |
| 29 | + item['fileID'] = replacement['fileID'] |
| 30 | + if 'required' in replacement: |
| 31 | + item['required'] = replacement['required'] |
| 32 | + |
| 33 | + # Add mods |
| 34 | + for mod in add_mods: |
| 35 | + data['files'].append({ |
| 36 | + 'projectID': mod['projectID'], |
| 37 | + 'fileID': mod['fileID'], |
| 38 | + 'required': mod.get('required', True) |
| 39 | + }) |
| 40 | + |
| 41 | + # Write manifest.json |
| 42 | + with open('../cmmc/manifest.json', 'w', encoding='utf-8') as f: |
| 43 | + json.dump(data, f, indent=2) |
| 44 | + |
| 45 | + |
| 46 | +if __name__ == '__main__': |
| 47 | + main() |
0 commit comments