SoundEffects[Tutorial]

Discussion in 'Resources' started by ceoepts, Oct 28, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    ceoepts

    DONT COPY AND PASE LEARN!
    Ok i just feeled like doing a sound effect tutorial for those how need it :p
    The first thing you need to do is to import the packet.

    import net.minecraft.server.Packet62NamedSoundEffect;

    Then you have to create the packet
    acket62NamedSoundEffect packet = new Packet62NamedSoundEffect
    after that you have to choose the effect by going in to .minecraft/resources/Where.WhatEffect

    [​IMG]

    Now add your effect there
    Packet62NamedSoundEffect packet = new Packet62NamedSoundEffect("note.pling",

    Then add the location

    Packet62NamedSoundEffect packet = new Packet62NamedSoundEffect("portal.travel", p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ(),

    I really am not sure what the two floats in the end stand for but maybe volume/radius
    add these anyway
    1.0F, 1.0F);

    Packet62NamedSoundEffect packet = new Packet62NamedSoundEffect("portal.travel", p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ(), 1.0F, 1.0F);

    And now this should play a PLING! sound at the players location!

    Bye!:D


    [​IMG][​IMG]
    Fact READ
     
  2. Offline

    Hoolean

    This should be in the resources section, although very good tutorial! (maybe a few more code tags)

    I'll tell an Admin to move it to the right place for you!
     
  3. Offline

    ceoepts

    Thanks :)
     
  4. Offline

    devilquak

    Don't you need to actually send the modified packet to the player as well?

    PHP:
    ((CraftPlayer)player).getHandle().netServerHandler.sendPacket(packet);
     
    Woobie likes this.
  5. Offline

    stirante

    Packet62NamedSoundEffect is now Packet62LevelSound. Last two parameters are volume and pitch.
     
  6. Offline

    Gravity

    Moved to resources.
     
    MrBluebear3 likes this.
  7. Offline

    Icyene

    The first is the pitch, the second is the 'data value' for sounds that have multiple entries. For example, there exists mob.endermen.scream(1-5). You can't send a packet with mob.endermen.scream5: it won't work. You add the 5 as the data value.
     
  8. Offline

    stirante

    What about this:
    Code:java
    1. public Packet62LevelSound(String par1Str, double par2, double par4, double par6, float par8, float par9)
    2. {
    3. this.soundName = par1Str;
    4. this.effectX = (int)(par2 * 8.0D);
    5. this.effectY = (int)(par4 * 8.0D);
    6. this.effectZ = (int)(par6 * 8.0D);
    7. this.volume = par8;
    8. this.pitch = (int)(par9 * 63.0F);
    9.  
    10. if (this.pitch < 0)
    11. {
    12. this.pitch = 0;
    13. }
    14.  
    15. if (this.pitch > 255)
    16. {
    17. this.pitch = 255;
    18. }
    19. }
     
  9. Offline

    ftbastler

    Can be done easier using player.playSound(). Supports pretty much every sound...
    JavaDocs
     
  10. Offline

    Hoolean

     
  11. Offline

    ftbastler

    MrBluebear3 I know, but the same can happen with the packate-send-way.
     
  12. Offline

    Hoolean

    Is true. ;D
     
  13. Offline

    ftbastler

    I experimented with the volume and pitch a bit. Here is my result:
    Volume - 0, 1; anything else doesn't make any noticeable difference
    Pitch - 0, 1, 2; Everything over 2 doesn't make a difference between it (Bukkit only allows 0 - ~4)
     
  14. Offline

    Icyene

    Try it yourself :) I use alot of sound for my plugin, and trust me; it wouldn't be the first time that MCP is a little bit off.
     
  15. Offline

    stirante

    Thanks, could you post example, becouse I still don't know how to use it?
     
Thread Status:
Not open for further replies.

Share This Page