aboutsummaryrefslogtreecommitdiff
path: root/codegen/lib
diff options
context:
space:
mode:
Diffstat (limited to 'codegen/lib')
-rwxr-xr-x[-rw-r--r--]codegen/lib/code/blocks.py0
-rw-r--r--codegen/lib/code/entity.py36
-rwxr-xr-x[-rw-r--r--]codegen/lib/code/packet.py0
-rwxr-xr-x[-rw-r--r--]codegen/lib/code/registry.py0
-rwxr-xr-x[-rw-r--r--]codegen/lib/code/shapes.py0
-rwxr-xr-x[-rw-r--r--]codegen/lib/code/utils.py0
-rwxr-xr-x[-rw-r--r--]codegen/lib/code/version.py0
-rwxr-xr-x[-rw-r--r--]codegen/lib/download.py0
-rwxr-xr-x[-rw-r--r--]codegen/lib/extract.py0
-rwxr-xr-x[-rw-r--r--]codegen/lib/mappings.py0
-rwxr-xr-x[-rw-r--r--]codegen/lib/utils.py0
11 files changed, 35 insertions, 1 deletions
diff --git a/codegen/lib/code/blocks.py b/codegen/lib/code/blocks.py
index c32a3bbc..c32a3bbc 100644..100755
--- a/codegen/lib/code/blocks.py
+++ b/codegen/lib/code/blocks.py
diff --git a/codegen/lib/code/entity.py b/codegen/lib/code/entity.py
index 13f99022..9b976ef6 100644
--- a/codegen/lib/code/entity.py
+++ b/codegen/lib/code/entity.py
@@ -44,7 +44,7 @@ def generate_entity_metadata(burger_entity_data: dict, mappings: Mappings):
code.append('use azalea_block::BlockState;')
code.append('use azalea_chat::Component;')
code.append('use azalea_core::{BlockPos, Direction, Particle, Slot};')
- code.append('use std::{collections::VecDeque, ops::Deref};')
+ code.append('use std::{collections::VecDeque, ops::{Deref, DerefMut}};')
code.append('use uuid::Uuid;')
code.append('')
@@ -271,6 +271,10 @@ def generate_entity_metadata(burger_entity_data: dict, mappings: Mappings):
code.append(
f'fn deref(&self) -> &Self::Target {{ &self.{parent_field_name} }}')
code.append('}')
+ code.append(f'impl DerefMut for {struct_name} {{')
+ code.append(
+ f'fn deref_mut(&mut self) -> &mut Self::Target {{ &mut self.{parent_field_name} }}')
+ code.append('}')
code.append('')
# make the EntityMetadata enum from entity_structs
@@ -309,6 +313,36 @@ def generate_entity_metadata(burger_entity_data: dict, mappings: Mappings):
code.append('}')
code.append('')
+ # impl Deref for EntityMetadata {
+ # type Target = AbstractEntity;
+ # fn deref(&self) -> &Self::Target {
+ # match self {
+ # EntityMetadata::Allay(entity) => entity,
+ # _ => {}
+ # }
+ # }
+ # }
+ code.append('impl Deref for EntityMetadata {')
+ code.append('type Target = AbstractEntity;')
+ code.append('fn deref(&self) -> &Self::Target {')
+ code.append('match self {')
+ for struct_name in entity_structs:
+ code.append(
+ f'EntityMetadata::{struct_name}(entity) => entity,')
+ code.append('}')
+ code.append('}')
+ code.append('}')
+ code.append('impl DerefMut for EntityMetadata {')
+ code.append('fn deref_mut(&mut self) -> &mut Self::Target {')
+ code.append('match self {')
+ for struct_name in entity_structs:
+ code.append(
+ f'EntityMetadata::{struct_name}(entity) => entity,')
+ code.append('}')
+ code.append('}')
+ code.append('}')
+ code.append('')
+
with open(METADATA_RS_DIR, 'w') as f:
f.write('\n'.join(code))
diff --git a/codegen/lib/code/packet.py b/codegen/lib/code/packet.py
index 4beccd35..4beccd35 100644..100755
--- a/codegen/lib/code/packet.py
+++ b/codegen/lib/code/packet.py
diff --git a/codegen/lib/code/registry.py b/codegen/lib/code/registry.py
index c22eefe9..c22eefe9 100644..100755
--- a/codegen/lib/code/registry.py
+++ b/codegen/lib/code/registry.py
diff --git a/codegen/lib/code/shapes.py b/codegen/lib/code/shapes.py
index 9cf3093a..9cf3093a 100644..100755
--- a/codegen/lib/code/shapes.py
+++ b/codegen/lib/code/shapes.py
diff --git a/codegen/lib/code/utils.py b/codegen/lib/code/utils.py
index 66b18eed..66b18eed 100644..100755
--- a/codegen/lib/code/utils.py
+++ b/codegen/lib/code/utils.py
diff --git a/codegen/lib/code/version.py b/codegen/lib/code/version.py
index 35779af6..35779af6 100644..100755
--- a/codegen/lib/code/version.py
+++ b/codegen/lib/code/version.py
diff --git a/codegen/lib/download.py b/codegen/lib/download.py
index 5988f8ec..5988f8ec 100644..100755
--- a/codegen/lib/download.py
+++ b/codegen/lib/download.py
diff --git a/codegen/lib/extract.py b/codegen/lib/extract.py
index e66b9400..e66b9400 100644..100755
--- a/codegen/lib/extract.py
+++ b/codegen/lib/extract.py
diff --git a/codegen/lib/mappings.py b/codegen/lib/mappings.py
index 7cbb863a..7cbb863a 100644..100755
--- a/codegen/lib/mappings.py
+++ b/codegen/lib/mappings.py
diff --git a/codegen/lib/utils.py b/codegen/lib/utils.py
index efabbb38..efabbb38 100644..100755
--- a/codegen/lib/utils.py
+++ b/codegen/lib/utils.py