farmland and grass path should die when a solid block is above them

This commit is contained in:
Dylan K. Taylor 2017-10-12 11:11:33 +01:00
parent 35e7aca88f
commit 63fccd4682
2 changed files with 16 additions and 1 deletions

View File

@ -28,6 +28,7 @@ use pocketmine\item\ItemFactory;
use pocketmine\item\Tool;
use pocketmine\level\Level;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
class Farmland extends Transparent{
@ -65,7 +66,10 @@ class Farmland extends Transparent{
}
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_RANDOM){
if($type === Level::BLOCK_UPDATE_NORMAL and $this->getSide(Vector3::SIDE_UP)->isSolid()){
$this->level->setBlock($this, BlockFactory::get(Block::DIRT), true);
return $type;
}elseif($type === Level::BLOCK_UPDATE_RANDOM){
//TODO: hydration
}

View File

@ -26,7 +26,9 @@ namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\item\Tool;
use pocketmine\level\Level;
use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Vector3;
class GrassPath extends Transparent{
@ -59,6 +61,15 @@ class GrassPath extends Transparent{
return 0.6;
}
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_NORMAL and $this->getSide(Vector3::SIDE_UP)->isSolid()){
$this->level->setBlock($this, BlockFactory::get(Block::DIRT), true);
return $type;
}
return false;
}
public function getDrops(Item $item) : array{
return [
ItemFactory::get(Item::DIRT, 0, 1)