Skip to content

Commit

Permalink
Merge pull request #1 from KnosTx/KnosTx-patch-1
Browse files Browse the repository at this point in the history
Mace Implementation.                     JavierLeon9966
  • Loading branch information
KnosTx authored Sep 9, 2024
2 parents 17eb827 + 61c4426 commit fe61117
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/item/Mace.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
use pocketmine\block\BlockToolType;
use pocketmine\entity\Entity;
use pocketmine\entity\Living;
use pocketmine\math\Vector3;
use pocketmine\player\Player;
use pocketmine\world\particle\HugeExplodeParticle;
use pocketmine\world\sound\MaceSmashAirSound;
Expand Down Expand Up @@ -85,21 +84,26 @@ public function onAttackEntity(Entity $victim, array &$returnedItems) : bool{
$fallDistance = $holder->getFallDistance();

if($fallDistance >= self::SMASH_ATTACK_FALL_HEIGHT){

$damage = self::SMASH_ATTACK_DAMAGE + (int)($fallDistance * 2);
$damage = self::SMASH_ATTACK_DAMAGE + (int) ( $fallDistance * 2);
$world->addSound($position, new MaceSmashGroundSound());
$world->addParticle($position, new HugeExplodeParticle());
$holder->resetFallDistance();

foreach($victim->getWorld()->getNearbyEntities($victim->getBoundingBox()->expandedCopy(3, 3, 3)) as $nearbyEntity){
if($nearbyEntity instanceof Living && $nearbyEntity !== $holder){
$knockbackVector = $nearbyEntity->getPosition()->subtract($holder->getPosition())->normalize()->multiply(0.4);
$knockbackVector = $nearbyEntity->getPosition()->subtract(
$holder->getPosition()->getX(),
$holder->getPosition()->getY(),
$holder->getPosition()->getZ()
)->normalize()->multiply(0.4);
$nearbyEntity->knockBack($knockbackVector->x, $knockbackVector->z, 0.4);
}
}
return $this->applyDamage(1);
}
}

$victim->setHealth($victim->getHealth() - self::NORMAL_ATTACK_DAMAGE);
return $this->applyDamage(1);
}
}

0 comments on commit fe61117

Please sign in to comment.