aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-05-28 18:20:15 -0500
committermat <github@matdoes.dev>2022-05-28 18:20:15 -0500
commit5d764c79d0b2be9a57a863cd2cb31ca47c16beca (patch)
tree4b1d5bc669b4747c500d6a79626f031770bdef34
parentff2f3c7af5bd4c1a1c10fa7c269830b9081319e4 (diff)
downloadazalea-drasl-5d764c79d0b2be9a57a863cd2cb31ca47c16beca.tar.xz
genblocks
-rw-r--r--azalea-block/block-macros/src/lib.rs6
-rw-r--r--azalea-block/src/blocks.rs4
-rw-r--r--codegen/genblocks.py13
-rw-r--r--codegen/lib/code/blocks.py17
-rw-r--r--codegen/newpacket.py7
5 files changed, 40 insertions, 7 deletions
diff --git a/azalea-block/block-macros/src/lib.rs b/azalea-block/block-macros/src/lib.rs
index 3d937ac4..63e21e58 100644
--- a/azalea-block/block-macros/src/lib.rs
+++ b/azalea-block/block-macros/src/lib.rs
@@ -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);
diff --git a/azalea-block/src/blocks.rs b/azalea-block/src/blocks.rs
index beba877e..88253e34 100644
--- a/azalea-block/src/blocks.rs
+++ b/azalea-block/src/blocks.rs
@@ -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,
diff --git a/codegen/genblocks.py b/codegen/genblocks.py
new file mode 100644
index 00000000..70004820
--- /dev/null
+++ b/codegen/genblocks.py
@@ -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)
diff --git a/codegen/lib/code/blocks.py b/codegen/lib/code/blocks.py
new file mode 100644
index 00000000..bf1260ba
--- /dev/null
+++ b/codegen/lib/code/blocks.py
@@ -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)
diff --git a/codegen/newpacket.py b/codegen/newpacket.py
index 52d6a2b4..48d97640 100644
--- a/codegen/newpacket.py
+++ b/codegen/newpacket.py
@@ -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]