Help with LevelSoundEvent

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

  1. VlaD3n

    VlaD3n Spider

    Messages:
    7
    (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 Spider Jockey

    Messages:
    47
    GitHub:
    youngfad
    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 Spider Jockey

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

    VlaD3n Spider

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

    Fadhel Spider Jockey

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

    VlaD3n Spider

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

    Fadhel Spider Jockey

    Messages:
    47
    GitHub:
    youngfad
    are you sure that you registered the listener?
     
  8. VlaD3n

    VlaD3n Spider

    Messages:
    7
    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 Spider

    Messages:
    7
    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:
    677
    VlaD3n likes this.
  13. VlaD3n

    VlaD3n Spider

    Messages:
    7
    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 Spider

    Messages:
    7

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.