Music tracker null pointer check

This commit is contained in:
paulevsGitch 2021-03-17 23:00:06 +03:00
parent d90e352312
commit b69ce7f3b2

View file

@ -42,7 +42,7 @@ public class MusicTrackerMixin {
public void be_onTick(CallbackInfo info) { public void be_onTick(CallbackInfo info) {
if (ClientOptions.blendBiomeMusic()) { if (ClientOptions.blendBiomeMusic()) {
MusicSound musicSound = client.getMusicType(); MusicSound musicSound = client.getMusicType();
if (volume > 0 && beIsInEnd() && beShouldChangeSound(musicSound)) { if (be_checkNullSound(musicSound) && volume > 0 && be_isInEnd() && be_shouldChangeSound(musicSound)) {
if (volume > 0) { if (volume > 0) {
if (srcVolume < 0) { if (srcVolume < 0) {
srcVolume = current.getVolume(); srcVolume = current.getVolume();
@ -81,14 +81,18 @@ public class MusicTrackerMixin {
} }
} }
private boolean beIsInEnd() { private boolean be_isInEnd() {
return client.world != null && client.world.getRegistryKey().equals(World.END); return client.world != null && client.world.getRegistryKey().equals(World.END);
} }
private boolean beShouldChangeSound(MusicSound musicSound) { private boolean be_shouldChangeSound(MusicSound musicSound) {
return current != null && !musicSound.getSound().getId().equals(this.current.getId()) && musicSound.shouldReplaceCurrentMusic(); return current != null && !musicSound.getSound().getId().equals(this.current.getId()) && musicSound.shouldReplaceCurrentMusic();
} }
private boolean be_checkNullSound(MusicSound musicSound) {
return musicSound != null && musicSound.getSound() != null;
}
@Shadow @Shadow
public void play(MusicSound type) {} public void play(MusicSound type) {}
} }