Search in sources :

Example 1 with BuiltinSound

use of com.github.steveice10.mc.protocol.data.game.world.sound.BuiltinSound in project DragonProxy by DragonetMC.

the class PCPlaySoundPacketTranslator method translate.

public PEPacket[] translate(UpstreamSession session, ServerPlaySoundPacket packet) {
    try {
        String soundName;
        if (BuiltinSound.class.isAssignableFrom(packet.getSound().getClass())) {
            BuiltinSound sound = (BuiltinSound) packet.getSound();
            soundName = sound.name();
        } else {
            soundName = ((CustomSound) packet.getSound()).getName();
        }
        if (soundName == null) {
            return null;
        }
        PlaySoundPacket pk = new PlaySoundPacket();
        pk.blockPosition = new BlockPosition((int) packet.getX(), (int) packet.getY(), (int) packet.getZ());
        pk.name = soundName;
        pk.volume = packet.getVolume();
        pk.pitch = packet.getPitch();
        return new PEPacket[] { pk };
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
Also used : BlockPosition(org.dragonet.common.maths.BlockPosition) PEPacket(org.dragonet.protocol.PEPacket) BuiltinSound(com.github.steveice10.mc.protocol.data.game.world.sound.BuiltinSound) PlaySoundPacket(org.dragonet.protocol.packets.PlaySoundPacket) ServerPlaySoundPacket(com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerPlaySoundPacket)

Aggregations

BuiltinSound (com.github.steveice10.mc.protocol.data.game.world.sound.BuiltinSound)1 ServerPlaySoundPacket (com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerPlaySoundPacket)1 BlockPosition (org.dragonet.common.maths.BlockPosition)1 PEPacket (org.dragonet.protocol.PEPacket)1 PlaySoundPacket (org.dragonet.protocol.packets.PlaySoundPacket)1