aboutsummaryrefslogtreecommitdiff
path: root/codegen/lib/code
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2025-08-14 20:40:13 -0500
committerGitHub <noreply@github.com>2025-08-14 20:40:13 -0500
commite74ed047dbaf3877db4a89a2d589e992abd0bb11 (patch)
tree0a728c8be167a1d59a5492ed9df666f41cf12e57 /codegen/lib/code
parent6695132ddb31780786c67b8b9ff5df8ab3891438 (diff)
downloadazalea-drasl-e74ed047dbaf3877db4a89a2d589e992abd0bb11.tar.xz
Sneaking (#237)
* start implementing sneaking * fix horizontal_collision being inverted and cleanup * clippy * change dimensions and eye height based on pose * proper support for automatically crouching in certain cases * fix anticheat issues * add line to changelog and update a comment
Diffstat (limited to 'codegen/lib/code')
-rw-r--r--codegen/lib/code/entity.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/codegen/lib/code/entity.py b/codegen/lib/code/entity.py
index d4b43d58..31cf71a8 100644
--- a/codegen/lib/code/entity.py
+++ b/codegen/lib/code/entity.py
@@ -152,6 +152,10 @@ impl From<EntityDataValue> for UpdateMetadataError {
# some generic names... we don't like these
duplicate_field_names.add("state") # SnifferState instead of State
+ duplicate_field_names.add("crouching") # FoxCrouching instead of Crouching
+
+ # make this one longer to avoid accidental use -- AbstractEntityShiftKeyDown instead of ShiftKeydown
+ duplicate_field_names.add("shift_key_down")
for entity_id in burger_entity_metadata.keys():
field_name_map[entity_id] = {}
@@ -626,7 +630,7 @@ impl From<EntityDataValue> for UpdateMetadataError {
def generate_entity_dimensions(burger_entities_data: dict):
# lines look like
- # EntityKind::Player => EntityDimensions::new(0.6, 1.8),
+ # EntityKind::Player => EntityDimensions::new(0.6, 1.8).eye_height(1.62),
new_match_lines = []
for entity_id, entity_data in burger_entities_data["entity"].items():
if entity_id.startswith("~"):
@@ -635,9 +639,10 @@ def generate_entity_dimensions(burger_entities_data: dict):
variant_name: str = upper_first_letter(to_camel_case(entity_id))
width = entity_data["width"]
height = entity_data["height"]
- new_match_lines.append(
- f" EntityKind::{variant_name} => EntityDimensions::new({width}, {height}),"
- )
+ expr = f"EntityDimensions::new({width}, {height})"
+ if "eye_height" in entity_data:
+ expr += f".eye_height({entity_data['eye_height']})"
+ new_match_lines.append(f" EntityKind::{variant_name} => {expr},")
with open(DIMENSIONS_RS_DIR, "r") as f:
lines = f.read().split("\n")
@@ -650,7 +655,7 @@ def generate_entity_dimensions(burger_entities_data: dict):
if line.strip() == "match entity {":
in_match = True
else:
- if line.strip() == "}":
+ if line == " }":
new_lines.extend(new_match_lines)
new_lines.extend(lines[i:])
break