Grass update! 🥳

This commit is contained in:
ArkQuark 2022-03-28 18:10:55 +03:00
parent e16cf20340
commit 292581cf89
2 changed files with 156 additions and 0 deletions

View file

@ -25,6 +25,7 @@ class GrassBlock extends SolidBlock{
$this->isActivable = true;
$this->hardness = 3;
}
public function getDrops(Item $item, Player $player){
return array(
array(DIRT, 0, 1),
@ -47,4 +48,18 @@ class GrassBlock extends SolidBlock{
}
return false;
}
public function onUpdate($type){
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
if($type === BLOCK_UPDATE_RANDOM){
if(mt_rand(0, 2) == 1){
if($this->getSide(1)->isTransparent === false){
$this->level->setBlock($this, BlockAPI::get(DIRT, 0), true, false, true);
return BLOCK_UPDATE_RANDOM;
}
}
return false;
}
}
}