Pine & Spruce trees fixed

This commit is contained in:
Shoghi Cervantes 2013-05-26 13:36:33 +02:00
parent aefcfad296
commit 7622151a21
2 changed files with 9 additions and 9 deletions

View File

@ -57,22 +57,22 @@ class PineTreeObject extends TreeObject{
private function findRandomLeavesSize(Random $random){ private function findRandomLeavesSize(Random $random){
$this->totalHeight += $random->nextRange(-1, 2); $this->totalHeight += $random->nextRange(-1, 2);
$this->leavesSizeY = 1 + $random->nextRange(0, 2); $this->leavesSizeY = 1 + $random->nextRange(0, 2);
$this->leavesAbsoluteMaxRadius = 2 + $random->nextRange(0, 2); $this->leavesAbsoluteMaxRadius = 2 + $random->nextRange(0, 1);
} }
public function placeObject(Level $level, Vector3 $pos, Random $random){ public function placeObject(Level $level, Vector3 $pos, Random $random){
if($this->leavesSizeY === -1 or $this->leavesAbsoluteMaxRadius === -1) { if($this->leavesSizeY === -1 or $this->leavesAbsoluteMaxRadius === -1) {
$this->findRandomLeavesSize(); $this->findRandomLeavesSize($random);
} }
$level->setBlock(new Vector3($pos->x, $pos->y - 1, $pos->z), new DirtBlock()); $level->setBlock(new Vector3($pos->x, $pos->y - 1, $pos->z), new DirtBlock());
$leavesRadius = $random->nextRange(0, 2); $leavesRadius = 0;
$leavesMaxRadius = 1; $leavesMaxRadius = 1;
$leavesBottomY = $this->totalHeight - $this->leavesSizeY; $leavesBottomY = $this->totalHeight - $this->leavesSizeY;
$firstMaxedRadius = false; $firstMaxedRadius = false;
for($leavesY = 0; $leavesY < ($leavesBottomY + 1); ++$leavesY) { for($leavesY = 0; $leavesY <= $leavesBottomY; ++$leavesY) {
$yy = $this->totalHeight - $leavesY; $yy = $this->totalHeight - $leavesY;
for ($xx = -$leavesRadius; $xx < ($leavesRadius + 1); ++$xx) { for ($xx = -$leavesRadius; $xx <= $leavesRadius; ++$xx) {
for ($zz = -$leavesRadius; $zz < ($leavesRadius + 1); ++$zz) { for ($zz = -$leavesRadius; $zz <= $leavesRadius; ++$zz) {
if (abs($xx) != $leavesRadius or abs($zz) != $leavesRadius or $leavesRadius <= 0) { if (abs($xx) != $leavesRadius or abs($zz) != $leavesRadius or $leavesRadius <= 0) {
$level->setBlock(new Vector3($pos->x + $xx, $pos->y + $yy, $pos->z + $zz), new LeavesBlock($this->type)); $level->setBlock(new Vector3($pos->x + $xx, $pos->y + $yy, $pos->z + $zz), new LeavesBlock($this->type));
} }

View File

@ -67,14 +67,14 @@ class SpruceTreeObject extends TreeObject{
$level->setBlock(new Vector3($pos->x, $pos->y - 1, $pos->z), new DirtBlock()); $level->setBlock(new Vector3($pos->x, $pos->y - 1, $pos->z), new DirtBlock());
$leavesRadius = 0; $leavesRadius = 0;
for($yy = $this->totalHeight; $yy >= $this->leavesBottomY; --$yy){ for($yy = $this->totalHeight; $yy >= $this->leavesBottomY; --$yy){
for ($xx = -$leavesRadius; $xx < ($leavesRadius + 1); ++$xx) { for($xx = -$leavesRadius; $xx <= $leavesRadius; ++$xx) {
for ($zz = -$leavesRadius; $zz < ($leavesRadius + 1); ++$zz) { for($zz = -$leavesRadius; $zz <= $leavesRadius; ++$zz) {
if (abs($xx) != $leavesRadius or abs($zz) != $leavesRadius or $leavesRadius <= 0) { if (abs($xx) != $leavesRadius or abs($zz) != $leavesRadius or $leavesRadius <= 0) {
$level->setBlock(new Vector3($pos->x + $xx, $pos->y + $yy, $pos->z + $zz), new LeavesBLock($this->type)); $level->setBlock(new Vector3($pos->x + $xx, $pos->y + $yy, $pos->z + $zz), new LeavesBLock($this->type));
} }
} }
} }
if ($leavesRadius > 0 and $yy === ($pos->y + $this->leavesBottomY + 1)) { if($leavesRadius > 0 and $yy === ($pos->y + $this->leavesBottomY + 1)) {
--$leavesRadius; --$leavesRadius;
}elseif($leavesRadius < $this->leavesMaxRadius){ }elseif($leavesRadius < $this->leavesMaxRadius){
++$leavesRadius; ++$leavesRadius;