mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 04:57:27 +00:00
ScriptSoundController:
-Fixed ConcurrentModificationException by using an Iterator to remove inactive sounds
This commit is contained in:
1 parent
58e129e0df
commit
d28a523c49
1 file changed
+5
-3
@@ -4,6 +4,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.SoundHandler;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -17,11 +18,12 @@ public class ScriptSoundController {
|
||||
|
||||
public void onUpdate() {
|
||||
SoundHandler soundHandler = Minecraft.getMinecraft().getSoundHandler();
|
||||
final Set<Map.Entry<Integer, ScriptClientSound>> entrySet = sounds.entrySet();
|
||||
for (Map.Entry<Integer, ScriptClientSound> entry : entrySet) {
|
||||
final Iterator<Map.Entry<Integer, ScriptClientSound>> iterator = sounds.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<Integer, ScriptClientSound> entry = iterator.next();
|
||||
ScriptClientSound sound = entry.getValue();
|
||||
if (!soundHandler.isSoundPlaying(sound) && !sound.canRepeat() && !sound.paused) {
|
||||
sounds.remove(entry.getKey());
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user