Added generic block relative place/break on Level

This commit is contained in:
Shoghi Cervantes
2014-03-13 23:04:49 +01:00
parent 91c4cbfedb
commit 279472b01a
97 changed files with 903 additions and 762 deletions

View File

@@ -21,9 +21,9 @@
namespace PocketMine\Block;
use PocketMine;
use PocketMine\Item\Item;
use PocketMine\Level\Level;
use PocketMine;
class Potato extends Flowable{
public function __construct($meta = 0){
@@ -32,7 +32,7 @@ class Potato extends Flowable{
$this->hardness = 0;
}
public function place(Item $item, PocketMine\Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, PocketMine\Player $player = null){
$down = $this->getSide(0);
if($down->getID() === self::FARMLAND){
$this->level->setBlock($block, $this, true, false, true);
@@ -43,7 +43,7 @@ class Potato extends Flowable{
return false;
}
public function onActivate(Item $item, PocketMine\Player $player){
public function onActivate(Item $item, PocketMine\Player $player = null){
if($item->getID() === Item::DYE and $item->getMetadata() === 0x0F){ //Bonemeal
$this->meta = 0x07;
$this->level->setBlock($this, $this, true, false, true);
@@ -66,7 +66,7 @@ class Potato extends Flowable{
return Level::BLOCK_UPDATE_NORMAL;
}
} elseif($type === Level::BLOCK_UPDATE_RANDOM){
}elseif($type === Level::BLOCK_UPDATE_RANDOM){
if(mt_rand(0, 2) == 1){
if($this->meta < 0x07){
++$this->meta;
@@ -74,7 +74,7 @@ class Potato extends Flowable{
return Level::BLOCK_UPDATE_RANDOM;
}
} else{
}else{
return Level::BLOCK_UPDATE_RANDOM;
}
}
@@ -82,11 +82,11 @@ class Potato extends Flowable{
return false;
}
public function getDrops(Item $item, PocketMine\Player $player){
public function getDrops(Item $item){
$drops = array();
if($this->meta >= 0x07){
$drops[] = array(Item::POTATO, 0, mt_rand(1, 4));
} else{
}else{
$drops[] = array(Item::POTATO, 0, 1);
}