mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-08-27 21:45:08 +00:00
Tilling Dirt & Grass, tall gras growth
This commit is contained in:
parent
a718294a08
commit
fee04cd0d9
@ -84,19 +84,32 @@ class Item{
|
|||||||
switch($this->id){
|
switch($this->id){
|
||||||
case IRON_PICKAXE:
|
case IRON_PICKAXE:
|
||||||
return 3;
|
return 3;
|
||||||
case 270: //Wood
|
case WOODEN_PICKAXE:
|
||||||
return 1;
|
return 1;
|
||||||
case 274: //Stone
|
case STONE_PICKAXE:
|
||||||
return 2;
|
return 2;
|
||||||
case 278: //Diamond
|
case DIAMOND_PICKAXE:
|
||||||
return 4;
|
return 4;
|
||||||
case 285: //Gold
|
case GOLD_PICKAXE:
|
||||||
return 3;
|
return 3;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isHoe(){
|
||||||
|
switch($this->id){
|
||||||
|
case IRON_HOE:
|
||||||
|
case WOODEN_HOE:
|
||||||
|
case STONE_HOE:
|
||||||
|
case DIAMOND_HOE:
|
||||||
|
case GOLD_HOE:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function getDestroySpeed(Block $block, Player $player){
|
public function getDestroySpeed(Block $block, Player $player){
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ class MelonStemBlock extends TransparentBlock{
|
|||||||
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){
|
||||||
$down = $level->getBlockFace($block, 0);
|
$down = $level->getBlockFace($block, 0);
|
||||||
if($down->getID() === 60){
|
if($down->getID() === FARMLAND){
|
||||||
$level->setBlock($block, $this->id, $this->getMetadata());
|
$level->setBlock($block, $this->id, $this->getMetadata());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ class SaplingBlock extends TransparentBlock{
|
|||||||
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){
|
||||||
$down = $level->getBlockFace($block, 0);
|
$down = $level->getBlockFace($block, 0);
|
||||||
if($down->getID() === 2 or $down->getID() === 3 or $down->getID() === 60){
|
if($down->getID() === GRASS or $down->getID() === DIRT or $down->getID() === FARMLAND){
|
||||||
$level->setBlock($block, $this->id, $this->getMetadata());
|
$level->setBlock($block, $this->id, $this->getMetadata());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@ class SaplingBlock extends TransparentBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onActivate(BlockAPI $level, Item $item, Player $player){
|
public function onActivate(BlockAPI $level, Item $item, Player $player){
|
||||||
if($item->getID() === 351 and $item->getMetadata() === 0x0F){ //Bonemeal
|
if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
|
||||||
TreeObject::growTree($level, $this);
|
TreeObject::growTree($level, $this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ class WheatBlock extends FlowableBlock{
|
|||||||
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){
|
||||||
$down = $level->getBlockFace($block, 0);
|
$down = $level->getBlockFace($block, 0);
|
||||||
if($down->getID() === 60){
|
if($down->getID() === FARMLAND){
|
||||||
$level->setBlock($block, $this->id, $this->getMetadata());
|
$level->setBlock($block, $this->id, $this->getMetadata());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,14 @@ the Free Software Foundation, either version 3 of the License, or
|
|||||||
class DirtBlock extends SolidBlock{
|
class DirtBlock extends SolidBlock{
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(DIRT, 0, "Dirt");
|
parent::__construct(DIRT, 0, "Dirt");
|
||||||
|
$this->isActivable = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onActivate(BlockAPI $level, Item $item, Player $player){
|
||||||
|
if($item->isHoe()){
|
||||||
|
$level->setBlock($this, FARMLAND, 0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -28,10 +28,40 @@ the Free Software Foundation, either version 3 of the License, or
|
|||||||
class GrassBlock extends SolidBlock{
|
class GrassBlock extends SolidBlock{
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
parent::__construct(GRASS, 0, "Grass");
|
parent::__construct(GRASS, 0, "Grass");
|
||||||
|
$this->isActivable = true;
|
||||||
}
|
}
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array(
|
return array(
|
||||||
array(DIRT, 0, 1),
|
array(DIRT, 0, 1),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onActivate(BlockAPI $level, 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 = $level->getBlock(new Vector3($x, $this->y + 1, $z));
|
||||||
|
$d = $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)];
|
||||||
|
$level->setBlock($b, $t[0], $t[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}elseif($item->isHoe()){
|
||||||
|
$level->setBlock($this, FARMLAND, 0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user