From 2e0b64e76bee8bd51265841200e7ee8ebadbe48c Mon Sep 17 00:00:00 2001 From: IvanCraft623 Date: Fri, 19 Apr 2024 16:21:51 -0500 Subject: [PATCH] IronGolem: Broadcast throw sound on attacks --- src/IvanCraft623/MobPlugin/entity/Mob.php | 6 ++- .../MobPlugin/entity/golem/IronGolem.php | 7 +++ .../MobPlugin/sound/ThrowSound.php | 46 +++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/IvanCraft623/MobPlugin/sound/ThrowSound.php diff --git a/src/IvanCraft623/MobPlugin/entity/Mob.php b/src/IvanCraft623/MobPlugin/entity/Mob.php index 8fba502..9c60c7d 100644 --- a/src/IvanCraft623/MobPlugin/entity/Mob.php +++ b/src/IvanCraft623/MobPlugin/entity/Mob.php @@ -457,6 +457,10 @@ public function getPerceivedDistanceSqrForMeleeAttack(Entity $target) : float{ return $this->location->distanceSquared($target->getPosition()); } + protected function doAttackAnimation() : void{ + $this->broadcastAnimation(new ArmSwingAnimation($this)); + } + /** * Attacks the given entity with the currently-held item. * TODO: make a PR that implements this un PM core. @@ -492,7 +496,7 @@ public function attackEntity(Entity $entity) : bool{ $entity->attack($ev); - $this->broadcastAnimation(new ArmSwingAnimation($this), $this->getViewers()); + $this->doAttackAnimation(); if ($this->isOnFire()) { $entity->setOnFire(8); diff --git a/src/IvanCraft623/MobPlugin/entity/golem/IronGolem.php b/src/IvanCraft623/MobPlugin/entity/golem/IronGolem.php index bf80648..d4c5836 100644 --- a/src/IvanCraft623/MobPlugin/entity/golem/IronGolem.php +++ b/src/IvanCraft623/MobPlugin/entity/golem/IronGolem.php @@ -39,6 +39,7 @@ use IvanCraft623\MobPlugin\pattern\BlockPatternBuilder; use IvanCraft623\MobPlugin\sound\IronGolemCrackSound; use IvanCraft623\MobPlugin\sound\IronGolemRepairSound; +use IvanCraft623\MobPlugin\sound\ThrowSound; use IvanCraft623\MobPlugin\utils\Utils; use pocketmine\block\Block; @@ -214,6 +215,12 @@ protected function entityBaseTick(int $tickDiff = 1) : bool{ return $hasUpdate; } + protected function doAttackAnimation() : void{ + parent::doAttackAnimation(); + + $this->broadcastSound(new ThrowSound($this)); + } + public function attack(EntityDamageEvent $source) : void{ $crackiness = $this->getCrackiness(); diff --git a/src/IvanCraft623/MobPlugin/sound/ThrowSound.php b/src/IvanCraft623/MobPlugin/sound/ThrowSound.php new file mode 100644 index 0000000..f05ca53 --- /dev/null +++ b/src/IvanCraft623/MobPlugin/sound/ThrowSound.php @@ -0,0 +1,46 @@ +entity::getNetworkTypeId(), + false, + false + )]; + } +}