diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index bce2aa180..16be22499 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -3715,7 +3715,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ } } - public function attack($damage, EntityDamageEvent $source){ + public function attack(EntityDamageEvent $source){ if(!$this->isAlive()){ return; } @@ -3730,7 +3730,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $source->setCancelled(); } - parent::attack($damage, $source); + parent::attack($source); if($source->isCancelled()){ return; diff --git a/src/pocketmine/block/Cactus.php b/src/pocketmine/block/Cactus.php index f9f4c1ac1..62da396d8 100644 --- a/src/pocketmine/block/Cactus.php +++ b/src/pocketmine/block/Cactus.php @@ -68,7 +68,7 @@ class Cactus extends Transparent{ public function onEntityCollide(Entity $entity){ $ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_CONTACT, 1); - $entity->attack($ev->getFinalDamage(), $ev); + $entity->attack($ev); } public function onUpdate(int $type){ diff --git a/src/pocketmine/block/Fire.php b/src/pocketmine/block/Fire.php index 6e62d516f..51a872fec 100644 --- a/src/pocketmine/block/Fire.php +++ b/src/pocketmine/block/Fire.php @@ -63,7 +63,7 @@ class Fire extends Flowable{ public function onEntityCollide(Entity $entity){ $ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, 1); - $entity->attack($ev->getFinalDamage(), $ev); + $entity->attack($ev); $ev = new EntityCombustByBlockEvent($this, $entity, 8); if($entity instanceof Arrow){ diff --git a/src/pocketmine/block/Lava.php b/src/pocketmine/block/Lava.php index 2b557fa2c..d5001c9e6 100644 --- a/src/pocketmine/block/Lava.php +++ b/src/pocketmine/block/Lava.php @@ -52,7 +52,7 @@ class Lava extends Liquid{ $entity->fallDistance *= 0.5; $ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, 4); - $entity->attack($ev->getFinalDamage(), $ev); + $entity->attack($ev); $ev = new EntityCombustByBlockEvent($this, $entity, 15); Server::getInstance()->getPluginManager()->callEvent($ev); diff --git a/src/pocketmine/block/Magma.php b/src/pocketmine/block/Magma.php index beff40d1a..81578023c 100644 --- a/src/pocketmine/block/Magma.php +++ b/src/pocketmine/block/Magma.php @@ -60,7 +60,7 @@ class Magma extends Solid{ public function onEntityCollide(Entity $entity){ if(!$entity->isSneaking()){ $ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, 1); - $entity->attack($ev->getFinalDamage(), $ev); + $entity->attack($ev); } } diff --git a/src/pocketmine/entity/Effect.php b/src/pocketmine/entity/Effect.php index 1241c5b34..e06b16a62 100644 --- a/src/pocketmine/entity/Effect.php +++ b/src/pocketmine/entity/Effect.php @@ -337,19 +337,19 @@ class Effect{ case Effect::POISON: if($entity->getHealth() > 1){ $ev = new EntityDamageEvent($entity, EntityDamageEvent::CAUSE_MAGIC, 1); - $entity->attack($ev->getFinalDamage(), $ev); + $entity->attack($ev); } break; case Effect::WITHER: $ev = new EntityDamageEvent($entity, EntityDamageEvent::CAUSE_MAGIC, 1); - $entity->attack($ev->getFinalDamage(), $ev); + $entity->attack($ev); break; case Effect::REGENERATION: if($entity->getHealth() < $entity->getMaxHealth()){ $ev = new EntityRegainHealthEvent($entity, 1, EntityRegainHealthEvent::CAUSE_MAGIC); - $entity->heal($ev->getAmount(), $ev); + $entity->heal($ev); } break; @@ -362,13 +362,13 @@ class Effect{ //TODO: add particles (witch spell) if($entity->getHealth() < $entity->getMaxHealth()){ $amount = 2 * (2 ** ($this->getEffectLevel() % 32)); - $entity->heal($amount, new EntityRegainHealthEvent($entity, $amount, EntityRegainHealthEvent::CAUSE_MAGIC)); + $entity->heal(new EntityRegainHealthEvent($entity, $amount, EntityRegainHealthEvent::CAUSE_MAGIC)); } break; case Effect::INSTANT_DAMAGE: //TODO: add particles (witch spell) $amount = 2 * (2 ** ($this->getEffectLevel() % 32)); - $entity->attack($amount, new EntityDamageEvent($entity, EntityDamageEvent::CAUSE_MAGIC, $amount)); + $entity->attack(new EntityDamageEvent($entity, EntityDamageEvent::CAUSE_MAGIC, $amount)); break; } } diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 114da9a6b..b776a2d45 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -883,11 +883,9 @@ abstract class Entity extends Location implements Metadatable{ } /** - * @param float $damage * @param EntityDamageEvent $source - * */ - public function attack($damage, EntityDamageEvent $source){ + public function attack(EntityDamageEvent $source){ $this->server->getPluginManager()->callEvent($source); if($source->isCancelled()){ return; @@ -913,11 +911,9 @@ abstract class Entity extends Location implements Metadatable{ } /** - * @param float $amount * @param EntityRegainHealthEvent $source - * */ - public function heal($amount, EntityRegainHealthEvent $source){ + public function heal(EntityRegainHealthEvent $source){ $this->server->getPluginManager()->callEvent($source); if($source->isCancelled()){ return; @@ -1125,7 +1121,7 @@ abstract class Entity extends Location implements Metadatable{ if($this->y <= -16 and $this->isAlive()){ $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_VOID, 10); - $this->attack($ev->getFinalDamage(), $ev); + $this->attack($ev); $hasUpdate = true; } @@ -1173,7 +1169,7 @@ abstract class Entity extends Location implements Metadatable{ */ protected function dealFireDamage(){ $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_FIRE_TICK, 1); - $this->attack($ev->getFinalDamage(), $ev); + $this->attack($ev); } protected function updateMovement(){ diff --git a/src/pocketmine/entity/FallingSand.php b/src/pocketmine/entity/FallingSand.php index c54298218..1ee67cf03 100644 --- a/src/pocketmine/entity/FallingSand.php +++ b/src/pocketmine/entity/FallingSand.php @@ -74,9 +74,9 @@ class FallingSand extends Entity{ return false; } - public function attack($damage, EntityDamageEvent $source){ + public function attack(EntityDamageEvent $source){ if($source->getCause() === EntityDamageEvent::CAUSE_VOID){ - parent::attack($damage, $source); + parent::attack($source); } } diff --git a/src/pocketmine/entity/Human.php b/src/pocketmine/entity/Human.php index db36c093c..121746bc8 100644 --- a/src/pocketmine/entity/Human.php +++ b/src/pocketmine/entity/Human.php @@ -402,19 +402,19 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ $this->addFood(1.0); } if($this->foodTickTimer % 20 === 0 and $health < $this->getMaxHealth()){ - $this->heal(1, new EntityRegainHealthEvent($this, 1, EntityRegainHealthEvent::CAUSE_SATURATION)); + $this->heal(new EntityRegainHealthEvent($this, 1, EntityRegainHealthEvent::CAUSE_SATURATION)); } } if($this->foodTickTimer === 0){ if($food >= 18){ if($health < $this->getMaxHealth()){ - $this->heal(1, new EntityRegainHealthEvent($this, 1, EntityRegainHealthEvent::CAUSE_SATURATION)); + $this->heal(new EntityRegainHealthEvent($this, 1, EntityRegainHealthEvent::CAUSE_SATURATION)); $this->exhaust(3.0, PlayerExhaustEvent::CAUSE_HEALTH_REGEN); } }elseif($food <= 0){ if(($difficulty === 1 and $health > 10) or ($difficulty === 2 and $health > 1) or $difficulty === 3){ - $this->attack(1, new EntityDamageEvent($this, EntityDamageEvent::CAUSE_STARVATION, 1)); + $this->attack(new EntityDamageEvent($this, EntityDamageEvent::CAUSE_STARVATION, 1)); } } } diff --git a/src/pocketmine/entity/Item.php b/src/pocketmine/entity/Item.php index f45088c0c..93dd238df 100644 --- a/src/pocketmine/entity/Item.php +++ b/src/pocketmine/entity/Item.php @@ -87,14 +87,14 @@ class Item extends Entity{ $this->server->getPluginManager()->callEvent(new ItemSpawnEvent($this)); } - public function attack($damage, EntityDamageEvent $source){ + public function attack(EntityDamageEvent $source){ if( $source->getCause() === EntityDamageEvent::CAUSE_VOID or $source->getCause() === EntityDamageEvent::CAUSE_FIRE_TICK or $source->getCause() === EntityDamageEvent::CAUSE_ENTITY_EXPLOSION or $source->getCause() === EntityDamageEvent::CAUSE_BLOCK_EXPLOSION ){ - parent::attack($damage, $source); + parent::attack($source); } } diff --git a/src/pocketmine/entity/Living.php b/src/pocketmine/entity/Living.php index 11b9b4cb7..be73a0582 100644 --- a/src/pocketmine/entity/Living.php +++ b/src/pocketmine/entity/Living.php @@ -157,8 +157,8 @@ abstract class Living extends Entity implements Damageable{ //return $this->getLevel()->rayTraceBlocks(Vector3::createVector($this->x, $this->y + $this->height, $this->z), Vector3::createVector($entity->x, $entity->y + $entity->height, $entity->z)) === null; } - public function heal($amount, EntityRegainHealthEvent $source){ - parent::heal($amount, $source); + public function heal(EntityRegainHealthEvent $source){ + parent::heal($source); if($source->isCancelled()){ return; } @@ -321,14 +321,14 @@ abstract class Living extends Entity implements Damageable{ $damage = floor($fallDistance - 3 - ($this->hasEffect(Effect::JUMP) ? $this->getEffect(Effect::JUMP)->getEffectLevel() : 0)); if($damage > 0){ $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_FALL, $damage); - $this->attack($ev->getFinalDamage(), $ev); + $this->attack($ev); } } - public function attack($damage, EntityDamageEvent $source){ + public function attack(EntityDamageEvent $source){ if($this->attackTime > 0 or $this->noDamageTicks > 0){ $lastCause = $this->getLastDamageCause(); - if($lastCause !== null and $lastCause->getDamage() >= $damage){ + if($lastCause !== null and $lastCause->getDamage() >= $source->getDamage()){ $source->setCancelled(); } } @@ -346,7 +346,7 @@ abstract class Living extends Entity implements Damageable{ $source->setDamage(-($source->getDamage(EntityDamageEvent::MODIFIER_BASE) * 0.20 * $this->getEffect(Effect::DAMAGE_RESISTANCE)->getEffectLevel()), EntityDamageEvent::MODIFIER_RESISTANCE); } - parent::attack($damage, $source); + parent::attack($source); if($source->isCancelled()){ return; @@ -365,7 +365,7 @@ abstract class Living extends Entity implements Damageable{ $deltaX = $this->x - $e->x; $deltaZ = $this->z - $e->z; - $this->knockBack($e, $damage, $deltaX, $deltaZ, $source->getKnockBack()); + $this->knockBack($e, $source->getDamage(), $deltaX, $deltaZ, $source->getKnockBack()); } } @@ -428,7 +428,7 @@ abstract class Living extends Entity implements Damageable{ if($this->isInsideOfSolid()){ $hasUpdate = true; $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_SUFFOCATION, 1); - $this->attack($ev->getFinalDamage(), $ev); + $this->attack($ev); } if(!$this->hasEffect(Effect::WATER_BREATHING) and $this->isInsideOfWater()){ @@ -441,7 +441,7 @@ abstract class Living extends Entity implements Damageable{ $airTicks = 0; $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_DROWNING, 2); - $this->attack($ev->getFinalDamage(), $ev); + $this->attack($ev); } $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, $airTicks); } @@ -453,7 +453,7 @@ abstract class Living extends Entity implements Damageable{ $airTicks = 0; $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_SUFFOCATION, 2); - $this->attack($ev->getFinalDamage(), $ev); + $this->attack($ev); } $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, $airTicks); }else{ diff --git a/src/pocketmine/entity/PrimedTNT.php b/src/pocketmine/entity/PrimedTNT.php index 1d248a8a4..2530ee5ac 100644 --- a/src/pocketmine/entity/PrimedTNT.php +++ b/src/pocketmine/entity/PrimedTNT.php @@ -48,9 +48,9 @@ class PrimedTNT extends Entity implements Explosive{ public $canCollide = false; - public function attack($damage, EntityDamageEvent $source){ + public function attack(EntityDamageEvent $source){ if($source->getCause() === EntityDamageEvent::CAUSE_VOID){ - parent::attack($damage, $source); + parent::attack($source); } } diff --git a/src/pocketmine/entity/Projectile.php b/src/pocketmine/entity/Projectile.php index 03ef87172..b8e8fb618 100644 --- a/src/pocketmine/entity/Projectile.php +++ b/src/pocketmine/entity/Projectile.php @@ -49,9 +49,9 @@ abstract class Projectile extends Entity{ parent::__construct($level, $nbt); } - public function attack($damage, EntityDamageEvent $source){ + public function attack(EntityDamageEvent $source){ if($source->getCause() === EntityDamageEvent::CAUSE_VOID){ - parent::attack($damage, $source); + parent::attack($source); } } @@ -88,7 +88,7 @@ abstract class Projectile extends Entity{ $ev = new EntityDamageByChildEntityEvent($this->getOwningEntity(), $this, $entity, EntityDamageEvent::CAUSE_PROJECTILE, $damage); } - $entity->attack($ev->getFinalDamage(), $ev); + $entity->attack($ev); $this->hadCollision = true; diff --git a/src/pocketmine/entity/Squid.php b/src/pocketmine/entity/Squid.php index 40826c446..b46cf3d33 100644 --- a/src/pocketmine/entity/Squid.php +++ b/src/pocketmine/entity/Squid.php @@ -53,8 +53,8 @@ class Squid extends WaterAnimal{ return "Squid"; } - public function attack($damage, EntityDamageEvent $source){ - parent::attack($damage, $source); + public function attack(EntityDamageEvent $source){ + parent::attack($source); if($source->isCancelled()){ return; } diff --git a/src/pocketmine/level/Explosion.php b/src/pocketmine/level/Explosion.php index 18d419d1a..03313efef 100644 --- a/src/pocketmine/level/Explosion.php +++ b/src/pocketmine/level/Explosion.php @@ -187,7 +187,7 @@ class Explosion{ $ev = new EntityDamageEvent($entity, EntityDamageEvent::CAUSE_BLOCK_EXPLOSION, $damage); } - $entity->attack($ev->getFinalDamage(), $ev); + $entity->attack($ev); $entity->setMotion($motion->multiply($impact)); } }