(I am using google translator) Why doesn’t the sound "SOUND_LEVELUP" be broadcast when a dirt block is thrown out? Code: public function dirtDrop(PlayerDropItemEvent $ev){ if($ev->getItem()->getId() == 3){ $ev->getPlayer()->sendForm(new EForm); $vector = $ev->getPlayer()->getPosition(); $level = $ev->getPlayer()->level; $level->broadcastLevelSoundEvent(new Vector3(100,100,100), 62); return true; } }
PHP: public function onDrop(PlayerDropItemEvent $event) {$player = $event->getPlayer();if($ev->getItem()->getId() === 1){$player->getLevel()->broadcastLevelSoundEvent(new Vector3(100,100,100), 62);
Could you please use LevelEventPacket constant instead of 62. I think that 62 is an invalid sound packet, or do you mean 1062? Ref: PocketMine-MP/LevelEventPacket
PHP: $level->broadcastLevelSoundEvent(new Vector3(100,100,100), 62, 0x10000000 * (min(30, mt_rand(2, 30)) / 5)); Some sounds don't work for some reason. If I were you, I would use that code. Ref: https://github.com/pmmp/PocketMine-MP/blob/stable/src/pocketmine/entity/Human.php#L468
Error: "Class 'VlaD3n\ LevelSoundEventPacket' not found" at line 30 (this code) Im using "LevelSoundEventPacket::SOUND_LEVELUP" instead "62" (with "62" error too) Imports: use pocketmine\event\Listener; use pocketmine\plugin\PluginBase; use VlaD3n\EnchantForm\EForm; use pocketmine\Player; use pocketmine\form\Form; use pocketmine\event\player\PlayerDropItemEvent; use pocketmine\network\mcpe\protocol\LevelSoundEventPacket; use pocketmine\level\sound\Sound;