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:
Dylan K. Taylor
2024-11-25 10:55:35 +00:00
parent f4d50a1aa1
commit 4dcc14e0a1
12 changed files with 205 additions and 317 deletions

View File

@ -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();
}
}