Block: add onPostPlace() hook

This commit is contained in:
Dylan K. Taylor 2019-05-27 17:30:57 +01:00
parent 11d21448fc
commit 28f3322337
3 changed files with 22 additions and 19 deletions

View File

@ -253,6 +253,10 @@ class Block extends Position implements BlockLegacyIds, Metadatable{
return $this->getWorld()->setBlock($blockReplace, $this); return $this->getWorld()->setBlock($blockReplace, $this);
} }
public function onPostPlace() : void{
}
/** /**
* Returns an object containing information about the destruction requirements of this block. * Returns an object containing information about the destruction requirements of this block.
* *

View File

@ -62,7 +62,10 @@ class Chest extends Transparent{
$this->facing = Facing::opposite($player->getHorizontalFacing()); $this->facing = Facing::opposite($player->getHorizontalFacing());
} }
if(parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player)){ return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
}
public function onPostPlace() : void{
$tile = $this->world->getTile($this); $tile = $this->world->getTile($this);
if($tile instanceof TileChest){ if($tile instanceof TileChest){
foreach([ foreach([
@ -80,11 +83,6 @@ class Chest extends Transparent{
} }
} }
} }
return true;
}
return false;
} }
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{

View File

@ -1863,6 +1863,7 @@ class World implements ChunkManager, Metadatable{
//TODO: seal this up inside block placement //TODO: seal this up inside block placement
$tile->copyDataFromItem($item); $tile->copyDataFromItem($item);
} }
$hand->onPostPlace();
if($playSound){ if($playSound){
$this->addSound($hand, new BlockPlaceSound($hand)); $this->addSound($hand, new BlockPlaceSound($hand));