From 826c54e03d7b73b7986e0150e4d0c2640e16f7c3 Mon Sep 17 00:00:00 2001 From: asanetargoss Date: Sat, 12 Oct 2019 19:53:13 -0700 Subject: [PATCH] Fix crash when null sound processed by SoundHandler --- .../java/mchorse/metamorph/entity/SoundHandler.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/mchorse/metamorph/entity/SoundHandler.java b/src/main/java/mchorse/metamorph/entity/SoundHandler.java index 2be69bf6..4495f7fa 100644 --- a/src/main/java/mchorse/metamorph/entity/SoundHandler.java +++ b/src/main/java/mchorse/metamorph/entity/SoundHandler.java @@ -69,8 +69,18 @@ public void onPlaySound(PlaySoundAtEntityEvent event) { return; } + + SoundEvent sound = event.getSound(); + if (sound == null) { + // Sounds can be null, apparently + return; + } + ResourceLocation soundResource = sound.getRegistryName(); + if (soundResource == null) { + return; + } + String soundType = soundResource.getResourcePath(); - String soundType = event.getSound().getRegistryName().getResourcePath(); if (soundType.endsWith(".hurt")) { SoundEvent newSound = morph.getHurtSound(player, morphing.getLastDamageSource());