mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 02:42:58 +00:00
first shot making Block not extend Position
this makes some stuff a lot less pretty, but this seems to be the bare minimum necessary to do this task. It can be enhanced later.
This commit is contained in:
@ -27,6 +27,7 @@ use pocketmine\event\block\BlockSpreadEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Facing;
|
||||
use function mt_rand;
|
||||
use pocketmine\world\Position;
|
||||
|
||||
class Mycelium extends Opaque{
|
||||
|
||||
@ -46,16 +47,16 @@ class Mycelium extends Opaque{
|
||||
|
||||
public function onRandomTick() : void{
|
||||
//TODO: light levels
|
||||
$x = mt_rand($this->x - 1, $this->x + 1);
|
||||
$y = mt_rand($this->y - 2, $this->y + 2);
|
||||
$z = mt_rand($this->z - 1, $this->z + 1);
|
||||
$block = $this->getWorld()->getBlockAt($x, $y, $z);
|
||||
$x = mt_rand($this->pos->x - 1, $this->pos->x + 1);
|
||||
$y = mt_rand($this->pos->y - 2, $this->pos->y + 2);
|
||||
$z = mt_rand($this->pos->z - 1, $this->pos->z + 1);
|
||||
$block = $this->pos->getWorld()->getBlockAt($x, $y, $z);
|
||||
if($block->getId() === BlockLegacyIds::DIRT){
|
||||
if($block->getSide(Facing::UP) instanceof Transparent){
|
||||
$ev = new BlockSpreadEvent($block, $this, VanillaBlocks::MYCELIUM());
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getWorld()->setBlock($block, $ev->getNewState());
|
||||
$this->pos->getWorld()->setBlock($block->pos, $ev->getNewState());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user