Cactus Placement

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

View file

@ -30,4 +30,21 @@ class CactusBlock extends TransparentBlock{
parent::__construct(CACTUS, 0, "Cactus");
}
public function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
if($block->inWorld === true){
$down = $level->getBlockFace($block, 0);
if($down->getID() === SAND or $down->getID() === CACTUS){
$block0 = $level->getBlockFace($block, 2);
$block1 = $level->getBlockFace($block, 3);
$block2 = $level->getBlockFace($block, 4);
$block3 = $level->getBlockFace($block, 5);
if($block0->isFlowable === true and $block1->isFlowable === true and $block2->isFlowable === true and $block3->isFlowable === true){
$level->setBlock($block, $this->id, 0);
return true;
}
}
}
return false;
}
}