Low level PMF level interface

This commit is contained in:
Shoghi Cervantes
2013-09-08 01:21:40 +02:00
parent 1abe7626bf
commit 275e27f7a9
3 changed files with 95 additions and 11 deletions

View File

@ -20,8 +20,8 @@
*/
class Level{
public $entities, $tiles, $blockUpdates, $nextSave, $players = array();
private $level, $time, $startCheck, $startTime, $server, $name, $usedChunks, $changedBlocks, $changedCount;
public $entities, $tiles, $blockUpdates, $nextSave, $players = array(), $level;
private $time, $startCheck, $startTime, $server, $name, $usedChunks, $changedBlocks, $changedCount;
public function __construct(PMFLevel $level, Config $entities, Config $tiles, Config $blockUpdates, $name){
$this->server = ServerAPI::request();
@ -263,6 +263,11 @@ class Level{
$this->nextSave = microtime(true) + 45;
}
public function getBlockRaw(Vector3 $pos){
$b = $this->level->getBlock($pos->x, $pos->y, $pos->z);
return BlockAPI::get($b[0], $b[1], new Position($pos->x, $pos->y, $pos->z, $this));
}
public function getBlock(Vector3 $pos){
if(!isset($this->level) or ($pos instanceof Position) and $pos->level !== $this){
return false;
@ -272,9 +277,6 @@ class Level{
}
public function setBlockRaw(Vector3 $pos, Block $block, $direct = true, $send = true){
if(!isset($this->level)){
return false;
}
if(($ret = $this->level->setBlock($pos->x, $pos->y, $pos->z, $block->getID(), $block->getMetadata())) === true and $send !== false){
if($direct === true){
$this->server->api->player->broadcastPacket($this->players, MC_UPDATE_BLOCK, array(