• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

VS plugin mod for Basic Armour


コミットメタ情報

リビジョンbdcc17d40c3cf30b7f6791d6b27c85ff3eac914f (tree)
日時2019-05-19 09:07:30
作者melchior <melchior@user...>
コミッターmelchior

ログメッセージ

Reworked workaround for out of order execution
Renderer will self-disable on exception

変更サマリ

差分

--- a/ArmourMod/Armour/AmourMeshRenderer.cs
+++ b/ArmourMod/Armour/AmourMeshRenderer.cs
@@ -16,6 +16,7 @@ namespace ArmourMod
1616 {
1717 protected ICoreClientAPI ClientApi { get; set; }
1818 private Dictionary<AssetLocation,ArmourModelData> Armoury;
19+ private bool enabled = true;
1920
2021 public double RenderOrder
2122 {
@@ -35,37 +36,43 @@ namespace ArmourMod
3536 }
3637
3738 public void OnRenderFrame(float deltaTime, EnumRenderStage stage)
38- {
39- for (int i = 0; i < ClientApi.World.AllOnlinePlayers.Length; i++)
40- {
41- var aPlayer = ClientApi.World.AllOnlinePlayers[i];
39+ {
40+ if (enabled) {
41+ try {
42+ for (int i = 0; i < ClientApi.World.AllOnlinePlayers.Length; i++) {
43+ var aPlayer = ClientApi.World.AllOnlinePlayers[i];
4244
43- if ( aPlayer != null ) {
44-
45- EntityShapeRenderer rend = aPlayer.Entity.Properties.Client.Renderer as EntityShapeRenderer;
46-
47- if ( rend == null )
48- continue;
45+ if (aPlayer != null) {
4946
50- if (aPlayer.Entity is EntityArmourPlayer)
51- {
52- EntityArmourPlayer armouredPlayer = aPlayer.Entity as EntityArmourPlayer;
47+ EntityShapeRenderer rend = aPlayer.Entity.Properties.Client.Renderer as EntityShapeRenderer;
5348
54- if (armouredPlayer == null) {
55- ClientApi.Logger.Error("Could not cast EntityPlayer to EntityArmourPlayer");
56- continue;
57- }
49+ if (rend == null)
50+ continue;
5851
59- if (armouredPlayer.RenderableWornArmours == null) {
60- ClientApi.Logger.Error("RenderableWornArmours was NULL!");
61- continue;
62- }
52+ if (aPlayer.Entity is EntityArmourPlayer) {
53+ EntityArmourPlayer armouredPlayer = aPlayer.Entity as EntityArmourPlayer;
6354
64- if ( armouredPlayer.RenderableWornArmours.Count > 0 ) {
65-
66- RenderWornArmour( armouredPlayer, rend, stage != EnumRenderStage.Opaque );
55+ if (armouredPlayer == null) {
56+ ClientApi.Logger.Error("Could not cast EntityPlayer to EntityArmourPlayer");
57+ return;
58+ }
59+
60+ if (armouredPlayer.RenderableWornArmours == null) {
61+ ClientApi.Logger.Error("RenderableWornArmours was NULL!");
62+ return;
63+ }
64+
65+ if (armouredPlayer.RenderableWornArmours.Count > 0) {
66+
67+ RenderWornArmour(armouredPlayer, rend, stage != EnumRenderStage.Opaque);
68+ }
69+ }
6770 }
6871 }
72+ } catch (Exception problem)
73+ {
74+ ClientApi.Logger.Error("ArmourMeshRenderer FAULT: {0} Disabling.", problem.Message);
75+ enabled = false;
6976 }
7077 }
7178 }
--- a/ArmourMod/Armour/EntityArmourPlayer.cs
+++ b/ArmourMod/Armour/EntityArmourPlayer.cs
@@ -23,6 +23,9 @@ namespace ArmourMod
2323 //Pre-compute values;
2424 private DamageFilter finalFilter;
2525
26+ private long recurringClientDelayHookId;
27+
28+
2629 internal ArmourModConfig CachedConfiguration
2730 {
2831 get
@@ -252,20 +255,35 @@ namespace ArmourMod
252255
253256
254257 protected void ClientDelayHook(IClientPlayer byPlayer)
255- {
256- retry:
257- Thread.Sleep(100);
258+ {
258259 if (base.GearInventory == null) {
259260 Logger.Error("ClientDelayHook: base.GearInventory IS NULL! ");
260-
261- goto retry;
261+ recurringClientDelayHookId = ClientAPI.Event.RegisterCallback(RecurringClientDelayHook, 100);
262+ return;
262263 }
263264
264- //CoreAPI.Event.UnregisterCallback(client_callback);
265265 base.GearInventory.SlotModified += ClientWatchSlotModified;
266266 PopulateWornArmourModels( );
267267 }
268268
269+ protected void RecurringClientDelayHook(float delayed)
270+ {
271+ if (base.GearInventory == null) {
272+ Logger.Error("RecurringClientDelayHook: base.GearInventory IS NULL! ");
273+
274+ return;
275+ } else {
276+ Logger.Notification("RecurringClientDelayHook: Finally the Gear data arrived - can proceed with event hooks");
277+
278+ ClientAPI.Event.UnregisterCallback(recurringClientDelayHookId);
279+
280+ base.GearInventory.SlotModified += ClientWatchSlotModified;
281+ PopulateWornArmourModels( );
282+ }
283+ }
284+
285+
286+
269287 private void ServerWatchSlotModified (int slotId)
270288 {
271289 var watchedSlot = base.GearInventory[slotId];
--- a/ArmourMod/modinfo.json
+++ b/ArmourMod/modinfo.json
@@ -3,7 +3,7 @@
33 "name": "Basic Armour Mod",
44 "description" : "Leather, Plate, Scale & More",
55 "authors": ["Melchior", "Bunnyviking"],
6- "version": "0.1.4",
6+ "version": "0.1.5",
77 "dependencies": {
88 "game": "1.9.3",
99 "survival": ""