Removed EntityAPI

This commit is contained in:
Shoghi Cervantes
2014-02-27 16:47:49 +01:00
parent e314f46b5b
commit 2bf3f0de73
23 changed files with 142 additions and 224 deletions

View File

@ -20,6 +20,8 @@
*/
class Level{
public $players = array();
public $entities = array();
public $chunkEntities = array();
@ -204,6 +206,14 @@ class Level{
$nbt->Entities->setTagType(NBTTag::TAG_Compound);
$nbt->TileEntities->setTagType(NBTTag::TAG_Compound);
$i = 0;
foreach($this->chunkEntities[$index] as $entity){
if($entity->closed !== true){
$nbt->Entities[$i] = $entity->namedtag;
++$i;
}
}
$i = 0;
foreach($this->chunkTiles[$index] as $tile){
if($tile->closed !== true){
@ -294,7 +304,6 @@ class Level{
if($update === true){
$this->server->api->block->blockUpdateAround($pos, BLOCK_UPDATE_NORMAL, 1);
$this->server->api->entity->updateRadius($pos, 3);
}
if($tiles === true){
if(($t = $this->getTile($pos)) !== false){
@ -305,6 +314,18 @@ class Level{
return $ret;
}
public function getEntities(){
return $this->entities;
}
public function getTiles(){
return $this->tiles;
}
public function getPlayers(){
return $this->players;
}
public function getTile(Vector3 $pos){
if($pos instanceof Position and $pos->level !== $this){
return false;
@ -354,6 +375,8 @@ class Level{
return array();
}
public function loadChunk($X, $Z){
if(!isset($this->level)){
return false;
@ -365,6 +388,11 @@ class Level{
$this->usedChunks[$index] = array();
$this->chunkTiles[$index] = array();
$this->chunkEntities[$index] = array();
foreach($this->level->getChunkNBT($X, $Z)->Entities as $nbt){
switch($nbt->id){
//TODO: spawn entities
}
}
foreach($this->level->getChunkNBT($X, $Z)->TileEntities as $nbt){
switch($nbt->id){
case Tile::CHEST: