1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 06:16:04 +00:00

genblocks

This commit is contained in:
mat 2022-05-28 18:20:15 -05:00
parent ff2f3c7af5
commit 5d764c79d0
5 changed files with 40 additions and 7 deletions

View file

@ -101,16 +101,16 @@ impl Parse for BlockDefinitions {
impl Parse for MakeBlockStates {
fn parse(input: ParseStream) -> Result<Self> {
// PROPERTIES => { ... } BLOCKS => { ... }
// Properties => { ... } Blocks => { ... }
let properties_ident = input.parse::<Ident>()?;
assert_eq!(properties_ident.to_string(), "PROPERTIES");
assert_eq!(properties_ident.to_string(), "Properties");
input.parse::<Token![=>]>()?;
let content;
braced!(content in input);
let properties = content.parse()?;
let blocks_ident = input.parse::<Ident>()?;
assert_eq!(blocks_ident.to_string(), "BLOCKS");
assert_eq!(blocks_ident.to_string(), "Blocks");
input.parse::<Token![=>]>()?;
let content;
braced!(content in input);

View file

@ -7,7 +7,7 @@ pub trait Block {
}
make_block_states! {
PROPERTIES => {
Properties => {
Face {
Floor,
Wall,
@ -36,7 +36,7 @@ make_block_states! {
False
};
}
BLOCKS => {
Blocks => {
acacia_button => BlockBehavior::default().no_collision(), {
Face,
Facing,

13
codegen/genblocks.py Normal file
View file

@ -0,0 +1,13 @@
import lib.code.version
import lib.code.packet
import lib.code.blocks
import lib.code.utils
import lib.download
import lib.extract
import sys
version_id = lib.code.version.get_version_id()
block_states_data = lib.extract.get_block_states(version_id)
lib.code.blocks.generate_blocks(block_states_data)

View file

@ -0,0 +1,17 @@
BLOCKS_RS_DIR = '../azalea-blocks/src/blocks.rs'
def generate_blocks(blocks: dict):
with open(BLOCKS_RS_DIR, 'r') as f:
existing_code = f.read().splitlines()
new_make_block_states_macro_code = []
new_make_block_states_macro_code.append('make_block_states! {')
properties = {}
for block_name, block_data in blocks.items():
block_properties = block_data['properties']
properties.update(block_properties)
print(properties)

View file

@ -1,11 +1,14 @@
import lib.code.version
import lib.code.packet
import lib.code.utils
import lib.download
import lib.extract
import sys
mappings = lib.download.get_mappings_for_version('1.18.2')
burger_data = lib.extract.get_burger_data_for_version('1.18.2')
version_id = lib.code.version.get_version_id()
mappings = lib.download.get_mappings_for_version(version_id)
burger_data = lib.extract.get_burger_data_for_version(version_id)
burger_packets_data = burger_data[0]['packets']['packet']
packet_id, direction, state = int(sys.argv[1]), sys.argv[2], sys.argv[3]