Instant growth using bonemeal

This commit is contained in:
Shoghi Cervantes Pueyo 2013-02-04 19:00:21 +01:00
parent fee04cd0d9
commit 7e7f1892fd
3 changed files with 18 additions and 41 deletions

View File

@ -291,47 +291,6 @@ class BlockAPI{
$cancelPlace = true;
}
break;
case 2:
if($target[0] === 2 and $data["block"] === 351 and $data["meta"] === 0x0F){ //Bonemeal
for($c = 0; $c < 15; ++$c){
$x = mt_rand($target[2][0] - 2, $target[2][0] + 2);
$z = mt_rand($target[2][2] - 2, $target[2][2] + 2);
$b = $this->server->api->level->getBlock($x, $target[2][1] + 1, $z);
$d = $this->server->api->level->getBlock($x, $target[2][1], $z);
if($b[0] === 0 and $d[0] === 2){
$arr = array(
array(37, 0),
array(38, 0),
array(31, 1),
array(31, 1),
array(31, 1),
array(31, 1),
array(0, 0),
);
$t = $arr[mt_rand(0, count($arr) - 1)];
$this->server->api->level->setBlock($x, $target[2][1] + 1, $z, $t[0], $t[1]);
}
}
$cancelPlace = true;
break;
}
case 3:
if($data["block"] === 292){ //Hoe
$data["block"] = 60;
$data["meta"] = 0;
$this->server->handle("player.block.update", $data);
$cancelPlace = true;
}
break;
case 59:
case 105:
if($data["block"] === 351 and $data["meta"] === 0x0F){ //Bonemeal
$data["block"] = $target[0];
$data["meta"] = 0x07;
$this->server->handle("player.block.place", $data);
$cancelPlace = true;
}
break;
default:
$cancelPlace = true;
break;

View File

@ -28,6 +28,7 @@ the Free Software Foundation, either version 3 of the License, or
class MelonStemBlock extends TransparentBlock{
public function __construct($meta = 0){
parent::__construct(MELON_STEM, $meta, "Melon Stem");
$this->isActivable = true;
}
public function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
if($block->inWorld === true){
@ -40,6 +41,14 @@ class MelonStemBlock extends TransparentBlock{
return false;
}
public function onActivate(BlockAPI $level, Item $item, Player $player){
if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
$level->setBlock($this, $this->id, 0x07);
return true;
}
return false;
}
public function getDrops(Item $item, Player $player){
return array(
array(MELON_SEEDS, 0, mt_rand(0, 2)),

View File

@ -28,6 +28,7 @@ the Free Software Foundation, either version 3 of the License, or
class WheatBlock extends FlowableBlock{
public function __construct($meta = 0){
parent::__construct(WHEAT_BLOCK, $meta, "Wheat Block");
$this->isActivable = true;
}
public function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
@ -41,6 +42,14 @@ class WheatBlock extends FlowableBlock{
return false;
}
public function onActivate(BlockAPI $level, Item $item, Player $player){
if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
$level->setBlock($this, $this->id, 0x07);
return true;
}
return false;
}
public function getDrops(Item $item, Player $player){
$drops = array();
if($this->meta >= 0x07){