mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Removed obsolete parameters from Entity->attack() and Entity->heal()
This commit is contained in:
parent
b62597fe63
commit
456ddd3fb3
@ -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;
|
||||
|
@ -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){
|
||||
|
@ -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){
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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(){
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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{
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user