aboutsummaryrefslogtreecommitdiff
path: root/codegen/lib/code/blocks.py
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2023-07-14 22:20:40 -0500
committerGitHub <noreply@github.com>2023-07-14 22:20:40 -0500
commit7405427199e5a994d4a6a706f84434a69cb7a7d9 (patch)
treeca537e5d761bc053187d952fced0915c850b92aa /codegen/lib/code/blocks.py
parentd1afd02aa84e7b4450c1607277f078eb2a0f1bf3 (diff)
downloadazalea-drasl-7405427199e5a994d4a6a706f84434a69cb7a7d9.tar.xz
Mining (#95)
* more mining stuff * initialize azalea-tags crate * more mining stuff 2 * mining in ecs * well technically mining works but no codegen for how long it takes to mine each block yet * rename downloads to __cache__ it was bothering me since it's not *just* downloads * codegen block behavior * fix not sending packet to finish breaking block * mining animation 🎉 * clippy * cleanup, move Client::mine into a client extension * add azalea/src/mining.rs --------- Co-authored-by: mat <git@matdoes.dev>
Diffstat (limited to 'codegen/lib/code/blocks.py')
-rwxr-xr-xcodegen/lib/code/blocks.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/codegen/lib/code/blocks.py b/codegen/lib/code/blocks.py
index a01df648..3af19fa8 100755
--- a/codegen/lib/code/blocks.py
+++ b/codegen/lib/code/blocks.py
@@ -13,7 +13,7 @@ BLOCKS_RS_DIR = get_dir_location('../azalea-block/src/generated.rs')
# - Block: Has properties and states.
-def generate_blocks(blocks_burger: dict, blocks_report: dict, ordered_blocks: list[str], mappings: Mappings):
+def generate_blocks(blocks_burger: dict, blocks_report: dict, pixlyzer_block_datas: dict, ordered_blocks: list[str], mappings: Mappings):
with open(BLOCKS_RS_DIR, 'r') as f:
existing_code = f.read().splitlines()
@@ -90,6 +90,7 @@ def generate_blocks(blocks_burger: dict, blocks_report: dict, ordered_blocks: li
for block_id in ordered_blocks:
block_data_burger = blocks_burger[block_id]
block_data_report = blocks_report['minecraft:' + block_id]
+ block_data_pixlyzer = pixlyzer_block_datas[f'minecraft:{block_id}']
block_properties = block_data_burger.get('states', [])
block_properties_burger = block_data_burger.get('states', [])
@@ -134,9 +135,28 @@ def generate_blocks(blocks_burger: dict, blocks_report: dict, ordered_blocks: li
else:
properties_code += '\n }'
+ # make the block behavior
+ behavior_constructor = 'BlockBehavior::new()'
+ # requires tool
+ if block_data_pixlyzer.get('requires_tool'):
+ behavior_constructor += '.requires_correct_tool_for_drops()'
+ # strength
+ destroy_time = block_data_pixlyzer.get('hardness')
+ explosion_resistance = block_data_pixlyzer.get('explosion_resistance')
+ if destroy_time and explosion_resistance:
+ behavior_constructor += f'.strength({destroy_time}, {explosion_resistance})'
+ elif destroy_time:
+ behavior_constructor += f'.destroy_time({destroy_time})'
+ elif explosion_resistance:
+ behavior_constructor += f'.explosion_resistance({explosion_resistance})'
+ # friction
+ friction = block_data_pixlyzer.get('friction')
+ if friction != None:
+ behavior_constructor += f'.friction({friction})'
+
# TODO: use burger to generate the blockbehavior
new_make_block_states_macro_code.append(
- f' {block_id} => BlockBehavior::default(), {properties_code},')
+ f' {block_id} => {behavior_constructor}, {properties_code},')
new_make_block_states_macro_code.append(' }')
new_make_block_states_macro_code.append('}')