Block: Split onUpdate() into several functions, removed Level::BLOCK_UPDATE_* constants

This allows the removal of lots of ugly code, and also exposes lots of similarities with how this update type was handled. This can be further improved in the future to more generically handle cases.

I realized in the process of changing this, that it might actually be simpler to treat to treat scheduled updates and neighbour updates as one and the same. They use the same mechanism for being saved on chunks (TileTicks),
and doing that would make updating only require one queue instead of two.

RedstoneOre: use onActivate() to trigger glowing
this is not technically correct behaviour, but this preserves the current behaviour.
This commit is contained in:
Dylan K. Taylor
2018-03-13 17:29:46 +00:00
parent 4f20a504e3
commit 86eee429bb
44 changed files with 490 additions and 765 deletions

View File

@ -278,6 +278,12 @@ class Block extends Position implements BlockIds, Metadatable{
return $base;
}
/**
* Called when this block or a block immediately adjacent to it changes state.
*/
public function onNearbyBlockChange() : void{
}
/**
* Returns whether random block updates will be done on this block.
@ -289,14 +295,18 @@ class Block extends Position implements BlockIds, Metadatable{
}
/**
* Fires a block update on the Block
*
* @param int $type
*
* @return bool|int
* Called when this block is randomly updated due to chunk ticking.
* WARNING: This will not be called if ticksRandomly() does not return true!
*/
public function onUpdate(int $type){
return false;
public function onRandomTick() : void{
}
/**
* Called when this block is updated by the delayed blockupdate scheduler in the level.
*/
public function onScheduledUpdate() : void{
}
/**