mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 20:49:43 +00:00
cacti and ded buses in the desert
This commit is contained in:
parent
bb045abb09
commit
92b89194f1
2 changed files with 47 additions and 10 deletions
|
|
@ -50,7 +50,7 @@ class NormalGenerator implements NewLevelGenerator{
|
||||||
new OreType(new StoneBlock(5), 12, 16, 0, 128),
|
new OreType(new StoneBlock(5), 12, 16, 0, 128),
|
||||||
));
|
));
|
||||||
$this->populators[] = $ores;
|
$this->populators[] = $ores;
|
||||||
|
$this->populators[] = new DesertPopulator(); //TODO biome populators
|
||||||
$trees = new BiomeBasedTreePopulator();
|
$trees = new BiomeBasedTreePopulator();
|
||||||
$trees->setBaseAmount(8);
|
$trees->setBaseAmount(8);
|
||||||
$trees->setRandomAmount(2);
|
$trees->setRandomAmount(2);
|
||||||
|
|
@ -123,17 +123,15 @@ class NormalGenerator implements NewLevelGenerator{
|
||||||
}
|
}
|
||||||
}elseif($y <= $this->waterHeight){
|
}elseif($y <= $this->waterHeight){
|
||||||
if(($this->waterHeight - $y) <= 1 and $diff === 0){
|
if(($this->waterHeight - $y) <= 1 and $diff === 0){
|
||||||
$chunk .= "\x0c"; //sand
|
$chunk .= ($biomeID === BIOME_TAIGA) ? chr(GRASS) : chr(SAND);
|
||||||
}elseif($diff === 0){
|
}elseif($diff === 0){
|
||||||
/*if($patchesSmall[$i] > 0.3){
|
$chunk .= "\x03"; //dirt
|
||||||
$chunk .= "\x0d"; //gravel
|
|
||||||
}elseif($patchesSmall[$i] < -0.45){
|
|
||||||
$chunk .= "\x0c"; //sand
|
|
||||||
}else{*/
|
|
||||||
$chunk .= "\x03"; //dirt
|
|
||||||
//}
|
|
||||||
}else{
|
}else{
|
||||||
|
//if($y === $this->waterHeight && $biomeID == BIOME_TAIGA){
|
||||||
|
// $chunk .= chr(ICE);
|
||||||
|
///}else{
|
||||||
$chunk .= "\x09"; //still_water
|
$chunk .= "\x09"; //still_water
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
}elseif($diff === 0){
|
}elseif($diff === 0){
|
||||||
if($patches[$i] > 0.7){
|
if($patches[$i] > 0.7){
|
||||||
|
|
@ -161,7 +159,6 @@ class NormalGenerator implements NewLevelGenerator{
|
||||||
$this->level->level->setPopulated($chunkX, $chunkZ, true);
|
$this->level->level->setPopulated($chunkX, $chunkZ, true);
|
||||||
$this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
|
$this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
|
||||||
foreach($this->populators as $populator){
|
foreach($this->populators as $populator){
|
||||||
$this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
|
|
||||||
$populator->populate($this->level, $chunkX, $chunkZ, $this->random);
|
$populator->populate($this->level, $chunkX, $chunkZ, $this->random);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
40
src/world/generator/populator/DesertPopulator.php
Normal file
40
src/world/generator/populator/DesertPopulator.php
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class DesertPopulator extends Populator //TODO Biome Decorators ?
|
||||||
|
{
|
||||||
|
public function populate(Level $level, $chunkX, $chunkZ, Random $random)
|
||||||
|
{
|
||||||
|
for($i = 0; $i < 4; ++$i){
|
||||||
|
$x = $chunkX*16 + $random->nextRange(0, 15);
|
||||||
|
$z = $chunkZ*16 + $random->nextRange(0, 15);
|
||||||
|
if($level->level->getBiomeId($x, $z) === BIOME_DESERT){
|
||||||
|
$y = $this->getHighestWorkableBlock($level, $x, $z);
|
||||||
|
$level->level->setBlockID($x, $y, $z, DEAD_BUSH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for($i = 0; $i < 2; ++$i){
|
||||||
|
$x = $chunkX*16 + $random->nextRange(0, 15);
|
||||||
|
$z = $chunkZ*16 + $random->nextRange(0, 15);
|
||||||
|
if($level->level->getBiomeId($x, $z) === BIOME_DESERT){
|
||||||
|
$y = $this->getHighestWorkableBlock($level, $x, $z);
|
||||||
|
$cactiSize = $random->nextRange(0, 3);
|
||||||
|
for($yOff = 0; $yOff < $cactiSize; ++$yOff){
|
||||||
|
$level->level->setBlockID($x, $y + $yOff, $z, CACTUS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getHighestWorkableBlock(Level $level, $x, $z){
|
||||||
|
for($y = 128; $y > 0; --$y){
|
||||||
|
$b = $level->level->getBlockID($x, $y, $z);
|
||||||
|
if($b == SAND && $level->level->getBlockID($x, $y + 1, $z) == 0){
|
||||||
|
return $y + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue