• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得cocoawindowspythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdombtronvb.netdirectxarduinopreviewerゲームエンジン

First Machine Age's Mods (Combined repo.)


Commit MetaInfo

Revision805ec5fd2154c0bbf23e660dc649b52d6c1fd5b7 (tree)
Time2022-03-28 04:19:40
Authormelchior <melchior@user...>
Commitermelchior

Log Message

AMR 0.1.17

3rd party Smithery mods API exposure; boog fxeis for Broken Metal
Fragments Tooltip

Change Summary

Incremental Difference

--- a/AnvilMetalRecovery/AnvilMetalRecovery.csproj
+++ b/AnvilMetalRecovery/AnvilMetalRecovery.csproj
@@ -85,6 +85,7 @@
8585 <Compile Include="MetalRecoverySystem_Components.cs" />
8686 <Compile Include="Harmony\GenericItemMortalityDetector.cs" />
8787 <Compile Include="Data\AMR_Config.cs" />
88+ <Compile Include="Data\RecoveryEntryTable.cs" />
8889 </ItemGroup>
8990 <ItemGroup>
9091 <None Include="modinfo.json">
--- a/AnvilMetalRecovery/BlockEntities/MetalRecovery_BlockEntityAnvil.cs
+++ b/AnvilMetalRecovery/BlockEntities/MetalRecovery_BlockEntityAnvil.cs
@@ -67,6 +67,7 @@ namespace AnvilMetalRecovery
6767
6868 base.MarkDirty (false);
6969 */
70+
7071
7172 if (splitTemp > 0 && this.WorkItemStack == null && this.SelectedRecipe == null)
7273 {
--- a/AnvilMetalRecovery/Data/RecoveryEntry.cs
+++ b/AnvilMetalRecovery/Data/RecoveryEntry.cs
@@ -6,6 +6,7 @@ namespace AnvilMetalRecovery
66 {
77 public struct RecoveryEntry
88 {
9+ public readonly AssetLocation CollectableCode;
910 public AssetLocation IngotCode;
1011 /// <summary>
1112 /// Metal Quantity (VOXELS)
@@ -14,9 +15,10 @@ namespace AnvilMetalRecovery
1415 public float Melting_Duration;
1516 public int Melting_Point;
1617
17- public RecoveryEntry(AssetLocation ig, uint qty, float dur, int point)
18+ public RecoveryEntry(AssetLocation coll, AssetLocation ingot, uint qty, float dur, int point)
1819 {
19- IngotCode = ig.Clone();
20+ CollectableCode = coll.Clone();
21+ IngotCode = ingot.Clone();
2022 Quantity = qty;
2123 Melting_Duration = dur;
2224 Melting_Point = point;
--- /dev/null
+++ b/AnvilMetalRecovery/Data/RecoveryEntryTable.cs
@@ -0,0 +1,34 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Collections.ObjectModel;
4+
5+using Vintagestory.API.Common;
6+
7+namespace AnvilMetalRecovery
8+{
9+ public class RecoveryEntryTable : KeyedCollection<AssetLocation, RecoveryEntry>
10+ {
11+ protected override AssetLocation GetKeyForItem(RecoveryEntry item) => item.CollectableCode;
12+
13+ public void AddReplace(RecoveryEntry entry)
14+ {
15+ if (Contains(entry.CollectableCode)) { Remove(entry.CollectableCode); }
16+ Add(entry);
17+ }
18+
19+ public ICollection<AssetLocation> Keys
20+ {
21+ get
22+ {
23+ return this.Dictionary.Keys;
24+ }
25+ }
26+
27+ public bool ContainsKey(AssetLocation code)
28+ {
29+ if (this.Dictionary == null || this.Dictionary.Keys == null ) return false;
30+ return this.Dictionary.ContainsKey(code);
31+ }
32+ }
33+}
34+
--- a/AnvilMetalRecovery/Harmony/GenericItemMortalityDetector.cs
+++ b/AnvilMetalRecovery/Harmony/GenericItemMortalityDetector.cs
@@ -74,7 +74,7 @@ namespace AnvilMetalRecovery.Patches
7474 return true;
7575 }
7676
77- Dictionary<AssetLocation, RecoveryEntry> itemToVoxelLookup = ( Dictionary<AssetLocation, RecoveryEntry> )world.Api.ObjectCache[MetalRecoverySystem.itemFilterListCacheKey];
77+ var itemToVoxelLookup = MetalRecoverySystem.GetCachedLookupTable(world);
7878
7979 if (itemToVoxelLookup.ContainsKey(that.Code)) return false;
8080
--- a/AnvilMetalRecovery/MetalRecoverySystem.cs
+++ b/AnvilMetalRecovery/MetalRecoverySystem.cs
@@ -25,7 +25,7 @@ namespace AnvilMetalRecovery
2525 internal IServerNetworkChannel _ConfigDownlink;
2626 internal IClientNetworkChannel _ConfigUplink;
2727
28- private Dictionary<AssetLocation, RecoveryEntry> itemToVoxelLookup = new Dictionary<AssetLocation, RecoveryEntry>();//Ammount & Material?
28+ private RecoveryEntryTable itemToVoxelLookup = new RecoveryEntryTable();//Item Asset Code to: Ammount & Material
2929
3030 private ICoreAPI CoreAPI;
3131 private ICoreServerAPI ServerAPI;
@@ -48,13 +48,16 @@ namespace AnvilMetalRecovery
4848 get { return CoreAPI.ModLoader.GetModSystem<RecipeRegistrySystem>( ).SmithingRecipes; }
4949 }
5050
51+ public static RecoveryEntryTable GetCachedLookupTable(IWorldAccessor world )
52+ {
53+ return ( RecoveryEntryTable )world.Api.ObjectCache[MetalRecoverySystem.itemFilterListCacheKey];
54+ }
5155
52-
53- /// <summary>
54- /// Valid Items that are 'recoverable' (Asset Codes) only
55- /// </summary>
56- /// <value>The item filter list.</value>
57- public List<AssetLocation> ItemFilterList {
56+ /// <summary>
57+ /// Valid Items that are 'recoverable' (Asset Codes) only
58+ /// </summary>
59+ /// <value>The item filter list.</value>
60+ public List<AssetLocation> ItemFilterList {
5861 get
5962 {
6063 return itemToVoxelLookup.Keys.ToList( );
@@ -62,14 +65,18 @@ namespace AnvilMetalRecovery
6265 }
6366
6467 /// <summary>
65- /// ALL Items that have were derivable from smithing recipies (and are tool / durable)
68+ /// ALL Items that have were derivable from smithing recipies (and are 'tool' / have durability property)
6669 /// </summary>/
6770 /// <value>The item filter list.</value>
68- public Dictionary<AssetLocation, RecoveryEntry> ItemRecoveryTable {
71+ public RecoveryEntryTable ItemRecoveryTable {
6972 get
7073 {
7174 return itemToVoxelLookup;
7275 }
76+ set
77+ {
78+ itemToVoxelLookup = value;
79+ }
7380 }
7481
7582 public override bool AllowRuntimeReload {
@@ -126,8 +133,7 @@ namespace AnvilMetalRecovery
126133 #if DEBUG
127134 ServerAPI.RegisterCommand("durability", "edit durability of item", " (Held tool) and #", EditDurability, Privilege.give);
128135 #endif
129-
130-
136+
131137 }
132138
133139 public override void StartClientSide(ICoreClientAPI api)
--- a/AnvilMetalRecovery/MetalRecoverySystem_Components.cs
+++ b/AnvilMetalRecovery/MetalRecoverySystem_Components.cs
@@ -56,7 +56,7 @@ namespace AnvilMetalRecovery
5656 Mod.Logger.Warning($"Duplicate recipie '{recipie.Name}' output item: '{outputItem.Code.ToString()}'");
5757 }
5858 else {
59- itemToVoxelLookup.Add(outputItem.Code.Clone( ), new RecoveryEntry(metalObject.Code,
59+ itemToVoxelLookup.Add(new RecoveryEntry(outputItem.Code, metalObject.Code,
6060 ( uint )(setVoxels / recipie.Output.Quantity),
6161 metalObject.CombustibleProps.MeltingDuration,
6262 metalObject.CombustibleProps.MeltingPoint)
@@ -84,7 +84,7 @@ namespace AnvilMetalRecovery
8484 Mod.Logger.Warning($"Duplicate recipie '{recipie.Name}' output tool-item: '{itemToolCode.ToString( )}'");
8585 }
8686 else
87- itemToVoxelLookup.Add(itemToolCode.Clone( ), new RecoveryEntry(metalObject.Code,
87+ itemToVoxelLookup.Add( new RecoveryEntry(itemToolCode.Clone( ), metalObject.Code,
8888 ( uint )(setVoxels / recipie.Output.Quantity),
8989 metalObject.CombustibleProps.MeltingDuration,
9090 metalObject.CombustibleProps.MeltingPoint)
@@ -99,7 +99,9 @@ namespace AnvilMetalRecovery
9999 }
100100
101101 //Cache list too
102- ServerAPI.ObjectCache.Add(itemFilterListCacheKey, itemToVoxelLookup);
102+ ServerAPI.ObjectCache.Add(itemFilterListCacheKey, itemToVoxelLookup);
103+
104+ Mod.Logger.Event("tallied {0} smithables totaling {1} metal units from {2} smithing recipies!", itemToVoxelLookup.Count, itemToVoxelLookup.Sum(ie => ie.Quantity), this.SmithingRecipies.Count);
103105 }
104106
105107 private bool SmithingRecipieValidator(SmithingRecipe aRecipie )
--- a/AnvilMetalRecovery/modinfo.json
+++ b/AnvilMetalRecovery/modinfo.json
@@ -4,9 +4,9 @@
44 "description" : "Get back lost scrap and smithing discards. Plus more.",
55 "authors": ["Melchior"],
66 "ModID":"metalrecovery",
7- "version": "0.1.16",
7+ "version": "0.1.17",
88 "dependencies": {
9- "game": "1.16.0",
9+ "game": "1.16.4",
1010 "survival": ""
1111 },
1212 "website": "http://nowebsite.nope"