From eccd82ca4bb2427f5819f1632a2914a93d2bb610 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sun, 13 Jul 2014 19:04:00 +0200 Subject: [PATCH] Moved player attack filter from Living to Player --- src/pocketmine/Player.php | 16 ++++++++++++++++ src/pocketmine/entity/Living.php | 17 ----------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 136cb52f6..aaf729dc3 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -2222,6 +2222,22 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ if($this->dead === true){ return; } + if(($this->getGamemode() & 0x01) === 1){ + if($source instanceof EntityDamageEvent){ + $cause = $source->getCause(); + }else{ + $cause = $source; + } + + if( + $cause !== EntityDamageEvent::CAUSE_MAGIC + and $cause !== EntityDamageEvent::CAUSE_SUICIDE + and $cause !== EntityDamageEvent::CAUSE_VOID + ){ + return; + } + } + $pk = new EntityEventPacket(); $pk->eid = 0; $pk->event = 2; diff --git a/src/pocketmine/entity/Living.php b/src/pocketmine/entity/Living.php index 7d3b1238e..033aa0469 100644 --- a/src/pocketmine/entity/Living.php +++ b/src/pocketmine/entity/Living.php @@ -59,23 +59,6 @@ abstract class Living extends Entity implements Damageable{ public abstract function getName(); public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC){ - - if($this instanceof Player and ($this->getGamemode() & 0x01) === 1){ - if($source instanceof EntityDamageEvent){ - $cause = $source->getCause(); - }else{ - $cause = $source; - } - - if( - $cause !== EntityDamageEvent::CAUSE_MAGIC - and $cause !== EntityDamageEvent::CAUSE_SUICIDE - and $cause !== EntityDamageEvent::CAUSE_VOID - ){ - return; - } - } - //TODO: attack tick limit $pk = new EntityEventPacket(); $pk->eid = $this->getID();