From 3e882ef40d5dc8d69bc7027497bcc08740a2c29c Mon Sep 17 00:00:00 2001 From: williamtdr Date: Fri, 11 Jul 2014 09:12:19 -0500 Subject: [PATCH] Revert "Fix #1615" This reverts commit a8359f29a81a9cc6836b14535a3256f06853482b. --- src/pocketmine/entity/Living.php | 123 +++++++++++++++---------------- 1 file changed, 60 insertions(+), 63 deletions(-) diff --git a/src/pocketmine/entity/Living.php b/src/pocketmine/entity/Living.php index 93347507c..27bba8bcc 100644 --- a/src/pocketmine/entity/Living.php +++ b/src/pocketmine/entity/Living.php @@ -34,76 +34,73 @@ use pocketmine\item\Item; abstract class Living extends Entity implements Damageable{ - protected $gravity = 0.08; - protected $drag = 0.02; + protected $gravity = 0.08; + protected $drag = 0.02; - protected function initEntity(){ - if(isset($this->namedtag->HealF)){ - $this->namedtag->Health = new Short("Health", (int) $this->namedtag["HealF"]); - unset($this->namedtag->HealF); - } + protected function initEntity(){ + if(isset($this->namedtag->HealF)){ + $this->namedtag->Health = new Short("Health", (int) $this->namedtag["HealF"]); + unset($this->namedtag->HealF); + } - if(!isset($this->namedtag->Health) or !($this->namedtag->Health instanceof Short)){ - $this->namedtag->Health = new Short("Health", $this->getMaxHealth()); - } + if(!isset($this->namedtag->Health) or !($this->namedtag->Health instanceof Short)){ + $this->namedtag->Health = new Short("Health", $this->getMaxHealth()); + } - $this->setHealth($this->namedtag["Health"]); - } + $this->setHealth($this->namedtag["Health"]); + } - public function saveNBT(){ - parent::saveNBT(); - $this->namedtag->Health = new Short("Health", $this->getHealth()); - } + public function saveNBT(){ + parent::saveNBT(); + $this->namedtag->Health = new Short("Health", $this->getHealth()); + } - public abstract function getName(); + public abstract function getName(); - public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC){ - //TODO: attack tick limit - if($this instanceof Player && $this->getGamemode() === 1 && $source != EntityDamageEvent::CAUSE_MAGIC) { - return; - } - $pk = new EntityEventPacket(); - $pk->eid = $this->getID(); - $pk->event = 2; //Ouch! - Server::broadcastPacket($this->hasSpawned, $pk); - $this->setLastDamageCause($source); - $motion = new Vector3(0, 0, 0); - if($source instanceof EntityDamageByEntityEvent){ - $e = $source->getDamager(); - $deltaX = $this->x - $e->x; - $deltaZ = $this->z - $e->z; - $yaw = atan2($deltaX, $deltaZ); - $motion->x = sin($yaw) * 0.5; - $motion->z = cos($yaw) * 0.5; - } - $this->setMotion($motion); - $this->setHealth($this->getHealth() - $damage); + public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC){ + //TODO: attack tick limit + $pk = new EntityEventPacket(); + $pk->eid = $this->getID(); + $pk->event = 2; //Ouch! + Server::broadcastPacket($this->hasSpawned, $pk); + $this->setLastDamageCause($source); + $motion = new Vector3(0, 0, 0); + if($source instanceof EntityDamageByEntityEvent){ + $e = $source->getDamager(); + $deltaX = $this->x - $e->x; + $deltaZ = $this->z - $e->z; + $yaw = atan2($deltaX, $deltaZ); + $motion->x = sin($yaw) * 0.5; + $motion->z = cos($yaw) * 0.5; + } + $this->setMotion($motion); + $this->setHealth($this->getHealth() - $damage); - } + } - public function heal($amount){ - $this->server->getPluginManager()->callEvent($ev = new EntityRegainHealthEvent($this, $amount)); - if($ev->isCancelled()){ - return; - } - $this->setHealth($this->getHealth() + $amount); - } + public function heal($amount){ + $this->server->getPluginManager()->callEvent($ev = new EntityRegainHealthEvent($this, $amount)); + if($ev->isCancelled()){ + return; + } + $this->setHealth($this->getHealth() + $amount); + } - public function kill(){ - if($this->dead){ - return; - } - parent::kill(); - $this->server->getPluginManager()->callEvent($ev = new EntityDeathEvent($this, $this->getDrops())); - foreach($ev->getDrops() as $item){ - $this->getLevel()->dropItem($this, $item); - } - } + public function kill(){ + if($this->dead){ + return; + } + parent::kill(); + $this->server->getPluginManager()->callEvent($ev = new EntityDeathEvent($this, $this->getDrops())); + foreach($ev->getDrops() as $item){ + $this->getLevel()->dropItem($this, $item); + } + } - /** - * @return Item[] - */ - public function getDrops(){ - return []; - } -} + /** + * @return Item[] + */ + public function getDrops(){ + return []; + } +} \ No newline at end of file