Last active
September 22, 2021 16:16
-
-
Save SmokeyStack/eb3a1eadfd050226e1a923ac3f7cc0ee to your computer and use it in GitHub Desktop.
MCAddonJSONGenerator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from pathlib import Path | |
| import json | |
| import os | |
| identifier = input("Identifier:") | |
| displayName = input("Display Name:") | |
| cooldownDur = float(input("Cooldown Duration:")) | |
| itemID = identifier.split(":", 2) | |
| mainPath = 'output' | |
| Path(mainPath).mkdir(parents=True, exist_ok=True) | |
| itemFileName = '{0}.json'.format(itemID[1]) | |
| item = os.path.join(mainPath, itemFileName) | |
| f = open(item, "a") | |
| itemJSON = { | |
| "format_version": "1.16.100", | |
| "minecraft:item": { | |
| "description": { | |
| "identifier": "{}".format(identifier), | |
| "category": "items" | |
| }, | |
| "components": { | |
| "minecraft:icon": { | |
| "texture": "{}.texture".format(itemID[1]) | |
| }, | |
| "minecraft:display_name": { | |
| "value": "{0}.{1}".format(itemID[0], itemID[1]) | |
| }, | |
| "minecraft:max_stack_size": 1, | |
| "minecraft:use_duration": 999999999, | |
| "minecraft:stacked_by_data": True, | |
| "minecraft:hand_equipped": True, | |
| "minecraft:creative_category": { | |
| "parent": "itemGroup.name.tools" | |
| }, | |
| "minecraft:food": { | |
| "can_always_eat": True | |
| }, | |
| "minecraft:cooldown": { | |
| "category": "{}".format(itemID[0]), | |
| "duration": cooldownDur | |
| }, | |
| "minecraft:render_offsets": { | |
| "main_hand": { | |
| "first_person": { | |
| "scale": [ | |
| 0, | |
| 0, | |
| 0 | |
| ] | |
| }, | |
| "third_person": { | |
| "scale": [ | |
| 0, | |
| 0, | |
| 0 | |
| ] | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| f.write(json.dumps(itemJSON, indent=2)) | |
| f.close() | |
| print('Item files were successfully created.') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import manifest | |
| manifest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import uuid | |
| import json | |
| def yes_no(variable): | |
| while variable not in ["y", "n"]: | |
| variable = input("Please enter 'y' or 'n'\n").lower() | |
| if variable == "y": | |
| return True | |
| return False | |
| def pack_manifest(): | |
| global manifestJSON | |
| manifestJSON = { | |
| "format_version": 2, | |
| "header": { | |
| "name": "{}".format(pack_name), | |
| "description": "{}".format(pack_desc), | |
| "uuid": str(uuid.uuid4()), | |
| "version": [1, 0, 0], | |
| "min_engine_version": [1, 16, 0] | |
| }, | |
| "modules": [ | |
| { | |
| "type": "{}".format(manifest_type), | |
| "uuid": str(uuid.uuid4()), | |
| "version": [1, 0, 0] | |
| } | |
| ] | |
| } | |
| def skin_manifest(): | |
| global manifestJSON | |
| manifestJSON = { | |
| "format_version": 2, | |
| "header": { | |
| "name": "{}".format(pack_name), | |
| "description": "{}".format(pack_desc), | |
| "uuid": str(uuid.uuid4()), | |
| "version": [1, 0, 0] | |
| }, | |
| "modules": [ | |
| { | |
| "type": "{}".format(manifest_type), | |
| "uuid": str(uuid.uuid4()), | |
| "version": [1, 0, 0] | |
| } | |
| ] | |
| } | |
| def world_manifest(): | |
| global manifestJSON | |
| manifestJSON = { | |
| "format_version": 2, | |
| "header": { | |
| "base_game_version": (1,17,0), | |
| "lock_template_options": True, | |
| "name": "{}".format(pack_name), | |
| "description": "{}".format(pack_desc), | |
| "uuid": str(uuid.uuid4()), | |
| "version": (1,0,0), | |
| "min_engine_version": (1,17,0), | |
| }, | |
| "modules": [{ | |
| "type": "{}".format(manifest_type), | |
| "uuid": str(uuid.uuid4()), | |
| "version": (1,0,0) | |
| }] | |
| } | |
| def new_manifest(): | |
| global manifest_type | |
| global pack_name | |
| global pack_desc | |
| pack_name = input("Pack name: ") | |
| pack_desc = input("Pack description: ") | |
| pack = input("Do you want a resource pack, behaviour pack, skin pack, or world template? (r/b/s/w)\n") | |
| while pack not in ["r", "b", "s", "w"]: | |
| pack = input("Please enter 'r' for resource pack, 'b' for behaviour pack, 's' for skin pack, or 'w' for world template!\n").lower() | |
| if pack == "r": | |
| manifest_type = "resources" | |
| pack_manifest() | |
| elif pack == "b": | |
| manifest_type = "data" | |
| pack_manifest() | |
| elif pack == "s": | |
| manifest_type = "skin_pack" | |
| skin_manifest() | |
| else: | |
| manifest_type = "word_template" | |
| world_manifest() | |
| f = open("manifest.json", "w") | |
| f.write(json.dumps(manifestJSON, indent=4)) | |
| f.close() | |
| print('Manifest file was successfully created.') | |
| while yes_no(input("Do you want to create a new pack? (y/n)\n").lower()): | |
| new_manifest() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment