1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Help with LevelSoundEvent

Discussion in 'Development' started by VlaD3n, Oct 11, 2019.

  1. VlaD3n

    VlaD3n Silverfish

    Messages:
    15
    (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;
    } }
     
  2. Fadhel

    Fadhel Witch

    Messages:
    68
    GitHub:
    dimbis
    PHP:
    public function onDrop(PlayerDropItemEvent $event) {
    $player $event->getPlayer();
    if(
    $ev->getItem()->getId() === 1){
    $player->getLevel()->broadcastLevelSoundEvent(new Vector3(100,100,100), 62);
     
  3. Fadhel

    Fadhel Witch

    Messages:
    68
    GitHub:
    dimbis
    read the PocketMine-MP API documentations and the PHP as well.
     
  4. VlaD3n

    VlaD3n Silverfish

    Messages:
    15
    This code also does not broadcast sound :с
     
  5. Fadhel

    Fadhel Witch

    Messages:
    68
    GitHub:
    dimbis
    you need to be on coordinates X100 Y100 Z100 to hear it.
     
  6. VlaD3n

    VlaD3n Silverfish

    Messages:
    15
    I was there but there was no sound
     
  7. Fadhel

    Fadhel Witch

    Messages:
    68
    GitHub:
    dimbis
    are you sure that you registered the listener?
     
  8. VlaD3n

    VlaD3n Silverfish

    Messages:
    15
    Yes, all code works, but not sound
     
  9. Geek

    Geek Creeper

    Messages:
    2
    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
     
  10. VlaD3n

    VlaD3n Silverfish

    Messages:
    15
    Sound 62 is contained in LevelEventSoundPacket
     
  11. Geek

    Geek Creeper

    Messages:
    2
    Which one? And as I said, please use the constant instead.
     
  12. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    VlaD3n likes this.
  13. VlaD3n

    VlaD3n Silverfish

    Messages:
    15
    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;
     
  14. VlaD3n

    VlaD3n Silverfish

    Messages:
    15
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.