When trying to use getSound().getVolume() or getSound().getPitch() methods on PlaySoundEvent, it will generate a NullPointerException if called for any Minecraft sound, like this one:
crash-2020-01-31_14.46.31-client.txt
In case anyone needs it, here is the code that caused that crash:
package com.sonicether.soundphysics.utils;
import net.minecraftforge.client.event.sound.PlaySoundEvent;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.SubscribeEvent;
public class SoundEventHandler {
@SubscribeEvent(priority= EventPriority.LOWEST)
public void onEvent(PlaySoundEvent event) {
event.getSound().getVolume();
}
}
This happens because net.minecraft.client.audio.LocatableSound, the main class every sound in Minecraft extends, uses this.sound.getVolume() and this.sound.getPitch(), but as at the time the ForgeHook is implemented the sound field has not yet been initialized, it's null, and generates the NPE.
This also results in that getSound().getSound() will always return null.