• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

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

First Machine Age's Mods (Combined repo.)


Commit MetaInfo

Révision3ce516f1d434f89407a13fd3af8f22a584364cf8 (tree)
l'heure2022-08-30 07:17:17
Auteurmelchior <melchior@user...>
Commitermelchior

Message de Log

Compat changes for 1.17

Change Summary

Modification

--- a/AnvilMetalRecovery/EntityBehaviors/HotbarObserverData.cs
+++ b/AnvilMetalRecovery/EntityBehaviors/HotbarObserverData.cs
@@ -56,6 +56,13 @@ namespace AnvilMetalRecovery
5656 {
5757 throw new NotImplementedException( );
5858 }
59+
60+ public IAttribute Clone( )
61+ {
62+ var newbie = new HotbarObserverData(this.InventoryID, this.Inventory_SlotID, this.ItemCode.Clone( ), this.PlayerUID);
63+
64+ return newbie;
65+ }
5966 }
6067 }
6168
--- a/AnvilMetalRecovery/MetalRecoverySystem.cs
+++ b/AnvilMetalRecovery/MetalRecoverySystem.cs
@@ -39,7 +39,7 @@ namespace AnvilMetalRecovery
3939 private RecoveryEntryTable itemToVoxelLookup = new RecoveryEntryTable();//Item Asset Code to: Ammount & Material
4040
4141 private ICoreAPI CoreAPI;
42- private ICoreServerAPI ServerAPI;
42+
4343 private ServerCoreAPI ServerCore { get; set; }
4444 private ClientCoreAPI ClientCore { get; set; }
4545
@@ -110,7 +110,18 @@ namespace AnvilMetalRecovery
110110
111111 RegisterItemMappings( );
112112 RegisterBlockBehaviors( );
113-
113+ if (api.Side.IsServer())
114+ {
115+ if (api is ServerCoreAPI) {
116+ ServerCore = api as ServerCoreAPI;
117+ }
118+ ServerCore.Event.AssetsFinalizers += AttachExtraBlockBehaviors;
119+ }
120+ else
121+ {
122+ ClientCore = api as ClientCoreAPI;
123+ ClientCore.Event.LevelFinalize += PerformBlockClassSwaps;
124+ }
114125
115126 #if DEBUG
116127 //Harmony.DEBUG = true;
@@ -123,54 +134,38 @@ namespace AnvilMetalRecovery
123134
124135 public override void StartServerSide(ICoreServerAPI api)
125136 {
126- this.ServerAPI = api;
127137
128-
129- if (api is ServerCoreAPI) {
130- ServerCore = api as ServerCoreAPI;
131- }
132- else {
133- Mod.Logger.Error("Cannot access 'ServerCoreAPI' class: API (implimentation) has changed, Contact Developer!");
134- return;
135- }
136138 PrepareServersideConfig( );
137139 PrepareDownlinkChannel( );
138- ServerAPI.Event.PlayerJoin += SendClientConfigMessage;
139- ServerAPI.Event.ServerRunPhase(EnumServerRunPhase.Shutdown, PersistServersideConfig);
140- ServerAPI.Event.ServerRunPhase(EnumServerRunPhase.GameReady, MaterialDataGathering);
141- PerformBlockClassSwaps();
142- ServerAPI.Event.ServerRunPhase(EnumServerRunPhase.RunGame, CacheRecoveryDataTable);
143- ServerAPI.Event.ServerRunPhase(EnumServerRunPhase.GameReady, AttachExtraBlockBehaviors);
140+ ServerCore.Event.PlayerJoin += SendClientConfigMessage;
141+ ServerCore.Event.ServerRunPhase(EnumServerRunPhase.Shutdown, PersistServersideConfig);
142+ ServerCore.Event.ServerRunPhase(EnumServerRunPhase.GameReady, MaterialDataGathering);
143+ ServerCore.Event.ServerRunPhase(EnumServerRunPhase.RunGame, CacheRecoveryDataTable);
144144
145145 SetupGeneralObservers( );
146146
147147 Mod.Logger.VerboseDebug("Anvil Metal Recovery - should be installed...");
148148
149149 #if DEBUG
150- ServerAPI.RegisterCommand("durability", "edit durability of item", " (Held tool) and #", EditDurability, Privilege.give);
150+ ServerCore.RegisterCommand("durability", "edit durability of item", " (Held tool) and #", EditDurability, Privilege.give);
151151 #endif
152152
153153 }
154154
155155 public override void StartClientSide(ICoreClientAPI api)
156156 {
157- base.StartClientSide(api);
158-
159- if (api is ClientCoreAPI) {
160- ClientCore = api as ClientCoreAPI;
161- }
162- else {
163- Mod.Logger.Error("Cannot access 'ClientCoreAPI' class: API (implimentation) has changed, Contact Developer!");
164- return;
165- }
157+ base.StartClientSide(api);
166158
167- ListenForServerConfigMessage( );
168- //ClientCore.Event.RegisterCallback(PerformBlockClassSwaps, 0);
169- PerformBlockClassSwaps();
159+ ListenForServerConfigMessage( );
170160
171161 Mod.Logger.VerboseDebug("Anvil Metal Recovery - should be installed...");
172162 }
173163
164+ public override void AssetsLoaded(ICoreAPI api)
165+ {
166+ if (api.Side.IsServer( )) { PerformBlockClassSwaps( );}
167+ }
168+
174169
175170 private void RegisterItemMappings( )
176171 {
@@ -189,6 +184,9 @@ namespace AnvilMetalRecovery
189184
190185 private void PerformBlockClassSwaps()
191186 {
187+ #if DEBUG
188+ Mod.Logger.Debug("PerformBlockClassSwaps");
189+ #endif
192190 if (CoreAPI.Side == EnumAppSide.Server)
193191 this.ServerCore.ClassRegistryNative.ReplaceBlockClassType(BlockWateringCanPlus.BlockClassName, typeof(BlockWateringCanPlus));
194192 else
@@ -202,7 +200,7 @@ namespace AnvilMetalRecovery
202200 new AssetLocation(@"game",@"toolmold-burned-*"),
203201 };
204202
205- var moldRecoverBehaviorType = ServerAPI.ClassRegistry.GetBlockBehaviorClass(MoldDestructionRecovererBehavior.BehaviorClassName);
203+ var moldRecoverBehaviorType = ServerCore.ClassRegistry.GetBlockBehaviorClass(MoldDestructionRecovererBehavior.BehaviorClassName);
206204 foreach (var assetName in mold_behaviorsAppendList) {
207205 if (!assetName.IsWildCard)
208206 {
@@ -212,7 +210,7 @@ namespace AnvilMetalRecovery
212210 #endif
213211 }
214212 else {
215- var searchResults = ServerAPI.World.SearchBlocks(assetName);
213+ var searchResults = ServerCore.World.SearchBlocks(assetName);
216214 if (searchResults != null && searchResults.Length > 0) {
217215 #if DEBUG
218216 Mod.Logger.VerboseDebug("Attaching Block-Behaviors, wildcard matches from '{0}'", assetName);
@@ -237,14 +235,14 @@ namespace AnvilMetalRecovery
237235
238236 private void PrepareServersideConfig( )
239237 {
240- AMRConfig config = ServerAPI.LoadModConfig<AMRConfig>(_configFilename);
238+ AMRConfig config = ServerCore.LoadModConfig<AMRConfig>(_configFilename);
241239
242240 if (config == null)
243241 {
244242 //Regen default
245243 Mod.Logger.Warning("Regenerating default config as it was missing / unparsable...");
246- ServerAPI.StoreModConfig<AMRConfig>(new AMRConfig(true), _configFilename);
247- config = ServerAPI.LoadModConfig<AMRConfig>(_configFilename);
244+ ServerCore.StoreModConfig<AMRConfig>(new AMRConfig(true), _configFilename);
245+ config = ServerCore.LoadModConfig<AMRConfig>(_configFilename);
248246 }
249247 else if( config.BlackList == null || config.BlackList.Count == 0)
250248 {
@@ -259,13 +257,13 @@ namespace AnvilMetalRecovery
259257 {
260258 if (this.CachedConfiguration != null) {
261259 Mod.Logger.Notification("Persisting configuration.");
262- ServerAPI.StoreModConfig<AMRConfig>(this.CachedConfiguration, _configFilename);
260+ ServerCore.StoreModConfig<AMRConfig>(this.CachedConfiguration, _configFilename);
263261 }
264262 }
265263
266264 private void PrepareDownlinkChannel( )
267265 {
268- _ConfigDownlink = ServerAPI.Network.RegisterChannel(_configFilename);
266+ _ConfigDownlink = ServerCore.Network.RegisterChannel(_configFilename);
269267 _ConfigDownlink.RegisterMessageType<AMRConfig>( );
270268 }
271269
@@ -309,7 +307,7 @@ namespace AnvilMetalRecovery
309307 #if DEBUG
310308 Mod.Logger.VerboseDebug("Adding Recovery entries table to Cache...");
311309 #endif
312- ServerAPI.ObjectCache.Add(itemFilterListCacheKey, itemToVoxelLookup);
310+ ServerCore.ObjectCache.Add(itemFilterListCacheKey, itemToVoxelLookup);
313311 }
314312 }
315313
--- a/AnvilMetalRecovery/MetalRecoverySystem_Components.cs
+++ b/AnvilMetalRecovery/MetalRecoverySystem_Components.cs
@@ -30,8 +30,8 @@ namespace AnvilMetalRecovery
3030 continue;
3131 }
3232
33- CollectibleObject metalObject = recipie.Ingredient.Type == EnumItemClass.Item ? ServerAPI.World.GetItem(recipie.Ingredient.Code) : ServerAPI.World.GetBlock(recipie.Ingredient.Code) as CollectibleObject;
34- Item outputItem = ServerAPI.World.GetItem(recipie?.Output?.Code);
33+ CollectibleObject metalObject = recipie.Ingredient.Type == EnumItemClass.Item ? ServerCore.World.GetItem(recipie.Ingredient.Code) : ServerCore.World.GetBlock(recipie.Ingredient.Code) as CollectibleObject;
34+ Item outputItem = ServerCore.World.GetItem(recipie?.Output?.Code);
3535
3636 if (outputItem == null) {
3737 #if DEBUG
@@ -69,9 +69,9 @@ namespace AnvilMetalRecovery
6969 }
7070 else {
7171 //Tool-head map to Tool item; decode
72- var itemToolCode = ServerAPI.World.GridRecipes.FirstOrDefault(gr => gr.Ingredients.Any(crg => crg.Value.Code.Equals(outputItem.Code)) && gr.Enabled && gr.Output.Type == EnumItemClass.Item)?.Output.Code;
72+ var itemToolCode = ServerCore.World.GridRecipes.FirstOrDefault(gr => gr.Ingredients.Any(crg => crg.Value.Code.Equals(outputItem.Code)) && gr.Enabled && gr.Output.Type == EnumItemClass.Item)?.Output.Code;
7373 if (itemToolCode != null) {
74- var itemTool = ServerAPI.World.GetItem(itemToolCode);
74+ var itemTool = ServerCore.World.GetItem(itemToolCode);
7575 if (itemTool == null) {
7676 #if DEBUG
7777 Mod.Logger.Debug($"Missing Output Tool item, from: {recipie.Name.ToString( )}, skipping.");
@@ -133,7 +133,7 @@ namespace AnvilMetalRecovery
133133 if (String.IsNullOrEmpty(hotbarData.PlayerUID) || String.IsNullOrEmpty(hotbarData.InventoryID)) return;
134134
135135 bool probablyHotbar = hotbarData.InventoryID.StartsWith(GlobalConstants.hotBarInvClassName, StringComparison.Ordinal);
136- var playerTarget = ServerAPI.World.PlayerByUid(hotbarData.PlayerUID);
136+ var playerTarget = ServerCore.World.PlayerByUid(hotbarData.PlayerUID);
137137 var spim = playerTarget.InventoryManager as ServerPlayerInventoryManager;
138138 var hotbarInv = playerTarget.InventoryManager.GetHotbarInventory( );
139139 var hotSlot = hotbarInv[hotbarData.Inventory_SlotID];
@@ -144,11 +144,11 @@ namespace AnvilMetalRecovery
144144 Mod.Logger.VerboseDebug("Directly inserting fragments into hotbar slot# {0}", hotbarData.Inventory_SlotID);
145145 #endif
146146
147- VariableMetalItem variableMetal = ServerAPI.World.GetItem(new AssetLocation(metalFragmentsCode)) as VariableMetalItem;
147+ VariableMetalItem variableMetal = ServerCore.World.GetItem(new AssetLocation(metalFragmentsCode)) as VariableMetalItem;
148148 ItemStack metalFragmentsStack = new ItemStack(variableMetal, 1);
149149 variableMetal.ApplyMetalProperties(rec, ref metalFragmentsStack, CachedConfiguration.ToolRecoveryRate);
150150 hotSlot.Itemstack = metalFragmentsStack;
151- hotSlot.Itemstack.ResolveBlockOrItem(ServerAPI.World);
151+ hotSlot.Itemstack.ResolveBlockOrItem(ServerCore.World);
152152 hotSlot.MarkDirty( );
153153 spim.NotifySlot(playerTarget, hotSlot);
154154 }
@@ -158,13 +158,13 @@ namespace AnvilMetalRecovery
158158 Mod.Logger.VerboseDebug("Hotbar-occupied (or crafting) slot#{0} so; shoving {1} in general direction of player...", hotbarData.Inventory_SlotID, hotbarData.ItemCode.ToShortString( ));
159159 #endif
160160
161- VariableMetalItem variableMetal = ServerAPI.World.GetItem(new AssetLocation(metalFragmentsCode)) as VariableMetalItem;
161+ VariableMetalItem variableMetal = ServerCore.World.GetItem(new AssetLocation(metalFragmentsCode)) as VariableMetalItem;
162162 ItemStack metalFragmentsStack = new ItemStack(variableMetal, 1);
163163 variableMetal.ApplyMetalProperties(rec, ref metalFragmentsStack, CachedConfiguration.ToolRecoveryRate);
164164 if (spim.TryGiveItemstack(metalFragmentsStack, true) == false)
165165 {
166166 //Player with full Inv.
167- ServerAPI.World.SpawnItemEntity(metalFragmentsStack, playerTarget.Entity.Pos.XYZ);
167+ ServerCore.World.SpawnItemEntity(metalFragmentsStack, playerTarget.Entity.Pos.XYZ);
168168 }
169169 }
170170 }
@@ -192,7 +192,7 @@ namespace AnvilMetalRecovery
192192 private void ApplySmeltingPropertiesByCodeVariant(AssetLocation updatingCode, int ratioOverride = 1)
193193 {
194194 //ALL ????:'ingot-*' type items...
195- var ingotItems = ServerAPI.World.Items.Where(itm => itm.ItemId > 0 && itm.Code != null && itm.Code.BeginingOnly(@"ingot"));
195+ var ingotItems = ServerCore.World.Items.Where(itm => itm.ItemId > 0 && itm.Code != null && itm.Code.BeginingOnly(@"ingot"));
196196
197197 #if DEBUG
198198 this.Mod.Logger.VerboseDebug("found {0} Ingot type items", ingotItems.Count( ));
@@ -208,16 +208,16 @@ namespace AnvilMetalRecovery
208208
209209 metalSmeltProps.SmeltedRatio = ratioOverride;
210210 AssetLocation shavingCode = updatingCode.AppendPathVariant(metalName);
211- var shavingEquivalentItem = ServerAPI.World.GetItem(shavingCode);
211+ var shavingEquivalentItem = ServerCore.World.GetItem(shavingCode);
212212 if (shavingEquivalentItem != null) {
213213 shavingEquivalentItem.CombustibleProps = metalSmeltProps;
214214 #if DEBUG
215- ServerAPI.Logger.VerboseDebug("Updated SmeltProps, for: {0}", shavingCode.ToString( ));
215+ ServerCore.Logger.VerboseDebug("Updated SmeltProps, for: {0}", shavingCode.ToString( ));
216216 #endif
217217 }
218218 else {
219219 #if DEBUG
220- ServerAPI.Logger.VerboseDebug("Non-existant item: {0}", shavingCode.ToString( ));
220+ ServerCore.Logger.VerboseDebug("Non-existant item: {0}", shavingCode.ToString( ));
221221 #endif
222222 }
223223 }
--- a/AnvilMetalRecovery/modinfo.json
+++ b/AnvilMetalRecovery/modinfo.json
@@ -4,9 +4,9 @@
44 "description" : "Get back smithing discards, broken tool scrap, failed molds; and MORE!",
55 "authors": ["Melchior"],
66 "ModID":"metalrecovery",
7- "version": "0.1.18-rc.1",
7+ "version": "0.1.18-rc.2",
88 "dependencies": {
9- "game": "1.16.5",
9+ "game": "1.17.0-rc.0",
1010 "survival": ""
1111 },
1212 "website": "http://nowebsite.nope"