mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Updated Levels :D
This commit is contained in:
@ -21,7 +21,7 @@
|
||||
|
||||
namespace pocketmine\level\generator;
|
||||
|
||||
use pocketmine\block\Air;
|
||||
use pocketmine\level\generator\populator\Populator;
|
||||
use pocketmine\block\CoalOre;
|
||||
use pocketmine\block\DiamondOre;
|
||||
use pocketmine\block\Dirt;
|
||||
@ -31,13 +31,22 @@ use pocketmine\block\IronOre;
|
||||
use pocketmine\block\LapisOre;
|
||||
use pocketmine\block\RedstoneOre;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\format\SimpleChunk;
|
||||
use pocketmine\level\generator\populator\Ore;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\math\Vector3 as Vector3;
|
||||
use pocketmine\utils\Random;
|
||||
|
||||
class Flat extends Generator{
|
||||
private $level, $random, $structure, $chunks, $options, $floorLevel, $preset, $populators = [];
|
||||
/** @var GenerationChunkManager */
|
||||
private $level;
|
||||
/** @var SimpleChunk */
|
||||
private $chunk;
|
||||
/** @var Random */
|
||||
private $random;
|
||||
/** @var Populator[] */
|
||||
private $populators = [];
|
||||
private $structure, $chunks, $options, $floorLevel, $preset;
|
||||
|
||||
public function getSettings(){
|
||||
return $this->options;
|
||||
@ -75,7 +84,7 @@ class Flat extends Generator{
|
||||
}*/
|
||||
}
|
||||
|
||||
public function parsePreset($preset){
|
||||
protected function parsePreset($preset){
|
||||
$this->preset = $preset;
|
||||
$preset = explode(";", $preset);
|
||||
$version = (int) $preset[0];
|
||||
@ -90,30 +99,33 @@ class Flat extends Generator{
|
||||
$b = Item::fromString($b);
|
||||
$cnt = $matches[2][$i] === "" ? 1 : intval($matches[2][$i]);
|
||||
for($cY = $y, $y += $cnt; $cY < $y; ++$cY){
|
||||
$this->structure[$cY] = $b;
|
||||
$this->structure[$cY] = [$b->getID(),$b->getDamage()];
|
||||
}
|
||||
}
|
||||
|
||||
$this->floorLevel = $y;
|
||||
|
||||
for(; $y < 0xFF; ++$y){
|
||||
$this->structure[$y] = new Air();
|
||||
$this->structure[$y] = [0, 0];
|
||||
}
|
||||
|
||||
|
||||
$this->chunk = new SimpleChunk(null, null, SimpleChunk::FLAG_GENERATED);
|
||||
|
||||
for($Y = 0; $Y < 8; ++$Y){
|
||||
$this->chunks[$Y] = "";
|
||||
$startY = $Y << 4;
|
||||
$endY = $startY + 16;
|
||||
for($Z = 0; $Z < 16; ++$Z){
|
||||
for($X = 0; $X < 16; ++$X){
|
||||
$blocks = "";
|
||||
$metas = "";
|
||||
for($y = $startY; $y < $endY; ++$y){
|
||||
$blocks .= chr($this->structure[$y]->getID());
|
||||
$metas .= substr(dechex($this->structure[$y]->getDamage()), -1);
|
||||
if($this->structure[$y][0] !== 0){
|
||||
$this->chunk->setBlockId($X, $y, $Z, $this->structure[$y][0]);
|
||||
}
|
||||
if($this->structure[$y][0] !== 0){
|
||||
$this->chunk->setBlockData($X, $y, $Z, $this->structure[$y][1]);
|
||||
}
|
||||
}
|
||||
$this->chunks[$Y] .= $blocks . hex2bin($metas) . "\x00\x00\x00\x00\x00\x00\x00\x00";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -135,15 +147,16 @@ class Flat extends Generator{
|
||||
}
|
||||
}
|
||||
|
||||
public function init(Level $level, Random $random){
|
||||
public function init(GenerationChunkManager $level, Random $random){
|
||||
$this->level = $level;
|
||||
$this->random = $random;
|
||||
}
|
||||
|
||||
public function generateChunk($chunkX, $chunkZ){
|
||||
for($Y = 0; $Y < 8; ++$Y){
|
||||
$this->level->setMiniChunk($chunkX, $chunkZ, $Y, $this->chunks[$Y]);
|
||||
}
|
||||
$chunk = clone $this->chunk;
|
||||
$chunk->setX($chunkX);
|
||||
$chunk->setZ($chunkZ);
|
||||
$this->level->setChunk($chunkX, $chunkZ, $chunk);
|
||||
}
|
||||
|
||||
public function populateChunk($chunkX, $chunkZ){
|
||||
|
Reference in New Issue
Block a user