Skip to content

Instantly share code, notes, and snippets.

@misode
Last active February 2, 2022 23:22
Show Gist options
  • Save misode/3a6a8c4782e5459b8815cd3268a94e41 to your computer and use it in GitHub Desktop.
Save misode/3a6a8c4782e5459b8815cd3268a94e41 to your computer and use it in GitHub Desktop.
PROPS = {
"instrument": [
"harp",
"basedrum",
"snare",
"hat",
"bass",
"flute",
"bell",
"guitar",
"chime",
"xylophone",
"iron_xylophone",
"cow_bell",
"didgeridoo",
"bit",
"banjo",
"pling"
],
"note": [
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
"14",
"15",
"16",
"17",
"18",
"19",
"20",
"21",
"22",
"23",
"24"
],
"powered": [
"true",
"false"
]
}
BLOCK = 'note_block'
from itertools import product
import json
keys = tuple(PROPS.keys())
variants = {}
for values in product(*PROPS.values()):
variant = ','.join([f'{keys[i]}={v}' for i, v in enumerate(values)])
variants[variant] = { 'model': f'minecraft:block/{BLOCK}' }
with open(f'{BLOCK}.json', 'w') as f:
json.dump({ "variants": variants }, f, indent=2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment