#990: Add playSound with Entity as source

By: Gero <gecam59@gmail.com>
This commit is contained in:
CraftBukkit/Spigot
2022-01-11 18:53:45 +11:00
parent 602f8cb433
commit 9b581cce11
2 changed files with 32 additions and 0 deletions

View File

@@ -44,6 +44,7 @@ import net.minecraft.network.protocol.game.PacketPlayOutChat;
import net.minecraft.network.protocol.game.PacketPlayOutCustomPayload;
import net.minecraft.network.protocol.game.PacketPlayOutCustomSoundEffect;
import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment;
import net.minecraft.network.protocol.game.PacketPlayOutEntitySound;
import net.minecraft.network.protocol.game.PacketPlayOutExperience;
import net.minecraft.network.protocol.game.PacketPlayOutGameStateChange;
import net.minecraft.network.protocol.game.PacketPlayOutMap;
@@ -501,6 +502,19 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
getHandle().connection.send(packet);
}
@Override
public void playSound(org.bukkit.entity.Entity entity, Sound sound, float volume, float pitch) {
playSound(entity, sound, org.bukkit.SoundCategory.MASTER, volume, pitch);
}
@Override
public void playSound(org.bukkit.entity.Entity entity, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch) {
if (!(entity instanceof CraftEntity craftEntity) || sound == null || category == null || getHandle().connection == null) return;
PacketPlayOutEntitySound packet = new PacketPlayOutEntitySound(CraftSound.getSoundEffect(sound), net.minecraft.sounds.SoundCategory.valueOf(category.name()), craftEntity.getHandle(), volume, pitch);
getHandle().connection.send(packet);
}
@Override
public void stopSound(Sound sound) {
stopSound(sound, null);