Attacking entities fixed

This commit is contained in:
Shoghi Cervantes Pueyo
2013-05-16 16:41:54 +02:00
parent 1f8987183b
commit 9a3f887f44
7 changed files with 44 additions and 101 deletions

View File

@ -179,7 +179,7 @@ class Entity extends Position{
private function spawnDrops(){
foreach($this->getDrops() as $drop){
$this->server->api->block->drop($this, BlockAPI::getItem($drop[0] & 0xFFFF, $drop[1] & 0xFFFF, $drop[2] & 0xFF), true);
$this->server->api->entity->drop($this, BlockAPI::getItem($drop[0] & 0xFFFF, $drop[1] & 0xFFFF, $drop[2] & 0xFF), true);
}
}

View File

@ -66,19 +66,17 @@ class Level{
if($this->server->api->dhandle("time.change", array("level" => $this, "time" => $time)) !== false){
$this->time = $time;
}
foreach($this->usedChunks as $i => $c){
if(count($c) === 0){
unset($this->usedChunks[$i]);
$X = explode(".", $i);
$Z = array_pop($X);
$this->level->unloadChunk((int) array_pop($X), (int) $Z);
}
}
if($this->nextSave < $now){
if($this->nextSave < $now and $this->server->saveEnabled === true){
foreach($this->usedChunks as $i => $c){
if(count($c) === 0){
unset($this->usedChunks[$i]);
$X = explode(".", $i);
$Z = array_pop($X);
$this->level->unloadChunk((int) array_pop($X), (int) $Z);
}
}
$this->save();
$this->lastSave = $now + 90;
}
}
@ -88,6 +86,9 @@ class Level{
}
public function save(){
if($this->server->saveEnabled === false){
return;
}
$entities = array();
foreach($this->server->api->entity->getAll($this) as $entity){
if($entity->class === ENTITY_MOB){
@ -157,6 +158,7 @@ class Level{
$this->level->setData("time", (int) $this->time);
$this->level->doSaveRound();
$this->level->saveData();
$this->lastSave = microtime(true) + 90;
}
public function getBlock(Vector3 $pos){

View File

@ -34,7 +34,7 @@ class Position extends Vector3{
}
public function distance($x = 0, $y = 0, $z = 0){
if($x instanceof Position and $x->level !== $this->level){
if(($x instanceof Position) and $x->level !== $this->level){
return PHP_INT_MAX;
}
return parent::distance($x, $y, $z);