aboutsummaryrefslogtreecommitdiff
path: root/codegen/lib/code
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2022-11-12 23:54:05 -0600
committerGitHub <noreply@github.com>2022-11-12 23:54:05 -0600
commit6eee543a3367d38a6f0e9bffb457a2bd76a8f9cc (patch)
treea5e493ccd7ec24293b8d866242c3836146517122 /codegen/lib/code
parentfa57d03627aa20b1df44caed7cb025b6db1d9b53 (diff)
downloadazalea-drasl-6eee543a3367d38a6f0e9bffb457a2bd76a8f9cc.tar.xz
Pathfinder (#25)
Pathfinding is very much not done, but it works enough and I want to get this merged. TODO: fast replanning, goals that aren't a single node, falling moves (it should be able to play the dropper), parkour moves
Diffstat (limited to 'codegen/lib/code')
-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
7 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