From 4cb0bca6048764e9e02958f961f58644e90773ee Mon Sep 17 00:00:00 2001 From: GoldenStack Date: Fri, 28 Oct 2022 21:01:17 -0500 Subject: [PATCH 1/2] Fallback to the sound's ID if it doesn't have a subtitled set --- src/main/java/anticope/rejects/modules/SoundLocator.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/anticope/rejects/modules/SoundLocator.java b/src/main/java/anticope/rejects/modules/SoundLocator.java index 1efbbbd..8973c78 100644 --- a/src/main/java/anticope/rejects/modules/SoundLocator.java +++ b/src/main/java/anticope/rejects/modules/SoundLocator.java @@ -13,6 +13,7 @@ import net.minecraft.client.sound.SoundInstance; import net.minecraft.client.sound.WeightedSoundSet; import net.minecraft.sound.SoundEvent; import net.minecraft.text.MutableText; +import net.minecraft.text.Text; import net.minecraft.util.Formatting; import net.minecraft.util.math.Vec3d; @@ -46,7 +47,12 @@ public class SoundLocator extends Module { private void printSound(SoundInstance sound) { WeightedSoundSet soundSet = mc.getSoundManager().get(sound.getId()); - MutableText text = soundSet.getSubtitle().copy(); + MutableText text; + if (soundSet == null || soundSet.getSubtitle() == null) { + text = Text.literal(sound.getId().toString()); + } else { + text = soundSet.getSubtitle().copy(); + } text.append(String.format("%s at ", Formatting.RESET)); Vec3d pos = new Vec3d(sound.getX(), sound.getY(), sound.getZ()); text.append(ChatUtils.formatCoords(pos)); From eb3d39a4d58a7200eda13065a81cfdd3695e9ba1 Mon Sep 17 00:00:00 2001 From: GoldenStack Date: Fri, 28 Oct 2022 21:03:24 -0500 Subject: [PATCH 2/2] Use the sound set's ID instead when possible --- src/main/java/anticope/rejects/modules/SoundLocator.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/anticope/rejects/modules/SoundLocator.java b/src/main/java/anticope/rejects/modules/SoundLocator.java index 8973c78..8b68a4e 100644 --- a/src/main/java/anticope/rejects/modules/SoundLocator.java +++ b/src/main/java/anticope/rejects/modules/SoundLocator.java @@ -48,8 +48,10 @@ public class SoundLocator extends Module { private void printSound(SoundInstance sound) { WeightedSoundSet soundSet = mc.getSoundManager().get(sound.getId()); MutableText text; - if (soundSet == null || soundSet.getSubtitle() == null) { + if (soundSet == null) { text = Text.literal(sound.getId().toString()); + } else if (soundSet.getSubtitle() == null) { + text = Text.literal(soundSet.getId().toString()); } else { text = soundSet.getSubtitle().copy(); }