Added more features to the World Generator

This commit is contained in:
Shoghi Cervantes 2013-05-26 13:22:22 +02:00
parent 424dba2fdd
commit aefcfad296
10 changed files with 104 additions and 56 deletions

View file

@ -54,7 +54,7 @@ class SaplingBlock extends TransparentBlock{
public function onActivate(Item $item, Player $player){
if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
TreeObject::growTree($this->level, $this, $this->meta);
TreeObject::growTree($this->level, $this, new Random(), $this->meta & 0x03);
return true;
}
return false;
@ -63,7 +63,7 @@ class SaplingBlock extends TransparentBlock{
public function onUpdate($type){
if($type === BLOCK_UPDATE_RANDOM and mt_rand(0,2) === 0){ //Growth
if(($this->meta & 0x08) === 0x08){
TreeObject::growTree($this->level, $this);
TreeObject::growTree($this->level, $this, new Random(), $this->meta & 0x03);
}else{
$this->meta |= 0x08;
$this->level->setBlock($this, $this);

View file

@ -38,25 +38,7 @@ class GrassBlock extends SolidBlock{
public function onActivate(Item $item, Player $player){
if($item->getID() === DYE and $item->getMetadata() === 0x0F){
for($c = 0; $c < 15; ++$c){
$x = mt_rand($this->x - 2, $this->x + 2);
$z = mt_rand($this->z - 2, $this->z + 2);
$b = $this->level->getBlock(new Vector3($x, $this->y + 1, $z));
$d = $this->level->getBlock(new Vector3($x, $this->y, $z));
if($b->getID() === AIR and $d->getID() === GRASS){
$arr = array(
array(DANDELION, 0),
array(CYAN_FLOWER, 0),
array(TALL_GRASS, 1),
array(TALL_GRASS, 1),
array(TALL_GRASS, 1),
array(TALL_GRASS, 1),
array(AIR, 0),
);
$t = $arr[mt_rand(0, count($arr) - 1)];
$this->level->setBlock($b, BlockAPI::get($t[0], $t[1]));
}
}
TallGrassObject::growGrass($this->level, $this, new Random());
return true;
}elseif($item->isHoe()){
$this->level->setBlock($this, new FarmlandBlock());