Search in sources :

Example 1 with SPlaySoundPacket

use of net.minecraft.network.play.server.SPlaySoundPacket in project Magma-1.16.x by magmafoundation.

the class CraftWorld method playSound.

@Override
public void playSound(Location loc, String sound, org.bukkit.SoundCategory category, float volume, float pitch) {
    if (loc == null || sound == null || category == null)
        return;
    double x = loc.getX();
    double y = loc.getY();
    double z = loc.getZ();
    SPlaySoundPacket packet = new SPlaySoundPacket(new ResourceLocation(sound), SoundCategory.valueOf(category.name()), new Vector3d(x, y, z), volume, pitch);
    world.getServer().getPlayerList().broadcast(null, x, y, z, volume > 1.0F ? 16.0F * volume : 16.0D, this.world.dimension(), packet);
}
Also used : Vector3d(net.minecraft.util.math.vector.Vector3d) ResourceLocation(net.minecraft.util.ResourceLocation) SPlaySoundPacket(net.minecraft.network.play.server.SPlaySoundPacket)

Example 2 with SPlaySoundPacket

use of net.minecraft.network.play.server.SPlaySoundPacket in project Magma-1.16.x by magmafoundation.

the class CraftPlayer method playSound.

@Override
public void playSound(Location loc, String sound, org.bukkit.SoundCategory category, float volume, float pitch) {
    if (loc == null || sound == null || category == null || getHandle().connection == null)
        return;
    SPlaySoundPacket packet = new SPlaySoundPacket(new ResourceLocation(sound), net.minecraft.util.SoundCategory.valueOf(category.name()), new Vector3d(loc.getX(), loc.getY(), loc.getZ()), volume, pitch);
    getHandle().connection.send(packet);
}
Also used : Vector3d(net.minecraft.util.math.vector.Vector3d) ResourceLocation(net.minecraft.util.ResourceLocation) SPlaySoundPacket(net.minecraft.network.play.server.SPlaySoundPacket)

Example 3 with SPlaySoundPacket

use of net.minecraft.network.play.server.SPlaySoundPacket in project LoliServer by Loli-Server.

the class CraftPlayer method playSound.

@Override
public void playSound(Location loc, String sound, org.bukkit.SoundCategory category, float volume, float pitch) {
    if (loc == null || sound == null || category == null || getHandle().connection == null)
        return;
    SPlaySoundPacket packet = new SPlaySoundPacket(new ResourceLocation(sound), net.minecraft.util.SoundCategory.valueOf(category.name()), new Vector3d(loc.getX(), loc.getY(), loc.getZ()), volume, pitch);
    getHandle().connection.send(packet);
}
Also used : Vector3d(net.minecraft.util.math.vector.Vector3d) ResourceLocation(net.minecraft.util.ResourceLocation) SPlaySoundPacket(net.minecraft.network.play.server.SPlaySoundPacket)

Example 4 with SPlaySoundPacket

use of net.minecraft.network.play.server.SPlaySoundPacket in project LoliServer by Loli-Server.

the class CraftWorld method playSound.

@Override
public void playSound(Location loc, String sound, org.bukkit.SoundCategory category, float volume, float pitch) {
    if (loc == null || sound == null || category == null)
        return;
    double x = loc.getX();
    double y = loc.getY();
    double z = loc.getZ();
    SPlaySoundPacket packet = new SPlaySoundPacket(new ResourceLocation(sound), SoundCategory.valueOf(category.name()), new Vector3d(x, y, z), volume, pitch);
    world.getServer().getPlayerList().broadcast(null, x, y, z, volume > 1.0F ? 16.0F * volume : 16.0D, this.world.dimension(), packet);
}
Also used : Vector3d(net.minecraft.util.math.vector.Vector3d) ResourceLocation(net.minecraft.util.ResourceLocation) SPlaySoundPacket(net.minecraft.network.play.server.SPlaySoundPacket)

Example 5 with SPlaySoundPacket

use of net.minecraft.network.play.server.SPlaySoundPacket in project Magma-1.16.x by magmafoundation.

the class CraftPlayer method playSound.

@Override
public void playSound(final net.kyori.adventure.sound.Sound sound, final double x, final double y, final double z) {
    final ResourceLocation name = io.papermc.paper.adventure.PaperAdventure.asVanilla(sound.name());
    final java.util.Optional<SoundEvent> event = Registry.SOUND_EVENT.getOptional(name);
    if (event.isPresent()) {
        this.getHandle().connection.send(new SPlaySoundEffectPacket(event.get(), io.papermc.paper.adventure.PaperAdventure.asVanilla(sound.source()), x, y, z, sound.volume(), sound.pitch()));
    } else {
        this.getHandle().connection.send(new SPlaySoundPacket(name, io.papermc.paper.adventure.PaperAdventure.asVanilla(sound.source()), new Vector3d(x, y, z), sound.volume(), sound.pitch()));
    }
}
Also used : SoundEvent(net.minecraft.util.SoundEvent) Vector3d(net.minecraft.util.math.vector.Vector3d) ResourceLocation(net.minecraft.util.ResourceLocation) SPlaySoundPacket(net.minecraft.network.play.server.SPlaySoundPacket) SPlaySoundEffectPacket(net.minecraft.network.play.server.SPlaySoundEffectPacket)

Aggregations

SPlaySoundPacket (net.minecraft.network.play.server.SPlaySoundPacket)5 ResourceLocation (net.minecraft.util.ResourceLocation)5 Vector3d (net.minecraft.util.math.vector.Vector3d)5 SPlaySoundEffectPacket (net.minecraft.network.play.server.SPlaySoundEffectPacket)1 SoundEvent (net.minecraft.util.SoundEvent)1