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

@ -1,13 +1,6 @@
<?php
class LadderBlock extends TransparentBlock{
public static $faces = [
3 => 2,
2 => 3,
5 => 4,
4 => 5,
];
public static function getAABB(Level $level, $x, $y, $z){
[$id, $meta] = $level->level->getBlock($x, $y, $z);
@ -47,15 +40,21 @@ class LadderBlock extends TransparentBlock{
return false;
}
public function onUpdate($type){
public static function onUpdate(Level $level, $x, $y, $z, $type){
$side = $level->level->getBlockDamage($x, $y, $z);
if($type === BLOCK_UPDATE_NORMAL){
$side = $this->getMetadata();
if($this->getSide(self::$faces[$side]) instanceof AirBlock){ //Replace with common break method
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id, 0, 1));
$this->level->setBlock($this, new AirBlock(), true, false, true);
return BLOCK_UPDATE_NORMAL;
}
$attached = match($side){
3 => $level->level->getBlockID($x, $y, $z - 1),
2 => $level->level->getBlockID($x, $y, $z + 1),
5 => $level->level->getBlockID($x - 1, $y, $z),
4 => $level->level->getBlockID($x + 1, $y, $z),
default => 0 //TODO
};
if($attached == AIR){ //Replace with common break method
ServerAPI::request()->api->entity->drop(new Position($x, $y, $z, $level), BlockAPI::getItem(LADDER, 0, 1));
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
return BLOCK_UPDATE_NORMAL;
}
return false;
}