From f3f682869990244c7112be34e7ef98d670be1d6c Mon Sep 17 00:00:00 2001 From: williamtdr Date: Wed, 31 Jul 2013 21:45:23 -0500 Subject: [PATCH] Object check on getting distance for PvP attacks Fixes #586, although I'm not entirely sure what's causing the object to be invalid in the first case, so this is a temporal fix. --- src/Player.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Player.php b/src/Player.php index 467eeab8..e865ba98 100644 --- a/src/Player.php +++ b/src/Player.php @@ -1402,12 +1402,12 @@ class Player{ $this->craftingItems = array(); $this->toCraft = array(); $target = $this->server->api->entity->get($data["target"]); - if($this->gamemode !== VIEW and $this->blocked === false and ($target instanceof Entity) and $this->entity->distance($target) <= 8){ + if($target instanceof Entity and $this->entity instanceof Entity and $this->gamemode !== VIEW and $this->blocked === false and ($target instanceof Entity) and $this->entity->distance($target) <= 8){ $data["targetentity"] = $target; $data["entity"] = $this->entity; - if($target->class === ENTITY_PLAYER and ($this->server->api->getProperty("pvp") == false or $this->server->difficulty <= 0 or ($target->player->gamemode & 0x01) === 0x01)){ - break; - }elseif($this->server->handle("player.interact", $data) !== false){ + if($target->class === ENTITY_PLAYER and ($this->server->api->getProperty("pvp") == false or $this->server->difficulty <= 0 or ($target->player->gamemode & 0x01) === 0x01)){ + break; + }elseif($this->server->handle("player.interact", $data) !== false){ $slot = $this->getSlot($this->slot); switch($slot->getID()){ case WOODEN_SWORD: @@ -1475,6 +1475,7 @@ class Player{ } } } + break; case MC_ANIMATE: if($this->spawned === false){