From ea922db58358cef73f647ffee7a65f13f01a4fc2 Mon Sep 17 00:00:00 2001 From: KnosTx <135945845+KnosTx@users.noreply.github.com> Date: Tue, 10 Sep 2024 21:18:57 +0700 Subject: [PATCH] Mace Implementation --- src/item/Mace.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/item/Mace.php b/src/item/Mace.php index 17cd86a692..d9f6b7c5b7 100644 --- a/src/item/Mace.php +++ b/src/item/Mace.php @@ -49,7 +49,7 @@ public function getBlockToolHarvestLevel() : int{ } public function getMiningEfficiency(bool $isCorrectTool) : float{ - return parent::getMiningEfficiency($isCorrectTool) * 1.5; //swords break any block 1.5x faster than hand + return parent::getMiningEfficiency($isCorrectTool) * 1.5; } public function getBaseMiningEfficiency() : float{ @@ -63,23 +63,17 @@ public function onDestroyBlock(Block $block, array &$returnedItems) : bool{ return false; } - private function getDamager() : ?EntityDamageByEntityEvent{ - return $this->damager ?? null; - } - public function onAttackEntity(EntityDamageByEntityEvent $damager, Entity $victim, array &$returnedItems) : bool{ $damageEvent = $victim->getLastDamageCause(); - if($damageEvent instanceof EntityDamageEvent && $damageEvent->getCause() == EntityDamageEvent::CAUSE_ENTITY_ATTACK){ + if($damageEvent instanceof EntityDamageByEntityEvent){ - /** @var Entity|null $user */ $user = $damageEvent->getDamager(); if($user !== null){ $height = $user->getFallDistance(); if($height >= 2) { - // The damage dealt with the mace is boosted 5+ damage for every block fallen after the first. $damage = ($height - 1) * 5; $victim->setHealth($victim->getHealth() - $damage);