aboutsummaryrefslogtreecommitdiff
path: root/codegen/lib/code/blocks.py
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-06-10 15:17:13 -0500
committermat <github@matdoes.dev>2022-06-10 15:17:13 -0500
commit8c5d7407fe9a7f23e19b3ecf02c4cb7848fb4d29 (patch)
tree05a1e6e3cb4510d1e12b0b70de27b2c4e1786f52 /codegen/lib/code/blocks.py
parentab0796119b39b785da8cff4c09904511de16bf72 (diff)
downloadazalea-drasl-8c5d7407fe9a7f23e19b3ecf02c4cb7848fb4d29.tar.xz
fix Facing property
Diffstat (limited to 'codegen/lib/code/blocks.py')
-rw-r--r--codegen/lib/code/blocks.py18
1 files changed, 4 insertions, 14 deletions
diff --git a/codegen/lib/code/blocks.py b/codegen/lib/code/blocks.py
index eb1485ef..0737270b 100644
--- a/codegen/lib/code/blocks.py
+++ b/codegen/lib/code/blocks.py
@@ -11,18 +11,6 @@ BLOCKS_RS_DIR = get_dir_location('../azalea-block/src/blocks.rs')
# - State: A possible state of a block, a combination of variants
# - Block: Has properties and states.
-
-def get_property_variants(data) -> list[str]:
- if 'values' in data:
- return list(map(str.lower, data['values']))
- if data['type'] == 'bool':
- return ['true', 'false']
- if data['type'] == 'int':
- # range between data['min'] and data['max']
- return [str(i) for i in range(data['min'], data['max'] + 1)]
- raise Exception('Unknown property type: ' + data['type'])
-
-
def generate_blocks(blocks_burger: dict, blocks_report: dict, mappings: Mappings):
with open(BLOCKS_RS_DIR, 'r') as f:
existing_code = f.read().splitlines()
@@ -42,12 +30,14 @@ def generate_blocks(blocks_burger: dict, blocks_report: dict, mappings: Mappings
# Find properties
properties = {}
- for block_data_burger in blocks_burger.values():
+ for block_id, block_data_burger in blocks_burger.items():
+ block_data_report = blocks_report[f'minecraft:{block_id}']
+
block_properties = {}
for property in block_data_burger.get('states', []):
+ property_variants = block_data_report['properties'][property['name']]
property_name = get_property_name(property, block_data_burger)
- property_variants = get_property_variants(property)
block_properties[property_name] = property_variants
properties.update(block_properties)