PocketMine-MP 5.43.2 git-a137a986d01d9af23452b2e741699a770c7ae112
Loading...
Searching...
No Matches
VoidGenerator.php
1<?php
2
3/*
4 *
5 * ____ _ _ __ __ _ __ __ ____
6 * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7 * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8 * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9 * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10 *
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * @author PocketMine Team
17 * @link http://www.pocketmine.net/
18 *
19 *
20 */
21
22declare(strict_types=1);
23
25
31use pocketmine\world\format\PalettedBlockArray;
33
35 public function __construct(int $seed, string $preset){
36 parent::__construct($seed, $preset);
37 }
38
39 public function generateChunk(ChunkManager $world, int $chunkX, int $chunkZ) : void{
40 $chunk = new Chunk([], false);
41
42 $biomeArray = new PalettedBlockArray(BiomeIds::PLAINS);
43 foreach($chunk->getSubChunks() as $y => $subChunk){
44 $chunk->setSubChunk($y, new SubChunk(Block::EMPTY_STATE_ID, [], clone $biomeArray));
45 }
46
47 $stoneState = VanillaBlocks::STONE()->getStateId();
48 $cobbleState = VanillaBlocks::COBBLESTONE()->getStateId();
49
50 for($x = 0; $x < Chunk::EDGE_LENGTH; $x++){
51 for($z = 0; $z < Chunk::EDGE_LENGTH; $z++){
52 $worldX = ($chunkX * Chunk::EDGE_LENGTH) + $x;
53 $worldZ = ($chunkZ * Chunk::EDGE_LENGTH) + $z;
54
55 if($worldX >= -16 && $worldX <= 16 && $worldZ >= -16 && $worldZ <= 16){
56 $chunk->setBlockStateId($x, -64, $z, ($worldX === 0 && $worldZ === 0) ? $cobbleState : $stoneState);
57 }
58 }
59 }
60 $world->setChunk($chunkX, $chunkZ, $chunk);
61 }
62
63 public function populateChunk(ChunkManager $world, int $chunkX, int $chunkZ) : void{
64 //NOOP
65 }
66}