Working Threaded Generation

This commit is contained in:
Shoghi Cervantes
2014-06-10 20:45:09 +02:00
parent 392eb74901
commit fa50cbf4b3
56 changed files with 1631 additions and 1733 deletions

View File

@ -26,7 +26,6 @@ use pocketmine\entity\Entity;
use pocketmine\level\format\Chunk;
use pocketmine\level\format\ChunkSection;
use pocketmine\level\format\LevelProvider;
use pocketmine\level\Level;
use pocketmine\nbt\tag\Compound;
use pocketmine\nbt\tag\String;
use pocketmine\tile\Chest;
@ -58,6 +57,8 @@ abstract class BaseChunk implements Chunk{
* @param ChunkSection[] $sections
* @param Compound[] $entities
* @param Compound[] $tiles
*
* @throws \Exception
*/
protected function __construct(LevelProvider $level, $x, $z, array $sections, array $entities = [], array $tiles = []){
$this->level = new \WeakRef($level);
@ -68,14 +69,11 @@ abstract class BaseChunk implements Chunk{
$this->sections[$Y] = $section;
}else{
trigger_error("Received invalid ChunkSection instance", E_USER_ERROR);
return;
throw new \Exception("Received invalid ChunkSection instance");
}
if($section >= self::SECTION_COUNT){
trigger_error("Invalid amount of chunks", E_USER_WARNING);
return;
if($Y >= self::SECTION_COUNT){
throw new \Exception("Invalid amount of chunks");
}
}

View File

@ -20,6 +20,7 @@
*/
namespace pocketmine\level\format\generic;
use pocketmine\level\format\LevelProvider;
use pocketmine\level\Level;
use pocketmine\math\Vector3;
@ -73,14 +74,22 @@ abstract class BaseLevelProvider implements LevelProvider{
$this->levelData->Time = new Int("Time", (int) $value);
}
public function getSeed(){
return $this->levelData["RandomSeed"];
}
public function setSeed($value){
$this->levelData->RandomSeed = new Int("RandomSeed", (int) $value);
}
public function getSpawn(){
return new Vector3($this->levelData["SpawnX"], $this->levelData["SpawnY"], $this->levelData["SpawnZ"]);
}
public function setSpawn(Vector3 $pos){
$this->levelData->SpawnX = new Int("SpawnX", $pos->x);
$this->levelData->SpawnY = new Int("SpawnY", $pos->y);
$this->levelData->SpawnZ = new Int("SpawnZ", $pos->z);
$this->levelData->SpawnX = new Int("SpawnX", (int) $pos->x);
$this->levelData->SpawnY = new Int("SpawnY", (int) $pos->y);
$this->levelData->SpawnZ = new Int("SpawnZ", (int) $pos->z);
}
/**

View File

@ -27,6 +27,17 @@ use pocketmine\level\format\ChunkSection;
* Stub used to detect empty chunks
*/
class EmptyChunkSection implements ChunkSection{
private $y;
public function __construct($y){
$this->y = $y;
}
final public function getY(){
return $this->y;
}
final public function getBlockId($x, $y, $z){
return 0;
}
@ -39,6 +50,15 @@ class EmptyChunkSection implements ChunkSection{
return "\x00\x00\x00\x00\x00\x00\x00\x00";
}
final public function getBlock($x, $y, $z, &$id = null, &$meta = null){
$id = 0;
$meta = 0;
}
final public function setBlock($x, $y, $z, $id = null, $meta = null){
throw new \Exception("Tried to modify an empty Chunk");
}
public function getIdArray(){
return str_repeat("\x00", 4096);
}
@ -56,7 +76,7 @@ class EmptyChunkSection implements ChunkSection{
}
final public function setBlockId($x, $y, $z, $id){
throw new \Exception("Tried to modify an empty Chunk");
}
final public function getBlockData($x, $y, $z){
@ -64,7 +84,7 @@ class EmptyChunkSection implements ChunkSection{
}
final public function setBlockData($x, $y, $z, $data){
throw new \Exception("Tried to modify an empty Chunk");
}
final public function getBlockLight($x, $y, $z){
@ -72,7 +92,7 @@ class EmptyChunkSection implements ChunkSection{
}
final public function setBlockLight($x, $y, $z, $level){
throw new \Exception("Tried to modify an empty Chunk");
}
final public function getBlockSkyLight($x, $y, $z){
@ -80,6 +100,6 @@ class EmptyChunkSection implements ChunkSection{
}
final public function setBlockSkyLight($x, $y, $z, $level){
throw new \Exception("Tried to modify an empty Chunk");
}
}