Skip to content

Commit

Permalink
Added Void Generator
Browse files Browse the repository at this point in the history
  • Loading branch information
atTheDisco authored Mar 26, 2019
1 parent 1231828 commit e173577
Showing 1 changed file with 91 additions and 0 deletions.
91 changes: 91 additions & 0 deletions src/pocketmine/level/generator/VoidGenerator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php

/*
* _ _
* /\ | | |
* / \ | | |_ __ _ _ _
* / /\ \ | | __/ _` | | | |
* / ____ \| | || (_| | |_| |
* /_/ \_|_|\__\__,_|\__, |
* __/ |
* |___/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author TuranicTeam
* @link https://github.com/TuranicTeam/Altay
*
*/

declare(strict_types=1);

namespace pocketmine\level\generator;

use pocketmine\block\Block;
use pocketmine\level\ChunkManager;
use pocketmine\level\format\Chunk;
use pocketmine\math\Vector3;
use pocketmine\utils\Random;

class VoidGenerator extends Generator{
/** @var Chunk */
private $emptyChunk = null;

public function __construct(array $options = []){
$this->generateEmptyChunk();
}

public function init(ChunkManager $level, Random $random) : void{
parent::init($level, $random);
}

public function getSettings() : array{
return [];
}

public function getName() : string{
return "Void";
}

public function generateEmptyChunk() : void{
$chunk = new Chunk(0, 0);
$chunk->setGenerated();

for($Z = 0; $Z < 16; ++$Z){
for($X = 0; $X < 16; ++$X){
$chunk->setBiomeId($X, $Z, 1);
for($y = 0; $y < 256; ++$y){
$chunk->setBlock($X, $y, $Z, Block::AIR, 0);
}
}
}

$this->emptyChunk = $chunk;
}

public function generateChunk(int $chunkX, int $chunkZ) : void{
$chunk = clone $this->emptyChunk;

$spawn = $this->getSpawn();
if(($spawn->x >> 4) === $chunkX and ($spawn->z >> 4) === $chunkZ){
//why?
}

$chunk->setX($chunkX);
$chunk->setZ($chunkZ);

$this->level->setChunk($chunkX, $chunkZ, $chunk);
}

public function populateChunk(int $chunkX, int $chunkZ) : void{

}

public function getSpawn() : Vector3{
return new Vector3(128, 72, 128);
}

}

0 comments on commit e173577

Please sign in to comment.