3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-19 21:10:10 +01:00

Implement API for Sound, and playing the sounds for Worlds and Players. Adds BUKKIT-1430, BUKKIT-1226 and BUKKIT-2019

Dieser Commit ist enthalten in:
feildmaster 2012-08-21 17:23:17 -05:00
Ursprung ccc760d629
Commit 161ab5edc6
2 geänderte Dateien mit 22 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -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);
}
}

Datei anzeigen

@ -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;