From 8e8e3a6da0b977c3a52311c31bdd2e4c90478082 Mon Sep 17 00:00:00 2001 From: chill <7596236+cthill@users.noreply.github.com> Date: Tue, 3 Oct 2023 00:01:29 -0700 Subject: [PATCH 1/2] allow mobs to attack while on jump-through blocks --- server/src/world/mob.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/server/src/world/mob.py b/server/src/world/mob.py index 95e4c82..9f5c720 100644 --- a/server/src/world/mob.py +++ b/server/src/world/mob.py @@ -135,21 +135,17 @@ def _step_active(self): self.xspeed = 0 x_plus_speed_as_int = int(round(self.x + self.xspeed)) - x_as_int = int(round(self.x)) y_as_int = int(round(self.y)) bbox_side = BoundingBox(x_plus_speed_as_int - self.x_offset, y_as_int - self.y_offset, self.w, self.h) side_collide = self.world.solid_block_at(bbox_side) - bbox_below = BoundingBox(x_as_int - self.x_offset, y_as_int - self.y_offset + 1, self.w, self.h) - ground_below = self.world.solid_block_at(bbox_below) - # walk, jump, atk + on_ground = self._move_yspeed_check_ground_collide() self._walk_step() - self._atk_step(ground_below) - self._jump_step(side_collide, ground_below) + self._atk_step(on_ground) + self._jump_step(side_collide, on_ground) self._move_xspeed_check_side_collide(side_collide) - self._move_yspeed_check_ground_collide() self.update_world_position(self.x, self.y) self._do_animation() @@ -307,7 +303,7 @@ def _move_yspeed_check_ground_collide(self): self.y += self.yspeed if self.y - self.y_offset > config.WORLD_HEIGHT + 300: self._die(broadcast_death=False) - return + return False elif self.y < 0: self.y = 0 @@ -326,6 +322,7 @@ def _move_yspeed_check_ground_collide(self): self.y = min_touching_y - self.h + self.y_offset self.xspeed_knockback = 0 self.yspeed = 0 + return True else: sliver_height = config.WORLD_TERMINAL_VELOCITY + 1 bottom_sliver_bbox = BoundingBox(x_as_int - self.x_offset, y_as_int - self.y_offset + self.h - sliver_height, self.w, sliver_height) @@ -340,6 +337,9 @@ def _move_yspeed_check_ground_collide(self): self.y = min_touching_y - self.h + self.y_offset self.xspeed_knockback = 0 self.yspeed = 0 + return True + + return False def _do_animation(self): if self.sprite_index == SPRITE_INDEX_ATTACK and self.image_index >= self.sprite['frames']: From 5c7f70e23c62c75d8646f7dcc632e29acaa2ecf8 Mon Sep 17 00:00:00 2001 From: chill <7596236+cthill@users.noreply.github.com> Date: Tue, 3 Oct 2023 00:23:50 -0700 Subject: [PATCH 2/2] move in x and y before doing walk/atk/jump animations --- server/src/world/mob.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/world/mob.py b/server/src/world/mob.py index 9f5c720..2d869aa 100644 --- a/server/src/world/mob.py +++ b/server/src/world/mob.py @@ -141,11 +141,11 @@ def _step_active(self): side_collide = self.world.solid_block_at(bbox_side) # walk, jump, atk + self._move_xspeed_check_side_collide(side_collide) on_ground = self._move_yspeed_check_ground_collide() self._walk_step() self._atk_step(on_ground) self._jump_step(side_collide, on_ground) - self._move_xspeed_check_side_collide(side_collide) self.update_world_position(self.x, self.y) self._do_animation()