mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-30 23:29:54 +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);
|
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.
|
||||||
*
|
*
|
||||||
|
@ -62,29 +62,27 @@ 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);
|
||||||
$tile = $this->world->getTile($this);
|
}
|
||||||
if($tile instanceof TileChest){
|
|
||||||
foreach([
|
public function onPostPlace() : void{
|
||||||
Facing::rotateY($this->facing, true),
|
$tile = $this->world->getTile($this);
|
||||||
Facing::rotateY($this->facing, false)
|
if($tile instanceof TileChest){
|
||||||
] as $side){
|
foreach([
|
||||||
$c = $this->getSide($side);
|
Facing::rotateY($this->facing, true),
|
||||||
if($c instanceof Chest and $c->isSameType($this) and $c->facing === $this->facing){
|
Facing::rotateY($this->facing, false)
|
||||||
$pair = $this->world->getTile($c);
|
] as $side){
|
||||||
if($pair instanceof TileChest and !$pair->isPaired()){
|
$c = $this->getSide($side);
|
||||||
$pair->pairWith($tile);
|
if($c instanceof Chest and $c->isSameType($this) and $c->facing === $this->facing){
|
||||||
$tile->pairWith($pair);
|
$pair = $this->world->getTile($c);
|
||||||
break;
|
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{
|
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
|
//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));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user