Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Why isn't addSound working?

Comments in 'Plugin Development' started by BlubberBoy333, Jul 13, 2015.

  1. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    I am making a plugin that sends a player a sound, but the sound doesn't work. Here's the code for the sound that I have:
    PHP:
    $p->getLevel()->addSound(new ClickSound($p));
    I'm pretty sure I have something wrong in that but i don't know what it is. Can someone help me?
  2. PixelGuy75
    Offline

    PixelGuy75 Notable Member Plugin Developer

    Joined:
    Feb 9, 2014
    Posts:
    316
    Plugins:
    2
    Minecraft User:
    PixelGuy75
    You have to add the sound to the players position.
  3. Fusionbeast
    Offline

    Fusionbeast New Member

    Joined:
    Jul 12, 2015
    Posts:
    2
    Minecraft User:
    BeastPanda
    Blubber I Can Fix That Just Pm Me Ur Code
  4. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Did gou add the class pocketmine\level\sound\ClickSound .?
  5. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    $p needs to be player position.
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Player itself is a position. Read the docs.
  7. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    I have it
  8. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    PHP:
    $x $player->getFloorX();
    $y $player->getFloorY();
    $z $player->getFloorZ();
    $pos = new Vector3($x$y$z);
    // Or just use $player
    $sound = new PopSound($pos); // Just add what sound you want i used PopSound
    $player->getLevel()->addSound($sound);
    Didnt know Player can be position cuz it says Vector3
  9. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    Thanks i'll try that
  10. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    It still isn't working. I think it has something to do with something else/ Can someone take a look at the full code here and see if you can find anything?
  11. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio
    use pocketmine\level\sound\BatSound; //example
    $->getLevel()->addSound(new BatSound($pos, 0));
  12. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    I'm already using the sound classes
  13. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio
  14. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
  15. hoyinm14mc
    Offline

    hoyinm14mc Notable Member Plugin Developer

    Joined:
    Jun 4, 2014
    Posts:
    501
    Plugins:
    9
    Minecraft User:
    hoyinm14mc
  16. hoyinm14mc
    Offline

    hoyinm14mc Notable Member Plugin Developer

    Joined:
    Jun 4, 2014
    Posts:
    501
    Plugins:
    9
    Minecraft User:
    hoyinm14mc
    And also, if your keyboard is opened, you cannot hear any sound effects.
    You could do this before adding the sound:
    PHP:
    $player->attack(1);
    $player->heal(1);
    /*addSound()
    Look at AuthMePE's auth() method*/
  17. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio
    have you set the pitch ?
    dont found it

    public function __construct(Vector3 $pos, $pitch = 0){
  18. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    #facepalm

    Player extends Human extends Creature extends Living extends Entity extends Location extends Position extends Vector3.


    Read the docs. Read http://jenkins.pocketmine.net/job/PocketMine-MP-Doc/doxygen/df/d2c/classpocketmine_1_1_player.html - the inheritance diagram shows all classes and interfaces extended/implemented by the Player class.

    Also see the inheritance chart in the Vector3 class, showing what classes are subclasses of Vector3: http://jenkins.pocketmine.net/job/P.../d90/classpocketmine_1_1math_1_1_vector3.html note that the classes in red mean they are not completely shown due to not enough space.
    CrazedMiner and Legoboy0215 like this.
  19. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    Why would i need to set the pitch? I don't think the way a player is looking has anything to do with where he's standing
    hoyinm14mc likes this.
  20. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio
    because i have no problem...but you xD dont know wheres your mistake

Share This Page

Advertisement