use of io.xol.chunkstories.api.sound.SoundSource.Mode in project chunkstories by Hugobros3.
the class PacketSoundSource method process.
@Override
public void process(PacketSender sender, DataInputStream in, PacketReceptionContext processor) throws IOException, PacketProcessingException {
String soundName = in.readUTF();
long UUID = in.readLong();
boolean hasPosition = in.readBoolean();
Vector3dc position = null;
if (hasPosition) {
position = new Vector3d(in.readFloat(), in.readFloat(), in.readFloat());
}
// boolean loop = in.readBoolean();
// boolean isAmbient = in.readBoolean();
// boolean buffered = in.readBoolean();
byte modeByte = in.readByte();
Mode mode = Mode.values()[modeByte];
boolean stopped = in.readBoolean();
float pitch = in.readFloat();
float gain = in.readFloat();
float attenuationStart = in.readFloat();
float attenuationEnd = in.readFloat();
if (!(processor instanceof ClientPacketsProcessor))
return;
ClientPacketsProcessor cpe = (ClientPacketsProcessor) processor;
SoundSource soundSource = cpe.getContext().getSoundManager().getSoundSourceByUUID(UUID);
// ALSoundSource soundSource = (ALSoundSource) Client.getInstance().getSoundManager().getSoundSourceByUUID(UUID);
if (soundSource == null && stopped)
return;
if (soundSource == null) {
soundSource = cpe.getContext().getSoundManager().replicateServerSoundSource(soundName, mode, position, pitch, gain, attenuationStart, attenuationEnd, UUID);
return;
}
if (stopped) {
soundSource.stop();
return;
}
// Update the soundSource with all we can
soundSource.setPosition(position);
soundSource.setPitch(pitch);
soundSource.setGain(gain);
soundSource.setAttenuationStart(attenuationStart);
soundSource.setAttenuationEnd(attenuationEnd);
}
Aggregations