DONT COPY AND PASE LEARN! Ok i just feeled like doing a sound effect tutorial for those how need it 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 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! Fact READ
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!
Don't you need to actually send the modified packet to the player as well? PHP: ((CraftPlayer)player).getHandle().netServerHandler.sendPacket(packet);
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.
What about this: Code:java public Packet62LevelSound(String par1Str, double par2, double par4, double par6, float par8, float par9) { this.soundName = par1Str; this.effectX = (int)(par2 * 8.0D); this.effectY = (int)(par4 * 8.0D); this.effectZ = (int)(par6 * 8.0D); this.volume = par8; this.pitch = (int)(par9 * 63.0F); if (this.pitch < 0) { this.pitch = 0; } if (this.pitch > 255) { this.pitch = 255; } }
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)
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.