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

@ -58,71 +58,73 @@ class LavaBlock extends LiquidBlock implements LightingBlock{
return null;
}
public function onUpdate($type){
//return false;
$newId = $this->id;
$level = $this->meta & 0x06;
if($type !== BLOCK_UPDATE_NORMAL){
return false;
}
/*if($this->checkWater()){
return;
}*/
$falling = $this->meta >> 3;
$down = $this->getSide(0);
if($down instanceof WaterBlock) {
$this->level->fastSetBlockUpdate($down->x, $down->y, $down->z, STONE, 0, true);
return;
}
$from = $this->getFrom();
if($from !== null || $level == 0x00){
if($down instanceof AirBlock || $down instanceof LavaBlock){
$this->level->setBlock($down, new LavaBlock(0x01), false, false, true);
ServerAPI::request()->api->block->scheduleBlockUpdate($down, 40, BLOCK_UPDATE_NORMAL);
}elseif($level !== 0x06){
for($side = 2; $side <= 5; ++$side){
$b = $this->getSide($side);
if($b instanceof LavaBlock){
}elseif($b->isFlowable === true){
$this->level->setBlock($b, new LavaBlock( min($level + 2,6) ), false, false, true);
ServerAPI::request()->api->block->scheduleBlockUpdate($b, 40, BLOCK_UPDATE_NORMAL);
}
}
}
}else{
//Extend Remove for Left Lavas
for($side = 2; $side <= 5; ++$side){
$sb = $this->getSide($side);
if($sb instanceof LavaBlock){
$tlevel = $sb->meta & 0x06;
if($tlevel != 0x00){
for ($s = 0; $s <= 5; $s++) {
$ssb = $sb->getSide($s);
ServerAPI::request()->api->block->scheduleBlockUpdate($ssb, 40, BLOCK_UPDATE_NORMAL);
}
$this->level->setBlock($sb, new AirBlock(), false, false, true);
}
}
$b = $this->getSide(0)->getSide($side);
if($b instanceof LavaBlock){
$tlevel = $b->meta & 0x06;
if($tlevel != 0x00){
for ($s = 0; $s <= 5; $s++) {
$ssb = $sb->getSide($s);
ServerAPI::request()->api->block->scheduleBlockUpdate($ssb, 40, BLOCK_UPDATE_NORMAL);
}
$this->level->setBlock($b, new AirBlock(), false, false, true);
}
}
//ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL);
}
$this->level->setBlock($this, new AirBlock(), false, false, true);
}
public static function onUpdate(Level $level, $x, $y, $z, $type){
//TODO rewrite
return false;
//return false;
// $newId = $this->id;
// $level = $this->meta & 0x06;
// if($type !== BLOCK_UPDATE_NORMAL){
// return false;
// }
// /*if($this->checkWater()){
// return;
// }*/
// $falling = $this->meta >> 3;
// $down = $this->getSide(0);
// if($down instanceof WaterBlock) {
// $this->level->fastSetBlockUpdate($down->x, $down->y, $down->z, STONE, 0, true);
// return;
// }
// $from = $this->getFrom();
// if($from !== null || $level == 0x00){
// if($down instanceof AirBlock || $down instanceof LavaBlock){
// $this->level->setBlock($down, new LavaBlock(0x01), false, false, true);
// ServerAPI::request()->api->block->scheduleBlockUpdate($down, 40, BLOCK_UPDATE_NORMAL);
// }elseif($level !== 0x06){
// for($side = 2; $side <= 5; ++$side){
// $b = $this->getSide($side);
// if($b instanceof LavaBlock){
// }elseif($b->isFlowable === true){
// $this->level->setBlock($b, new LavaBlock( min($level + 2,6) ), false, false, true);
// ServerAPI::request()->api->block->scheduleBlockUpdate($b, 40, BLOCK_UPDATE_NORMAL);
// }
// }
// }
// }else{
// //Extend Remove for Left Lavas
// for($side = 2; $side <= 5; ++$side){
// $sb = $this->getSide($side);
// if($sb instanceof LavaBlock){
// $tlevel = $sb->meta & 0x06;
// if($tlevel != 0x00){
// for ($s = 0; $s <= 5; $s++) {
// $ssb = $sb->getSide($s);
// ServerAPI::request()->api->block->scheduleBlockUpdate($ssb, 40, BLOCK_UPDATE_NORMAL);
// }
// $this->level->setBlock($sb, new AirBlock(), false, false, true);
// }
// }
// $b = $this->getSide(0)->getSide($side);
// if($b instanceof LavaBlock){
// $tlevel = $b->meta & 0x06;
// if($tlevel != 0x00){
// for ($s = 0; $s <= 5; $s++) {
// $ssb = $sb->getSide($s);
// ServerAPI::request()->api->block->scheduleBlockUpdate($ssb, 40, BLOCK_UPDATE_NORMAL);
// }
// $this->level->setBlock($b, new AirBlock(), false, false, true);
// }
// }
// //ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL);
// }
// $this->level->setBlock($this, new AirBlock(), false, false, true);
// }
// return false;
}
}