diff options
author | olim <bobq4582@gmail.com> | 2024-02-19 15:45:16 +0000 |
---|---|---|
committer | olim <bobq4582@gmail.com> | 2024-02-19 15:45:16 +0000 |
commit | 28299e61238d90d690541e713e1c059e6ec00ed0 (patch) | |
tree | fc3b33e46877f38c05a91cf478f1004e5486ba8f /src/main/java/de/hysky | |
parent | b3e4dabf7ffce74c8cd137d1ea7418c4ca1026dd (diff) | |
download | Skyblocker-28299e61238d90d690541e713e1c059e6ec00ed0.tar.gz Skyblocker-28299e61238d90d690541e713e1c059e6ec00ed0.tar.bz2 Skyblocker-28299e61238d90d690541e713e1c059e6ec00ed0.zip |
fix the current custom sound not loading in the config ui
compare the ids as this seams the only way to get the correct index
Diffstat (limited to 'src/main/java/de/hysky')
-rw-r--r-- | src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleConfigScreen.java | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleConfigScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleConfigScreen.java index 31611991..3adfc6fe 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleConfigScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleConfigScreen.java @@ -11,10 +11,13 @@ import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvents; import net.minecraft.text.MutableText; import net.minecraft.text.Text; +import net.minecraft.util.Identifier; import java.awt.*; +import java.util.List; import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; import static java.util.Map.entry; @@ -70,7 +73,19 @@ public class ChatRuleConfigScreen extends Screen { this.chatRuleIndex = chatRuleIndex; this.chatRule = ChatRulesHandler.chatRuleList.get(chatRuleIndex); this.parent = parent; - this.currentSoundIndex = soundsLookup.values().stream().toList().indexOf(chatRule.getCustomSound()); + this.currentSoundIndex = getCurrentSoundIndex(); + } + + private int getCurrentSoundIndex() { + List<SoundEvent> soundOptions = soundsLookup.values().stream().toList(); + Identifier ruleSoundId = chatRule.getCustomSound().getId(); + for (int i = 0; i < soundOptions.size(); i++) { + if (soundOptions.get(i).getId().compareTo(ruleSoundId) == 0) { + return i; + } + } + //not found + return -1; } @Override @@ -198,7 +213,7 @@ public class ChatRuleConfigScreen extends Screen { }) .position(currentPos.leftInt() + lineXOffset, currentPos.rightInt()) .size(100,20) - .tooltip(Tooltip.of(Text.translatable("text.autoconfig.skyblocker.option.messages.chatRules.screen.ruleScreen.sound.@Tooltip"))) + .tooltip(Tooltip.of(Text.translatable("text.autoconfig.skyblocker.option.messages.chatRules.screen.ruleScreen.sounds.@Tooltip"))) .build(); currentPos = IntIntPair.of(currentPos.leftInt(),currentPos.rightInt() + SPACER_Y); |