mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +00:00
Block: add onPostPlace() hook
This commit is contained in:
parent
11d21448fc
commit
28f3322337
@ -253,6 +253,10 @@ class Block extends Position implements BlockLegacyIds, Metadatable{
|
||||
return $this->getWorld()->setBlock($blockReplace, $this);
|
||||
}
|
||||
|
||||
public function onPostPlace() : void{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an object containing information about the destruction requirements of this block.
|
||||
*
|
||||
|
@ -62,29 +62,27 @@ class Chest extends Transparent{
|
||||
$this->facing = Facing::opposite($player->getHorizontalFacing());
|
||||
}
|
||||
|
||||
if(parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player)){
|
||||
$tile = $this->world->getTile($this);
|
||||
if($tile instanceof TileChest){
|
||||
foreach([
|
||||
Facing::rotateY($this->facing, true),
|
||||
Facing::rotateY($this->facing, false)
|
||||
] as $side){
|
||||
$c = $this->getSide($side);
|
||||
if($c instanceof Chest and $c->isSameType($this) and $c->facing === $this->facing){
|
||||
$pair = $this->world->getTile($c);
|
||||
if($pair instanceof TileChest and !$pair->isPaired()){
|
||||
$pair->pairWith($tile);
|
||||
$tile->pairWith($pair);
|
||||
break;
|
||||
}
|
||||
return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
|
||||
public function onPostPlace() : void{
|
||||
$tile = $this->world->getTile($this);
|
||||
if($tile instanceof TileChest){
|
||||
foreach([
|
||||
Facing::rotateY($this->facing, true),
|
||||
Facing::rotateY($this->facing, false)
|
||||
] as $side){
|
||||
$c = $this->getSide($side);
|
||||
if($c instanceof Chest and $c->isSameType($this) and $c->facing === $this->facing){
|
||||
$pair = $this->world->getTile($c);
|
||||
if($pair instanceof TileChest and !$pair->isPaired()){
|
||||
$pair->pairWith($tile);
|
||||
$tile->pairWith($pair);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
|
||||
|
@ -1863,6 +1863,7 @@ class World implements ChunkManager, Metadatable{
|
||||
//TODO: seal this up inside block placement
|
||||
$tile->copyDataFromItem($item);
|
||||
}
|
||||
$hand->onPostPlace();
|
||||
|
||||
if($playSound){
|
||||
$this->addSound($hand, new BlockPlaceSound($hand));
|
||||
|
Loading…
x
Reference in New Issue
Block a user