GenisysPro  for Minecraft PE/Windows 10 v1.1.x
Feature-rich server software for Minecraft PE and Windows 10 Edition
GroundCover Class Reference

Public Member Functions

 populate (ChunkManager $level, $chunkX, $chunkZ, Random $random)
 
- Public Member Functions inherited from Populator
 populate (ChunkManager $level, $chunkX, $chunkZ, Random $random)
 

Member Function Documentation

◆ populate()

populate ( ChunkManager  $level,
  $chunkX,
  $chunkZ,
Random  $random 
)
Parameters
ChunkManager$level
$chunkX
$chunkZ
Random$random
Returns
mixed|void
41  {
42  $chunk = $level->getChunk($chunkX, $chunkZ);
43  if($level instanceof Level or $level instanceof SimpleChunkManager){
44  $waterHeight = $level->getWaterHeight();
45  }else $waterHeight = 0;
46  for($x = 0; $x < 16; ++$x){
47  for($z = 0; $z < 16; ++$z){
48  $biome = Biome::getBiome($chunk->getBiomeId($x, $z));
49  $cover = $biome->getGroundCover();
50  if(count($cover) > 0){
51  $diffY = 0;
52  if(!$cover[0]->isSolid()){
53  $diffY = 1;
54  }
55 
56  $column = $chunk->getBlockIdColumn($x, $z);
57  for($y = 127; $y > 0; --$y){
58  if($column{$y} !== "\x00" and !Block::get(ord($column{$y}))->isTransparent()){
59  break;
60  }
61  }
62  $startY = min(127, $y + $diffY);
63  $endY = $startY - count($cover);
64  for($y = $startY; $y > $endY and $y >= 0; --$y){
65  $b = $cover[$startY - $y];
66  if($column{$y} === "\x00" and $b->isSolid()){
67  break;
68  }
69  if($y <= $waterHeight and $b->getId() == Block::GRASS and $chunk->getBlockId($x, $y + 1, $z) == Block::STILL_WATER){
70  $b = Block::get(Block::DIRT);
71  }
72  if($b->getDamage() === 0){
73  $chunk->setBlockId($x, $y, $z, $b->getId());
74  }else{
75  $chunk->setBlock($x, $y, $z, $b->getId(), $b->getDamage());
76  }
77  }
78  }
79  }
80  }
81  }

The documentation for this class was generated from the following file: