mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 00:29:54 +00:00
farmland and grass path should die when a solid block is above them
This commit is contained in:
parent
35e7aca88f
commit
63fccd4682
@ -28,6 +28,7 @@ use pocketmine\item\ItemFactory;
|
|||||||
use pocketmine\item\Tool;
|
use pocketmine\item\Tool;
|
||||||
use pocketmine\level\Level;
|
use pocketmine\level\Level;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
|
|
||||||
class Farmland extends Transparent{
|
class Farmland extends Transparent{
|
||||||
|
|
||||||
@ -65,7 +66,10 @@ class Farmland extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onUpdate(int $type){
|
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
|
//TODO: hydration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,9 @@ namespace pocketmine\block;
|
|||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\item\ItemFactory;
|
use pocketmine\item\ItemFactory;
|
||||||
use pocketmine\item\Tool;
|
use pocketmine\item\Tool;
|
||||||
|
use pocketmine\level\Level;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
|
|
||||||
class GrassPath extends Transparent{
|
class GrassPath extends Transparent{
|
||||||
|
|
||||||
@ -59,6 +61,15 @@ class GrassPath extends Transparent{
|
|||||||
return 0.6;
|
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{
|
public function getDrops(Item $item) : array{
|
||||||
return [
|
return [
|
||||||
ItemFactory::get(Item::DIRT, 0, 1)
|
ItemFactory::get(Item::DIRT, 0, 1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user