VS plugin mod for Basic Armour
Revision | 50d2a76def4a964fe07f870a55d193f663d1cc0e (tree) |
---|---|
Time | 2019-05-19 06:49:05 |
Author | melchior <melchior@user...> |
Commiter | melchior |
Fix for Crash on Multiplayer client
(possible race condition dodged)
@@ -51,10 +51,19 @@ namespace ArmourMod | ||
51 | 51 | { |
52 | 52 | EntityArmourPlayer armouredPlayer = aPlayer.Entity as EntityArmourPlayer; |
53 | 53 | |
54 | + if (armouredPlayer == null) { | |
55 | + ClientApi.Logger.Error("Could not cast EntityPlayer to EntityArmourPlayer"); | |
56 | + continue; | |
57 | + } | |
58 | + | |
59 | + if (armouredPlayer.RenderableWornArmours == null) { | |
60 | + ClientApi.Logger.Error("RenderableWornArmours was NULL!"); | |
61 | + continue; | |
62 | + } | |
63 | + | |
54 | 64 | if ( armouredPlayer.RenderableWornArmours.Count > 0 ) { |
55 | 65 | |
56 | 66 | RenderWornArmour( armouredPlayer, rend, stage != EnumRenderStage.Opaque ); |
57 | - | |
58 | 67 | } |
59 | 68 | } |
60 | 69 | } |
@@ -1,7 +1,7 @@ | ||
1 | 1 | using System; |
2 | 2 | using System.Collections.Generic; |
3 | 3 | using System.Linq; |
4 | - | |
4 | +using System.Threading; | |
5 | 5 | |
6 | 6 | using Vintagestory.API.Common; |
7 | 7 | using Vintagestory.API.Client; |
@@ -76,7 +76,7 @@ namespace ArmourMod | ||
76 | 76 | Logger.VerboseDebug( "Side:{0}, gearInv == null?{1}", CoreAPI.Side.ToString( ), base.GearInventory == null ); |
77 | 77 | #endif |
78 | 78 | |
79 | - //base.GearInventory.SlotModified += ClientWatchSlotModified; | |
79 | + | |
80 | 80 | ClientAPI.Event.PlayerJoin += ClientDelayHook; |
81 | 81 | } |
82 | 82 | } |
@@ -251,12 +251,15 @@ namespace ArmourMod | ||
251 | 251 | } |
252 | 252 | |
253 | 253 | |
254 | - | |
255 | 254 | protected void ClientDelayHook(IClientPlayer byPlayer) |
256 | - { | |
257 | -#if DEBUG | |
258 | - Logger.Debug("ClientDelayHook: Checking gearInv is null? {0}", base.GearInventory == null); | |
259 | -#endif | |
255 | + { | |
256 | + retry: | |
257 | + Thread.Sleep(100); | |
258 | + if (base.GearInventory == null) { | |
259 | + Logger.Error("ClientDelayHook: base.GearInventory IS NULL! "); | |
260 | + | |
261 | + goto retry; | |
262 | + } | |
260 | 263 | |
261 | 264 | //CoreAPI.Event.UnregisterCallback(client_callback); |
262 | 265 | base.GearInventory.SlotModified += ClientWatchSlotModified; |
@@ -3,7 +3,7 @@ | ||
3 | 3 | "name": "Basic Armour Mod", |
4 | 4 | "description" : "Leather, Plate, Scale & More", |
5 | 5 | "authors": ["Melchior", "Bunnyviking"], |
6 | - "version": "0.1.3", | |
6 | + "version": "0.1.4", | |
7 | 7 | "dependencies": { |
8 | 8 | "game": "1.9.3", |
9 | 9 | "survival": "" |