falling sand will schedule update onplace

This commit is contained in:
GameHerobrine 2025-04-12 18:49:22 +03:00
parent 012f03a52b
commit 933b92f41e
2 changed files with 57 additions and 42 deletions

View file

@ -23,8 +23,10 @@ class FallingSand extends Entity{
public function update($now){ public function update($now){
if($this->closed) return; if($this->closed) return;
if( $this->data["Tile"] == AIR) $this->close(); if( $this->data["Tile"] == AIR) {
else { $this->close();
return;
}
$this->lastX = $this->x; $this->lastX = $this->x;
$this->lastY = $this->y; $this->lastY = $this->y;
$this->lastZ = $this->z; $this->lastZ = $this->z;
@ -55,5 +57,4 @@ class FallingSand extends Entity{
} }
} }
} }
}
} }

View file

@ -47,14 +47,17 @@ class GenericBlock extends Block{
return $this->level->setBlock($this, new AirBlock(), true, false, true); return $this->level->setBlock($this, new AirBlock(), true, false, true);
} }
/** public static function onPlace(Level $level, $x, $y, $z){
* @param integer $type [$id, $meta] = $level->level->getBlock($x, $y, $z);
* if(StaticBlock::getHasPhysics($id)){
* @return boolean ServerAPI::request()->api->block->scheduleBlockUpdateXYZ($level, $x, $y, $z, BLOCK_UPDATE_SCHEDULED, 2); //tick delay == 2
*/ }else{
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){ parent::onPlace($level, $x, $y, $z);
}
}
public static function onUpdate(Level $level, $x, $y, $z, $type){
[$id, $meta] = $level->level->getBlock($x, $y, $z); [$id, $meta] = $level->level->getBlock($x, $y, $z);
if(StaticBlock::getHasPhysics($id)){ //TODO move from here to different class
$down = $level->level->getBlockID($x, $y - 1, $z); $down = $level->level->getBlockID($x, $y - 1, $z);
if($down == AIR || StaticBlock::getIsLiquid($down)){ if($down == AIR || StaticBlock::getIsLiquid($down)){
$data = array( $data = array(
@ -69,6 +72,17 @@ class GenericBlock extends Block{
$server->api->entity->spawnToAll($e); $server->api->entity->spawnToAll($e);
} }
} }
/**
* @param integer $type
*
* @return boolean
*/
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
[$id, $meta] = $level->level->getBlock($x, $y, $z);
if(StaticBlock::getHasPhysics($id)){ //TODO move from here to different class
static::onUpdate($level, $x, $y, $z, BLOCK_UPDATE_NORMAL);
}
} }
/** /**