onUpdate is now static, disabled rail, water and lava updates to rework.

This commit is contained in:
GameHerobrine 2024-05-20 13:16:48 +03:00
parent 3c37dc446e
commit ee989ef556
38 changed files with 329 additions and 367 deletions

View file

@ -26,7 +26,7 @@ class CactusBlock extends TransparentBlock{
$bID = $level->level->getBlockID($x, $y + $yy, $z);
if($bID === AIR){
$level->fastSetBlockUpdate($x, $y + $yy, $z, CACTUS, 0);
$level->getBlockWithoutVector($x, $y + $yy, $z)->onUpdate(BLOCK_UPDATE_NORMAL); //TODO rewrite ticking
CactusBlock::onUpdate($level, $x, $y + $yy, $z, BLOCK_UPDATE_NORMAL); //TODO rewrite ticking
break;
}
}
@ -39,16 +39,16 @@ class CactusBlock extends TransparentBlock{
}
}
public function onUpdate($type){
public static function onUpdate(Level $level, $x, $y, $z, $type){
if($type === BLOCK_UPDATE_NORMAL){
$down = $this->getSide(0);
$block0 = $this->getSide(2);
$block1 = $this->getSide(3);
$block2 = $this->getSide(4);
$block3 = $this->getSide(5);
if($block0->isFlowable === false or $block1->isFlowable === false or $block2->isFlowable === false or $block3->isFlowable === false or ($down->getID() !== SAND and $down->getID() !== CACTUS)){ //Replace with common break method
$this->level->setBlock($this, new AirBlock(), true, false, true);
ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem($this->id));
$down = $level->level->getBlockID($x, $y, $z);
$b0 = $level->level->getBlockID($x, $y, $z - 1);
$b1 = $level->level->getBlockID($x, $y, $z + 1);
$b2 = $level->level->getBlockID($x - 1, $y, $z);
$b3 = $level->level->getBlockID($x + 1, $y, $z);
if(!StaticBlock::getIsFlowable($b0) || !StaticBlock::getIsFlowable($b1) || !StaticBlock::getIsFlowable($b2) || !StaticBlock::getIsFlowable($b3) || ($down !== SAND and $down !== CACTUS)){ //Replace with common break method
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
ServerAPI::request()->api->entity->drop(new Position($x + 0.5, $y, $z + 0.5, $level), BlockAPI::getItem(CACTUS));
return BLOCK_UPDATE_NORMAL;
}
}