From 92494d7dba6f49d95b7f5753c72fc3d831a4c0cf Mon Sep 17 00:00:00 2001 From: Lukas Hennig Date: Sun, 6 Mar 2016 12:20:38 +1100 Subject: [PATCH] Added a playSound method to World which accepts a String parameter. Similar to the respective method in Player. --- src/main/java/org/bukkit/craftbukkit/CraftWorld.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 7023979afd..f22885fe2d 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -1319,6 +1319,17 @@ public class CraftWorld implements World { getHandle().a(null, x, y, z, CraftSound.getSoundEffect(CraftSound.getSound(sound)), SoundCategory.MASTER, volume, pitch); // PAIL: rename } + public void playSound(Location loc, String sound, float volume, float pitch) { + if (loc == null || sound == null) return; + + double x = loc.getX(); + double y = loc.getY(); + double z = loc.getZ(); + + PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(sound, SoundCategory.MASTER, x, y, z, volume, pitch); + world.getMinecraftServer().getPlayerList().sendPacketNearby(null, x, y, z, volume > 1.0F ? 16.0F * volume : 16.0D, this.world.dimension, packet); + } + public String getGameRuleValue(String rule) { return getHandle().getGameRules().get(rule); }