Fixed long trunk generation

This commit is contained in:
Shoghi Cervantes 2015-04-15 20:47:18 +02:00
parent 7f28deefcb
commit fc2e4ddc63
No known key found for this signature in database
GPG Key ID: 78464DB0A7837F89
2 changed files with 11 additions and 7 deletions

View File

@ -54,12 +54,14 @@ class SpruceTree extends Tree{
$xOff = abs($xx - $x);
for($zz = $z - $radius; $zz <= $z + $radius; ++$zz){
$zOff = abs($zz - $z);
if(($xOff === 0 and $zOff === 0) or ($xOff === $radius and $zOff === $radius and $radius > 0)){
if($xOff === $radius and $zOff === $radius and $radius > 0){
continue;
}
$level->setBlockIdAt($xx, $yyy, $zz, $this->leafBlock);
$level->setBlockDataAt($xx, $yyy, $zz, $this->type);
if(!Block::$solid[$level->getBlockIdAt($xx, $yyy, $zz)]){
$level->setBlockIdAt($xx, $yyy, $zz, $this->leafBlock);
$level->setBlockDataAt($xx, $yyy, $zz, $this->type);
}
}
}

View File

@ -102,11 +102,13 @@ abstract class Tree{
$xOff = abs($xx - $x);
for($zz = $z - $mid; $zz <= $z + $mid; ++$zz){
$zOff = abs($zz - $z);
if(($xOff === 0 and $zOff === 0) or ($xOff === $mid and $zOff === $mid and ($yOff === 0 or $random->nextBoundedInt(2) === 0))){
if($xOff === $mid and $zOff === $mid and ($yOff === 0 or $random->nextBoundedInt(2) === 0)){
continue;
}
$level->setBlockIdAt($xx, $yy, $zz, $this->leafBlock);
$level->setBlockDataAt($xx, $yy, $zz, $this->type);
if(!Block::$solid[$level->getBlockIdAt($xx, $yy, $zz)]){
$level->setBlockIdAt($xx, $yy, $zz, $this->leafBlock);
$level->setBlockDataAt($xx, $yy, $zz, $this->type);
}
}
}
}
@ -116,7 +118,7 @@ abstract class Tree{
// The base dirt block
$level->setBlockIdAt($x, $y - 1, $z, Block::DIRT);
for($yy = 0; $yy <= $trunkHeight; ++$yy){
for($yy = 0; $yy < $trunkHeight; ++$yy){
$blockId = $level->getBlockIdAt($x, $y + $yy, $z);
if(isset($this->overridable[$blockId])){
$level->setBlockIdAt($x, $y + $yy, $z, $this->trunkBlock);