LevelSoundEventPacket issues

Discussion in 'Development' started by minijaham, May 6, 2021.

  1. minijaham

    minijaham Zombie Pigman

    Messages:
    737
    GitHub:
    minijaham
    PHP:
    $packet = new LevelSoundEventPacket();
    $packet->sound 290;
    $packet->disableRelativeVolume true// This is the problem!
    $packet->position $sender;
    $sender->sendDataPacket($packet);
    I have two problems.
    1. The audio seems to be a bit off-tuned from the original. (The key seems to differ)
    2. disableRelativeVolume is not working. So basically, when disableRelativeVolume is set to "true", the volume should be the same regardless of the position, which makes it so you can hear the sound from anywhere.

    Anyone know how to solve these issues?...
    Thanks!
     
  2. Axon

    Axon Zombie

    Messages:
    266
    DisableRelativeVolume doesn't seem to be working.
    Try this code below.
    PHP:
    foreach($this->plugin->getServer()->getOnlinePlayers() as $player){
                
    $packet = new LevelSoundEventPacket();
                
    $packet->sound 290;
                
    $packet->position $player->getPosition()
    ;
                
    $player->sendDataPacket($packet);
            }
    If you want to modify the pitch/volume, use these objects below.
    PHP:
    $packet->volume 1// numeric
    $packet->pitch 1// numeric
     
    Last edited: May 6, 2021
    Agent likes this.
  3. minijaham

    minijaham Zombie Pigman

    Messages:
    737
    GitHub:
    minijaham
    Foreaching all online players won't solve the problem, since it will just play the sound at each locations

    And I don't think LevelSoundEventPacket doesn't have volume and pitch parem.

    Thanks for the reply though
     
  4. Axon

    Axon Zombie

    Messages:
    266
    Not true, The player will only hear one sound, because the packet sends it to the player. I've tested it on my devices. :)
    I may be mistaken though.
     
    Agent likes this.
  5. minijaham

    minijaham Zombie Pigman

    Messages:
    737
    GitHub:
    minijaham
    Yes, thats what I meant. And i also meant that foreaching wont solve the distance issue
     

Share This Page

  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.