mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Renamed TileEntity to Tile (TileEntityAPI, TileEntity class, variables)
This commit is contained in:
@ -26,14 +26,14 @@ the Free Software Foundation, either version 3 of the License, or
|
||||
*/
|
||||
|
||||
class Level{
|
||||
public $entities, $tileEntities, $nextSave, $players = array();
|
||||
public $entities, $tiles, $nextSave, $players = array();
|
||||
private $level, $time, $startCheck, $startTime, $server, $name, $usedChunks, $changedBlocks, $changedCount;
|
||||
|
||||
public function __construct(PMFLevel $level, Config $entities, Config $tileEntities, $name){
|
||||
public function __construct(PMFLevel $level, Config $entities, Config $tiles, $name){
|
||||
$this->server = ServerAPI::request();
|
||||
$this->level = $level;
|
||||
$this->entities = $entities;
|
||||
$this->tileEntities = $tileEntities;
|
||||
$this->tiles = $tiles;
|
||||
$this->startTime = $this->time = (int) $this->level->getData("time");
|
||||
$this->nextSave = $this->startCheck = microtime(true);
|
||||
$this->nextSave += 90;
|
||||
@ -216,11 +216,11 @@ class Level{
|
||||
$this->entities->setAll($entities);
|
||||
$this->entities->save();
|
||||
$tiles = array();
|
||||
foreach($this->server->api->tileentity->getAll($this) as $tile){
|
||||
foreach($this->server->api->tile->getAll($this) as $tile){
|
||||
$tiles[] = $tile->data;
|
||||
}
|
||||
$this->tileEntities->setAll($tiles);
|
||||
$this->tileEntities->save();
|
||||
$this->tiles->setAll($tiles);
|
||||
$this->tiles->save();
|
||||
|
||||
$this->level->setData("time", (int) $this->time);
|
||||
$this->level->doSaveRound();
|
||||
@ -295,7 +295,7 @@ class Level{
|
||||
$this->server->api->entity->updateRadius($pos, 3);
|
||||
}
|
||||
if($tiles === true){
|
||||
if(($t = $this->server->api->tileentity->get($pos)) !== false){
|
||||
if(($t = $this->server->api->tile->get($pos)) !== false){
|
||||
$t->close();
|
||||
}
|
||||
}
|
||||
|
@ -32,13 +32,13 @@ class LevelImport{
|
||||
}
|
||||
|
||||
public function import(){
|
||||
if(file_exists($this->path."tileEntities.dat")){ //OldPM
|
||||
if(file_exists($this->path."tiles.dat")){ //OldPM
|
||||
$level = unserialize(file_get_contents($this->path."level.dat"));
|
||||
console("[INFO] Importing OldPM level \"".$level["LevelName"]."\" to PMF format");
|
||||
$entities = new Config($this->path."entities.yml", CONFIG_YAML, unserialize(file_get_contents($this->path."entities.dat")));
|
||||
$entities->save();
|
||||
$tileEntities = new Config($this->path."tileEntities.yml", CONFIG_YAML, unserialize(file_get_contents($this->path."tileEntities.dat")));
|
||||
$tileEntities->save();
|
||||
$tiles = new Config($this->path."tiles.yml", CONFIG_YAML, unserialize(file_get_contents($this->path."tiles.dat")));
|
||||
$tiles->save();
|
||||
}elseif(file_exists($this->path."chunks.dat") and file_exists($this->path."level.dat")){ //Pocket
|
||||
$nbt = new NBT();
|
||||
$level = parseNBTData($nbt->loadFile($this->path."level.dat"));
|
||||
@ -51,12 +51,12 @@ class LevelImport{
|
||||
if(!isset($entities["TileEntities"])){
|
||||
$entities["TileEntities"] = array();
|
||||
}
|
||||
$tileEntities = $entities["TileEntities"];
|
||||
$tiles = $entities["TileEntities"];
|
||||
$entities = $entities["Entities"];
|
||||
$entities = new Config($this->path."entities.yml", CONFIG_YAML, $entities);
|
||||
$entities->save();
|
||||
$tileEntities = new Config($this->path."tileEntities.yml", CONFIG_YAML, $tileEntities);
|
||||
$tileEntities->save();
|
||||
$tiles = new Config($this->path."tiles.yml", CONFIG_YAML, $tiles);
|
||||
$tiles->save();
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
@ -113,8 +113,8 @@ class LevelImport{
|
||||
@unlink($this->path."entities.dat");
|
||||
@unlink($this->path."chunks.dat");
|
||||
@unlink($this->path."chunks.dat.gz");
|
||||
@unlink($this->path."tileEntities.dat");
|
||||
unset($chunks, $level, $entities, $tileEntities, $nbt);
|
||||
@unlink($this->path."tiles.dat");
|
||||
unset($chunks, $level, $entities, $tiles, $nbt);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ the Free Software Foundation, either version 3 of the License, or
|
||||
|
||||
*/
|
||||
|
||||
class TileEntity extends Position{
|
||||
class Tile extends Position{
|
||||
public $name;
|
||||
public $normal;
|
||||
public $id;
|
||||
@ -55,10 +55,10 @@ class TileEntity extends Position{
|
||||
$this->x = (int) $x;
|
||||
$this->y = (int) $y;
|
||||
$this->z = (int) $z;
|
||||
$this->server->query("INSERT OR REPLACE INTO tileentities (ID, level, class, x, y, z) VALUES (".$this->id.", '".$this->level->getName()."', '".$this->class."', ".$this->x.", ".$this->y.", ".$this->z.");");
|
||||
$this->server->query("INSERT OR REPLACE INTO tiles (ID, level, class, x, y, z) VALUES (".$this->id.", '".$this->level->getName()."', '".$this->class."', ".$this->x.", ".$this->y.", ".$this->z.");");
|
||||
switch($this->class){
|
||||
case TILE_SIGN:
|
||||
$this->server->query("UPDATE tileentities SET spawnable = 1 WHERE ID = ".$this->id.";");
|
||||
$this->server->query("UPDATE tiles SET spawnable = 1 WHERE ID = ".$this->id.";");
|
||||
break;
|
||||
case TILE_FURNACE:
|
||||
if(!isset($this->data["BurnTime"]) or $this->data["BurnTime"] < 0){
|
||||
@ -234,7 +234,7 @@ class TileEntity extends Position{
|
||||
public function close(){
|
||||
if($this->closed === false){
|
||||
$this->closed = true;
|
||||
$this->server->api->tileentity->remove($this->id);
|
||||
$this->server->api->tile->remove($this->id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,12 +250,12 @@ class TileEntity extends Position{
|
||||
public function setPosition(Vector3 $pos){
|
||||
if($pos instanceof Position){
|
||||
$this->level = $pos->level;
|
||||
$this->server->query("UPDATE tileentities SET level = '".$this->level->getName()."' WHERE ID = ".$this->id.";");
|
||||
$this->server->query("UPDATE tiles SET level = '".$this->level->getName()."' WHERE ID = ".$this->id.";");
|
||||
}
|
||||
$this->x = (int) $pos->x;
|
||||
$this->y = (int) $pos->y;
|
||||
$this->z = (int) $pos->z;
|
||||
$this->server->query("UPDATE tileentities SET x = ".$this->x.", y = ".$this->y.", z = ".$this->z." WHERE ID = ".$this->id.";");
|
||||
$this->server->query("UPDATE tiles SET x = ".$this->x.", y = ".$this->y.", z = ".$this->z." WHERE ID = ".$this->id.";");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -46,8 +46,8 @@ class WorldGenerator{
|
||||
"height" => $this->height
|
||||
));
|
||||
$entities = new Config($this->path."entities.yml", CONFIG_YAML);
|
||||
$tileEntities = new Config($this->path."tileEntities.yml", CONFIG_YAML);
|
||||
$this->level = new Level($level, $entities, $tileEntities, $name);
|
||||
$tiles = new Config($this->path."tiles.yml", CONFIG_YAML);
|
||||
$this->level = new Level($level, $entities, $tiles, $name);
|
||||
}
|
||||
|
||||
public function generate(){
|
||||
|
Reference in New Issue
Block a user