mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 03:48:01 +01:00
Implement API for Sound, and playing the sounds for Worlds and Players. Adds BUKKIT-1430, BUKKIT-1226 and BUKKIT-2019
This commit is contained in:
parent
ccc760d629
commit
161ab5edc6
@ -41,6 +41,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.plugin.messaging.StandardMessenger;
|
||||
@ -1161,4 +1162,14 @@ public class CraftWorld implements World {
|
||||
public void setWaterAnimalSpawnLimit(int limit) {
|
||||
waterAnimalSpawn = limit;
|
||||
}
|
||||
|
||||
public void playSound(Location loc, Sound sound, float volume, float pitch) {
|
||||
if (loc == null || sound == null) return;
|
||||
|
||||
double x = loc.getX();
|
||||
double y = loc.getY();
|
||||
double z = loc.getZ();
|
||||
|
||||
getHandle().makeSound(x, y, z, sound.getSound(), volume, pitch);
|
||||
}
|
||||
}
|
||||
|
@ -250,6 +250,17 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
getHandle().netServerHandler.sendPacket(new Packet54PlayNoteBlock(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), id, instrument.getType(), note.getId()));
|
||||
}
|
||||
|
||||
public void playSound(Location loc, Sound sound, float volume, float pitch) {
|
||||
if (loc == null || sound == null || getHandle().netServerHandler == null) return;
|
||||
|
||||
double x = loc.getBlockX() + 0.5;
|
||||
double y = loc.getBlockY() + 0.5;
|
||||
double z = loc.getBlockZ() + 0.5;
|
||||
|
||||
Packet62NamedSoundEffect packet = new Packet62NamedSoundEffect(sound.getSound(), x, y, z, volume, pitch);
|
||||
getHandle().netServerHandler.sendPacket(packet);
|
||||
}
|
||||
|
||||
public void playEffect(Location loc, Effect effect, int data) {
|
||||
if (getHandle().netServerHandler == null) return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user