diff --git a/Systems/World/WorldgenManagementSystem.cs b/Systems/World/WorldgenManagementSystem.cs index f37b0f5d2e..a314ebf140 100644 --- a/Systems/World/WorldgenManagementSystem.cs +++ b/Systems/World/WorldgenManagementSystem.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Threading; using CalamityMod.Items.SummonItems; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.World; @@ -362,7 +363,8 @@ namespace CalamityMod.Systems // Insert the Astral biome generation right before the final hardmode announcement. tasks.Insert(announceIndex, new PassLegacy("AstralMeteor", (progress, config) => { - AstralBiome.PlaceAstralMeteor(); + //Delaying it a bit so that weaker pcs dont suffer - Shade + ThreadPool.QueueUserWorkItem(_ => World.AstralBiome.PlaceAstralMeteor()); })); } #endregion diff --git a/Utilities/GlobalEntityUtils.cs b/Utilities/GlobalEntityUtils.cs index 7e5c2490f3..5376de2c92 100644 --- a/Utilities/GlobalEntityUtils.cs +++ b/Utilities/GlobalEntityUtils.cs @@ -19,22 +19,30 @@ namespace CalamityMod /// true If we successfully get GlobalNPC. otherwise false public static bool TryGetGlobalNPCSafer(this NPC npc, out T globalNPC) where T : GlobalNPC { - if (npc is null) + try + { + if (npc is null) + { + globalNPC = null; + return false; + } + + int slot = ModContent.GetInstance()?.PerEntityIndex ?? -1; + int length = npc.EntityGlobals.Length; + if (slot < 0 || slot >= length) + { + globalNPC = null; + return false; + } + + npc.TryGetGlobalNPC(out globalNPC); + return globalNPC != null; + } + catch { globalNPC = null; return false; } - - int slot = ModContent.GetInstance()?.PerEntityIndex ?? -1; - int length = npc.EntityGlobals.Length; - if (slot < 0 || slot >= length) - { - globalNPC = null; - return false; - } - - npc.TryGetGlobalNPC(out globalNPC); - return globalNPC != null; } } }