BlockType: replace list of booleans with flags bitfield

This commit is contained in:
Matthias Schiffer 2020-06-18 23:38:21 +02:00
parent 446e74791f
commit ef4b6eac02
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C
8 changed files with 800 additions and 787 deletions

View file

@ -209,8 +209,8 @@
"brown_wall_banner": null,
"brown_wool": {},
"bubble_column": {
"blue": true,
"texture": "water_still"
"texture": "water_still",
"water": true
},
"bubble_coral": null,
"bubble_coral_block": {},
@ -1428,8 +1428,8 @@
"warped_wall_sign": null,
"warped_wart_block": {},
"water": {
"blue": true,
"texture": "water_still"
"texture": "water_still",
"water": true
},
"weeping_vines": {},
"weeping_vines_plant": {},

View file

@ -42,7 +42,7 @@ for name, info in blocks.items():
'opaque': False,
'grass': False,
'foliage': False,
'blue': False,
'water': False,
}
if info is None:
@ -54,7 +54,7 @@ for name, info in blocks.items():
output[id]['opaque'] = True
output[id]['grass'] = info.get('grass', False)
output[id]['foliage'] = info.get('foliage', False)
output[id]['blue'] = info.get('blue', False)
output[id]['water'] = info.get('water', False)
with open(sys.argv[3], 'w') as f:
json.dump(output, f)

View file

@ -15,12 +15,23 @@ output = {}
with open(sys.argv[2], 'w') as f:
for name, info in colors.items():
print('{"%s", {%s, %s, %s, %s, {%u, %u, %u}}},' % (
flags = []
if info['opaque']:
flags.append('BLOCK_OPAQUE')
if info['grass']:
flags.append('BLOCK_GRASS')
if info['foliage']:
flags.append('BLOCK_FOLIAGE')
if info['water']:
flags.append('BLOCK_WATER')
if flags:
flags = '|'.join(flags)
else:
flags = '0'
print('{"%s", {%s, {%u, %u, %u}}},' % (
name,
['false', 'true'][info['opaque']],
['false', 'true'][info['grass']],
['false', 'true'][info['foliage']],
['false', 'true'][info['blue']],
flags,
info['color']['r'],
info['color']['g'],
info['color']['b'],