From 7624eda7b12f7b766c48a747efa7b731ab873131 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Fri, 11 Jul 2014 16:24:04 +0200 Subject: [PATCH] Update damage sources for creative mode players --- src/pocketmine/entity/Living.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/entity/Living.php b/src/pocketmine/entity/Living.php index 8993eca5d..fa20a507d 100644 --- a/src/pocketmine/entity/Living.php +++ b/src/pocketmine/entity/Living.php @@ -58,9 +58,23 @@ 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 and $source != EntityDamageEvent::CAUSE_MAGIC and $source != EntityDamageEvent::CAUSE_SUICIDE and $source != EntityDamageEvent::CAUSE_VOID) { - return; + + 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();