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

@ -25,7 +25,6 @@ namespace pocketmine\block;
use pocketmine\item\enchantment\Enchantment;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\Player;
class Ice extends Transparent{
@ -67,15 +66,10 @@ class Ice extends Transparent{
return true;
}
public function onUpdate(int $type){
if($type === Level::BLOCK_UPDATE_RANDOM){
if($this->level->getHighestAdjacentBlockLight($this->x, $this->y, $this->z) >= 12){
$this->level->useBreakOn($this);
return $type;
}
public function onRandomTick() : void{
if($this->level->getHighestAdjacentBlockLight($this->x, $this->y, $this->z) >= 12){
$this->level->useBreakOn($this);
}
return false;
}
public function getDropsForCompatibleTool(Item $item) : array{