mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-11 04:17:48 +00:00
Instant growth using bonemeal
This commit is contained in:
parent
fee04cd0d9
commit
7e7f1892fd
@ -291,47 +291,6 @@ class BlockAPI{
|
|||||||
$cancelPlace = true;
|
$cancelPlace = true;
|
||||||
}
|
}
|
||||||
break;
|
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:
|
default:
|
||||||
$cancelPlace = true;
|
$cancelPlace = true;
|
||||||
break;
|
break;
|
||||||
|
@ -28,6 +28,7 @@ the Free Software Foundation, either version 3 of the License, or
|
|||||||
class MelonStemBlock extends TransparentBlock{
|
class MelonStemBlock extends TransparentBlock{
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(MELON_STEM, $meta, "Melon Stem");
|
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){
|
public function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||||
if($block->inWorld === true){
|
if($block->inWorld === true){
|
||||||
@ -40,6 +41,14 @@ class MelonStemBlock extends TransparentBlock{
|
|||||||
return false;
|
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){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return array(
|
||||||
array(MELON_SEEDS, 0, mt_rand(0, 2)),
|
array(MELON_SEEDS, 0, mt_rand(0, 2)),
|
||||||
|
@ -28,6 +28,7 @@ the Free Software Foundation, either version 3 of the License, or
|
|||||||
class WheatBlock extends FlowableBlock{
|
class WheatBlock extends FlowableBlock{
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(WHEAT_BLOCK, $meta, "Wheat Block");
|
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){
|
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;
|
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){
|
public function getDrops(Item $item, Player $player){
|
||||||
$drops = array();
|
$drops = array();
|
||||||
if($this->meta >= 0x07){
|
if($this->meta >= 0x07){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user