diff --git a/src/pocketmine/inventory/ChestInventory.php b/src/pocketmine/inventory/ChestInventory.php index 6414550ec..039827361 100644 --- a/src/pocketmine/inventory/ChestInventory.php +++ b/src/pocketmine/inventory/ChestInventory.php @@ -61,19 +61,29 @@ class ChestInventory extends ContainerInventory{ 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{ parent::onOpen($who); if(count($this->getViewers()) === 1 and $this->getHolder()->isValid()){ + //TODO: this crap really shouldn't be managed by the inventory $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{ if(count($this->getViewers()) === 1 and $this->getHolder()->isValid()){ + //TODO: this crap really shouldn't be managed by the inventory $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); } diff --git a/src/pocketmine/inventory/EnderChestInventory.php b/src/pocketmine/inventory/EnderChestInventory.php index 47f99c304..ce0f1e51e 100644 --- a/src/pocketmine/inventory/EnderChestInventory.php +++ b/src/pocketmine/inventory/EnderChestInventory.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace pocketmine\inventory; use pocketmine\level\Position; +use pocketmine\network\mcpe\protocol\LevelSoundEventPacket; use pocketmine\network\mcpe\protocol\types\WindowTypes; use pocketmine\tile\EnderChest; @@ -58,6 +59,14 @@ class EnderChestInventory extends ChestInventory{ $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. * @return Position diff --git a/src/pocketmine/tile/Sign.php b/src/pocketmine/tile/Sign.php index c566fe651..518f75f08 100644 --- a/src/pocketmine/tile/Sign.php +++ b/src/pocketmine/tile/Sign.php @@ -123,14 +123,9 @@ class Sign extends Spawnable{ public function updateCompoundTag(CompoundTag $nbt, Player $player) : bool{ if($nbt->hasTag(self::TAG_TEXT_BLOB, StringTag::class)){ - $lines = array_pad(explode("\n", $nbt->getString(self::TAG_TEXT_BLOB)), 4, ""); + $lines = array_slice(array_pad(explode("\n", $nbt->getString(self::TAG_TEXT_BLOB)), 4, ""), 0, 4); }else{ - $lines = [ - $nbt->getString(sprintf(self::TAG_TEXT_LINE, 1)), - $nbt->getString(sprintf(self::TAG_TEXT_LINE, 2)), - $nbt->getString(sprintf(self::TAG_TEXT_LINE, 3)), - $nbt->getString(sprintf(self::TAG_TEXT_LINE, 4)) - ]; + return false; } $removeFormat = $player->getRemoveFormat();