Fixed the client crashs when a Player in the render distance dead (including client player)

Bad End: Dead and Crash
just kidding
This commit is contained in:
ReinforceZwei 2020-03-25 00:03:26 +08:00 committed by ORelio
parent 4b08912407
commit c870f080f2

View file

@ -1115,10 +1115,10 @@ namespace MinecraftClient
{ {
foreach (int a in Entities) foreach (int a in Entities)
{ {
foreach (ChatBot bot in bots.ToArray())
bot.OnEntityDespawn(new Entity(entities[a].ID, entities[a].Type, entities[a].Location));
if (entities.ContainsKey(a)) if (entities.ContainsKey(a))
{ {
foreach (ChatBot bot in bots.ToArray())
bot.OnEntityDespawn(new Entity(entities[a].ID, entities[a].Type, entities[a].Location));
entities.Remove(a); entities.Remove(a);
} }
} }