summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorsk89q <the.sk89q@gmail.com>2011-06-09 22:38:44 -0700
committersk89q <the.sk89q@gmail.com>2011-06-09 22:38:44 -0700
commitbaf9a9f50141baf04f5fe2cbff32607943394312 (patch)
treedc400a7aec279800022b5ee23141d4604ff0f834 /src/main/java
parentf627b69be95fcc346fea21c5e25d0d95ca4cff74 (diff)
parent5fe9ac362b7e65721a9d31b1c366d7b92da877f7 (diff)
downloadcraftbukkit-baf9a9f50141baf04f5fe2cbff32607943394312.tar
craftbukkit-baf9a9f50141baf04f5fe2cbff32607943394312.tar.gz
craftbukkit-baf9a9f50141baf04f5fe2cbff32607943394312.tar.lz
craftbukkit-baf9a9f50141baf04f5fe2cbff32607943394312.tar.xz
craftbukkit-baf9a9f50141baf04f5fe2cbff32607943394312.zip
Merge branch 'sound' of https://github.com/sunkid/CraftBukkit
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftWorld.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index d15926e3..4fa939de 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -11,6 +11,7 @@ import java.util.Random;
import net.minecraft.server.*;
import org.bukkit.entity.Arrow;
+import org.bukkit.Sound;
import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.event.weather.ThunderChangeEvent;
import org.bukkit.event.world.SpawnChangeEvent;
@@ -645,5 +646,25 @@ public class CraftWorld implements World {
public void setPVP(boolean pvp) {
world.pvpMode = pvp;
+ }
+
+ public void playSound(Player player, Sound sound, int data) {
+ playSound(player.getLocation(), sound, data, 0);
+ }
+
+ public void playSound(Location location, Sound sound, int data) {
+ playSound(location, sound, data, 64);
}
+
+ public void playSound(Location location, Sound sound, int data, int radius) {
+ int packetData = sound.getSoundIdentifier();
+ Packet61 packet = new Packet61(packetData, location.getBlockX(), location.getBlockY(), location.getBlockZ(), data);
+ int distance;
+ for (Player player : getPlayers()) {
+ distance = (int) player.getLocation().distanceTo(location);
+ if (distance <= radius) {
+ ((CraftPlayer) player).getHandle().netServerHandler.sendPacket(packet);
+ }
+ }
+ }
}