mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-10 03:34:06 +00:00
Integrate block container animations and SFX into Block classes by way of AnimatedContainer interface
this allows getting rid of several container window classes. we should probably look into adding more info to the BlockInventoryWindow to make the type easier to identify, though. now that holder is tracked by an ephemeral window, we can put whatever we like in there.
This commit is contained in:
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\block\inventory\window;
|
||||
|
||||
use pocketmine\block\utils\AnimatedContainer;
|
||||
use pocketmine\inventory\Inventory;
|
||||
use pocketmine\player\InventoryWindow;
|
||||
use pocketmine\player\Player;
|
||||
@ -39,4 +40,20 @@ class BlockInventoryWindow extends InventoryWindow{
|
||||
}
|
||||
|
||||
public function getHolder() : Position{ return $this->holder; }
|
||||
|
||||
public function onOpen() : void{
|
||||
parent::onOpen();
|
||||
$block = $this->holder->getWorld()->getBlock($this->holder);
|
||||
if($block instanceof AnimatedContainer){
|
||||
$block->onContainerOpen();
|
||||
}
|
||||
}
|
||||
|
||||
public function onClose() : void{
|
||||
$block = $this->holder->getWorld()->getBlock($this->holder);
|
||||
if($block instanceof AnimatedContainer){
|
||||
$block->onContainerClose();
|
||||
}
|
||||
parent::onClose();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user