From aed891e3c87c82359f887d2ec6a1ff48a47f84c7 Mon Sep 17 00:00:00 2001 From: initsuj Date: Tue, 23 Feb 2016 11:19:14 -0700 Subject: [PATCH] Fixed IndexOutOfRangeException when bot is unloaded on update --- MinecraftClient/McTcpClient.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MinecraftClient/McTcpClient.cs b/MinecraftClient/McTcpClient.cs index 35eaa124..f50baecd 100644 --- a/MinecraftClient/McTcpClient.cs +++ b/MinecraftClient/McTcpClient.cs @@ -477,18 +477,18 @@ namespace MinecraftClient public void OnUpdate() { - for (int i = 0; i < bots.Count; i++) + foreach (var bot in bots.ToArray()) { try { - bots[i].Update(); - bots[i].ProcessQueuedText(); + bot.Update(); + bot.ProcessQueuedText(); } catch (Exception e) { if (!(e is ThreadAbortException)) { - ConsoleIO.WriteLineFormatted("§8Update: Got error from " + bots[i].ToString() + ": " + e.ToString()); + ConsoleIO.WriteLineFormatted("§8Update: Got error from " + bot.ToString() + ": " + e.ToString()); } else throw; //ThreadAbortException should not be caught }