mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 00:29:54 +00:00
Fixed ender chest sounds, closes #2611
This commit is contained in:
parent
98f903783c
commit
93dd05a03e
@ -61,19 +61,29 @@ class ChestInventory extends ContainerInventory{
|
|||||||
return $this->holder;
|
return $this->holder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getOpenSound() : int{
|
||||||
|
return LevelSoundEventPacket::SOUND_CHEST_OPEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getCloseSound() : int{
|
||||||
|
return LevelSoundEventPacket::SOUND_CHEST_CLOSED;
|
||||||
|
}
|
||||||
|
|
||||||
public function onOpen(Player $who) : void{
|
public function onOpen(Player $who) : void{
|
||||||
parent::onOpen($who);
|
parent::onOpen($who);
|
||||||
|
|
||||||
if(count($this->getViewers()) === 1 and $this->getHolder()->isValid()){
|
if(count($this->getViewers()) === 1 and $this->getHolder()->isValid()){
|
||||||
|
//TODO: this crap really shouldn't be managed by the inventory
|
||||||
$this->broadcastBlockEventPacket(true);
|
$this->broadcastBlockEventPacket(true);
|
||||||
$this->getHolder()->getLevel()->broadcastLevelSoundEvent($this->getHolder()->add(0.5, 0.5, 0.5), LevelSoundEventPacket::SOUND_CHEST_OPEN);
|
$this->getHolder()->getLevel()->broadcastLevelSoundEvent($this->getHolder()->add(0.5, 0.5, 0.5), $this->getOpenSound());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onClose(Player $who) : void{
|
public function onClose(Player $who) : void{
|
||||||
if(count($this->getViewers()) === 1 and $this->getHolder()->isValid()){
|
if(count($this->getViewers()) === 1 and $this->getHolder()->isValid()){
|
||||||
|
//TODO: this crap really shouldn't be managed by the inventory
|
||||||
$this->broadcastBlockEventPacket(false);
|
$this->broadcastBlockEventPacket(false);
|
||||||
$this->getHolder()->getLevel()->broadcastLevelSoundEvent($this->getHolder()->add(0.5, 0.5, 0.5), LevelSoundEventPacket::SOUND_CHEST_CLOSED);
|
$this->getHolder()->getLevel()->broadcastLevelSoundEvent($this->getHolder()->add(0.5, 0.5, 0.5), $this->getCloseSound());
|
||||||
}
|
}
|
||||||
parent::onClose($who);
|
parent::onClose($who);
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||||||
namespace pocketmine\inventory;
|
namespace pocketmine\inventory;
|
||||||
|
|
||||||
use pocketmine\level\Position;
|
use pocketmine\level\Position;
|
||||||
|
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||||
use pocketmine\network\mcpe\protocol\types\WindowTypes;
|
use pocketmine\network\mcpe\protocol\types\WindowTypes;
|
||||||
use pocketmine\tile\EnderChest;
|
use pocketmine\tile\EnderChest;
|
||||||
|
|
||||||
@ -58,6 +59,14 @@ class EnderChestInventory extends ChestInventory{
|
|||||||
$this->holder->setLevel($enderChest->getLevel());
|
$this->holder->setLevel($enderChest->getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getOpenSound() : int{
|
||||||
|
return LevelSoundEventPacket::SOUND_ENDERCHEST_OPEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getCloseSound() : int{
|
||||||
|
return LevelSoundEventPacket::SOUND_ENDERCHEST_CLOSED;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This override is here for documentation and code completion purposes only.
|
* This override is here for documentation and code completion purposes only.
|
||||||
* @return Position
|
* @return Position
|
||||||
|
Loading…
x
Reference in New Issue
Block a user