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.
This commit is contained in:
williamtdr 2013-07-31 21:45:23 -05:00
parent c1e1f5195b
commit f3f6828699

View File

@ -1402,7 +1402,7 @@ class Player{
$this->craftingItems = array(); $this->craftingItems = array();
$this->toCraft = array(); $this->toCraft = array();
$target = $this->server->api->entity->get($data["target"]); $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["targetentity"] = $target;
$data["entity"] = $this->entity; $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)){ if($target->class === ENTITY_PLAYER and ($this->server->api->getProperty("pvp") == false or $this->server->difficulty <= 0 or ($target->player->gamemode & 0x01) === 0x01)){
@ -1475,6 +1475,7 @@ class Player{
} }
} }
} }
break; break;
case MC_ANIMATE: case MC_ANIMATE:
if($this->spawned === false){ if($this->spawned === false){