First Machine Age's Mods (Combined repo.)
修訂 | b46e1569559926fa4b091f9baa49663a627914b8 (tree) |
---|---|
時間 | 2023-05-07 04:08:52 |
作者 | melchior <melchior@user...> |
Commiter | melchior |
Updates for 1.18 W.I.P. Set I
@@ -88,6 +88,7 @@ | ||
88 | 88 | <Compile Include="Data\RecoveryEntryTable.cs" /> |
89 | 89 | <Compile Include="BlockBehaviors\MoldDestructionRecovererBehavior.cs" /> |
90 | 90 | <Compile Include="Harmony\WateringCanDaptor.cs" /> |
91 | + <Compile Include="Data\MetalInfo.cs" /> | |
91 | 92 | </ItemGroup> |
92 | 93 | <ItemGroup> |
93 | 94 | <None Include="modinfo.json"> |
@@ -130,6 +131,8 @@ | ||
130 | 131 | <None Include="assets\fma\patches\wateringcan_behavior.json"> |
131 | 132 | </None> |
132 | 133 | <None Include="Blocks\BlockWateringCanPlus.cs" /> |
134 | + <None Include="assets\fma\patches\old_item_remapping.json"> | |
135 | + </None> | |
133 | 136 | </ItemGroup> |
134 | 137 | <ItemGroup> |
135 | 138 | <Folder Include="assets\" /> |
@@ -77,7 +77,7 @@ namespace AnvilMetalRecovery | ||
77 | 77 | |
78 | 78 | internal void SpawnMetalBits(IWorldAccessor world, BlockPos pos, int unitQuantity, string baseMetalCode) |
79 | 79 | { |
80 | - if (unitQuantity > 0) | |
80 | + if (unitQuantity > 0 && pos != null && !string.IsNullOrEmpty(baseMetalCode)) | |
81 | 81 | { |
82 | 82 | int shavingQty = unitQuantity / shavingValue; |
83 | 83 | Item metalShavingsItem = world.Api.World.GetItem(MetalBits_partial.AppendPathVariant(baseMetalCode)); |
@@ -14,14 +14,14 @@ namespace AnvilMetalRecovery | ||
14 | 14 | { |
15 | 15 | ToolFragmentRecovery = true; |
16 | 16 | VoxelEquivalentValue = MetalRecoverySystem.IngotVoxelDefault; |
17 | - ToolRecoveryRate = 0.95f; | |
17 | + ToolRecoveryRate = 0.85f; | |
18 | 18 | } |
19 | 19 | |
20 | 20 | public AMRConfig(bool setDefaultBL) |
21 | 21 | { |
22 | 22 | ToolFragmentRecovery = true; |
23 | 23 | VoxelEquivalentValue = MetalRecoverySystem.IngotVoxelDefault; |
24 | - ToolRecoveryRate = 0.95f; | |
24 | + ToolRecoveryRate = 0.85f; | |
25 | 25 | if (setDefaultBL) { |
26 | 26 | BlackList = new List<AssetLocation> { |
27 | 27 | new AssetLocation(@"game:metalplate"), |
@@ -0,0 +1,41 @@ | ||
1 | +using System; | |
2 | +using System.ComponentModel; | |
3 | + | |
4 | +using Newtonsoft.Json; | |
5 | + | |
6 | +namespace AnvilMetalRecovery | |
7 | +{ | |
8 | + //Too outdated for...: [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] | |
9 | + [JsonObject(MemberSerialization.OptIn)] | |
10 | + public struct MetalInfo | |
11 | + { | |
12 | + [JsonProperty("code", Required = Required.Always)] | |
13 | + public readonly string Code; | |
14 | + | |
15 | + [JsonProperty("meltPoint")] | |
16 | + [DefaultValue(1000f)] | |
17 | + public readonly float MeltingPoint; | |
18 | + | |
19 | + [JsonProperty("boilPoint")] | |
20 | + [DefaultValue(100f)] | |
21 | + public readonly float BoilingPoint; | |
22 | + | |
23 | + [JsonIgnore] | |
24 | + [DefaultValue(30)] | |
25 | + public int MeltingDuration; | |
26 | + | |
27 | + [JsonProperty("density")] | |
28 | + [DefaultValue(10000f)] | |
29 | + public readonly float Density; | |
30 | + | |
31 | + [JsonProperty("specificHeatCapacity")] | |
32 | + [DefaultValue(1f)] | |
33 | + public readonly float SpecificHeatCapacity; | |
34 | + | |
35 | + [JsonProperty("elemental")] | |
36 | + public readonly bool Elemental; | |
37 | + | |
38 | + [JsonProperty("tier")] | |
39 | + public readonly int Tier; | |
40 | + } | |
41 | +} | |
\ No newline at end of file |
@@ -1,27 +1,69 @@ | ||
1 | 1 | using System; |
2 | +using System.Collections; | |
3 | +using System.Collections.Generic; | |
4 | +using System.Linq; | |
2 | 5 | |
3 | 6 | using Vintagestory.API.Common; |
4 | 7 | |
5 | 8 | namespace AnvilMetalRecovery |
6 | 9 | { |
7 | - public struct RecoveryEntry | |
10 | + public class RecoveryEntry | |
8 | 11 | { |
9 | 12 | public readonly AssetLocation CollectableCode; |
10 | - public AssetLocation IngotCode; | |
13 | + public Dictionary<AssetLocation, uint> MaterialComposition;//e.g. 50x Ingot-Copper, 10x Ingot-Zinc... | |
14 | + | |
15 | + public AssetLocation PrimaryMaterial | |
16 | + { | |
17 | + get { | |
18 | + return MaterialComposition.First().Key; | |
19 | + } | |
20 | + } | |
21 | + | |
22 | + public uint FirstQuantity { | |
23 | + get | |
24 | + { | |
25 | + return MaterialComposition.First( ).Value; | |
26 | + } | |
27 | + } | |
28 | + | |
29 | + public uint TotalQuantity | |
30 | + { | |
31 | + get | |
32 | + { | |
33 | + return ( uint )MaterialComposition.Sum(mt => mt.Value); | |
34 | + } | |
35 | + } | |
36 | + | |
37 | + public bool MultiComponent | |
38 | + { | |
39 | + get | |
40 | + { | |
41 | + return MaterialComposition.Count > 1; | |
42 | + } | |
43 | + } | |
44 | + | |
11 | 45 | /// <summary> |
12 | - /// Metal Quantity (VOXELS) | |
46 | + /// Initializes a singluar entry recovery entry for 1:1 items | |
13 | 47 | /// </summary> |
14 | - public uint Quantity; | |
15 | - public float Melting_Duration;//TODO: Replace with 1.17 MetalAlloy mappings | |
16 | - public int Melting_Point;//TODO: Replace with 1.17 MetalAlloy mappings | |
17 | - | |
18 | - public RecoveryEntry(AssetLocation coll, AssetLocation ingot, uint qty, float dur, int point) | |
48 | + /// <param name="coll">Coll.</param> | |
49 | + /// <param name="ingot">Ingot.</param> | |
50 | + /// <param name="qty">Qty.</param> | |
51 | + public RecoveryEntry(AssetLocation coll, AssetLocation ingot, uint qty) | |
19 | 52 | { |
20 | 53 | CollectableCode = coll.Clone(); |
21 | - IngotCode = ingot.Clone(); | |
22 | - Quantity = qty; | |
23 | - Melting_Duration = dur; | |
24 | - Melting_Point = point; | |
54 | + MaterialComposition = new Dictionary<AssetLocation, uint>( ); | |
55 | + MaterialComposition.Add(ingot, qty); | |
56 | + } | |
57 | + | |
58 | + /// <summary> | |
59 | + /// Initializes a singluar entry recovery entry for 1:2 items | |
60 | + /// </summary> | |
61 | + public RecoveryEntry(AssetLocation coll, AssetLocation ingotA, uint qtyA,AssetLocation ingotB, uint qtyB) | |
62 | + { | |
63 | + CollectableCode = coll.Clone( ); | |
64 | + MaterialComposition = new Dictionary<AssetLocation, uint>( ); | |
65 | + MaterialComposition.Add(ingotA, qtyA); | |
66 | + MaterialComposition.Add(ingotB, qtyB); | |
25 | 67 | } |
26 | 68 | } |
27 | 69 | } |
@@ -91,6 +91,8 @@ namespace AnvilMetalRecovery.Patches | ||
91 | 91 | if (anvil.BaseMaterial != null && anvil.SplitCount > 0) |
92 | 92 | { |
93 | 93 | dsc.AppendFormat("[ {0} ] : {1} × {2}\n", anvil.SplitCount, Lang.GetUnformatted($"game:item-metalbit-{anvil.BaseMetal}"), anvil.ShavingQuantity); |
94 | + } else if (anvil.IsShavable == false) { | |
95 | + dsc.AppendLine( Lang.GetUnformatted($"fma:cant_recover")); | |
94 | 96 | } |
95 | 97 | } |
96 | 98 |
@@ -317,13 +319,13 @@ namespace AnvilMetalRecovery.Patches | ||
317 | 319 | if (itemToVoxelLookup.ContainsKey(bea.SelectedRecipe.Output.Code)) { |
318 | 320 | var result = itemToVoxelLookup[bea.SelectedRecipe.Output.Code]; |
319 | 321 | #if DEBUG |
320 | - Logger.VerboseDebug("(old) Selected Recipe: {0} base-material: '{1}' worth {2} units; spawning", bea.SelectedRecipe.Output.Code, result.IngotCode, result.Quantity); | |
322 | + Logger.VerboseDebug("(old) Selected Recipe: {0} base-material: '{1}' worth {2} units; spawning", bea.SelectedRecipe.Output.Code, result.PrimaryMaterial, result.TotalQuantity); | |
321 | 323 | #endif |
322 | 324 | |
323 | - int shavingQty = ( int )(result.Quantity / MetalRecoverySystem.IngotVoxelDefault); | |
325 | + int shavingQty = ( int )(result.TotalQuantity / MetalRecoverySystem.IngotVoxelDefault); | |
324 | 326 | |
325 | 327 | if (shavingQty > 0) { |
326 | - Item metalShavingsItem = World.GetItem(MetalShavingsCode.AppendPathVariant(result.IngotCode.PathEnding())); | |
328 | + Item metalShavingsItem = World.GetItem(MetalShavingsCode.AppendPathVariant(result.PrimaryMaterial.PathEnding())); | |
327 | 329 | |
328 | 330 | if (metalShavingsItem != null) { |
329 | 331 | ItemStack metalShavingsStack = new ItemStack(metalShavingsItem, shavingQty); |
@@ -14,6 +14,7 @@ namespace AnvilMetalRecovery | ||
14 | 14 | public class VariableMetalItem : Item |
15 | 15 | { |
16 | 16 | private const string default_IngotCode = @"game:ingot-copper"; |
17 | + private const string default_MetalbitCode = @"metalbit-"; | |
17 | 18 | private const string metalQuantityKey = @"metalQuantity"; |
18 | 19 | private const string metalIngotCodeKey = @"metalIngotCode"; |
19 | 20 |
@@ -91,47 +92,43 @@ namespace AnvilMetalRecovery | ||
91 | 92 | var metalQuantity = ( int )Math.Floor(MetalQuantity(inSlot.Itemstack) * AnvilMetalRecoveryMod.CachedConfiguration.VoxelEquivalentValue); |
92 | 93 | var props = RegenerateCombustablePropsFromStack(inSlot.Itemstack); |
93 | 94 | |
95 | + base.GetHeldItemInfo(inSlot, dsc, world, withDebugInfo); | |
96 | + | |
94 | 97 | dsc.AppendLine(Lang.Get("fma:itemdesc-item-metal_fragments")); |
95 | 98 | dsc.AppendLine(Lang.Get("fma:metal_worth", metalQuantity, metalName)); |
96 | 99 | } |
97 | 100 | |
98 | - | |
99 | - //TODO: Merge - to the New metal V.S. stock metal bits...? | |
100 | - //TryMergeStacks ??? | |
101 | - //virtual bool CanBePlacedInto(ItemStack stack, ItemSlot slot) //? | |
102 | - //virtual void OnModifiedInInventorySlot //Only for new-Inserts (?) | |
103 | - | |
104 | 101 | public void ApplyMetalProperties(RecoveryEntry recoveryData, ref ItemStack contStack, float percentAdjust = 1.0f) |
105 | 102 | { |
106 | - contStack.Attributes.SetInt(metalQuantityKey, ( int )(recoveryData.Quantity * percentAdjust)); | |
107 | - contStack.Attributes.SetString(metalIngotCodeKey, recoveryData.IngotCode.ToString( )); | |
103 | + contStack.Attributes.SetInt(metalQuantityKey, ( int )(recoveryData.TotalQuantity * percentAdjust)); | |
104 | + contStack.Attributes.SetString(metalIngotCodeKey, recoveryData.PrimaryMaterial.ToString( )); | |
108 | 105 | |
109 | 106 | RegenerateCombustablePropsFromStack(contStack); |
110 | 107 | } |
111 | 108 | |
109 | + //Why is this actually done...? whole item isn't smeltable now... | |
112 | 110 | protected CombustibleProperties RegenerateCombustablePropsFromStack(ItemStack contStack) |
113 | 111 | { |
114 | 112 | if (contStack == null ) return null; |
115 | 113 | //if (contStack.Class == EnumItemClass.Item && contStack.Item.CombustibleProps != null) return contStack.Item.CombustibleProps; |
116 | 114 | |
117 | - var metalCode = MetalIngotCode(contStack); | |
115 | + var metalAssetCode = MetalIngotCode(contStack); | |
118 | 116 | var metalUnits = MetalQuantity(contStack); |
119 | 117 | |
120 | - if (metalCode != null || metalUnits > 0) | |
118 | + if (metalAssetCode != null && metalUnits > 0) | |
119 | + if (MetalRecoverySystem.MetalProperties.ContainsKey(metalAssetCode.PathEnding())) | |
121 | 120 | { |
122 | - var sourceMetalItem = api.World.GetItem(metalCode); | |
121 | + var sourceInfo = MetalRecoverySystem.MetalProperties[metalAssetCode.PathEnding( )];//Mabey more...rustic lookup? | |
123 | 122 | |
124 | - if (sourceMetalItem == null || sourceMetalItem.IsMissing || sourceMetalItem.CombustibleProps == null) return null; | |
125 | - | |
126 | 123 | var aCombustibleProps = new CombustibleProperties( ) { |
127 | 124 | SmeltingType = EnumSmeltType.Smelt, |
128 | - MeltingPoint = sourceMetalItem.CombustibleProps.MeltingPoint, | |
129 | - MeltingDuration = sourceMetalItem.CombustibleProps.MeltingDuration, | |
130 | - HeatResistance = sourceMetalItem.CombustibleProps.HeatResistance, | |
131 | - MaxTemperature = sourceMetalItem.CombustibleProps.MaxTemperature, | |
132 | - SmokeLevel = sourceMetalItem.CombustibleProps.SmokeLevel, | |
125 | + MeltingPoint = ( int )sourceInfo.MeltingPoint, | |
126 | + MeltingDuration = sourceInfo.MeltingDuration, | |
127 | + //HeatResistance = 500, //sourceInfo.SpecificHeatCapacity & Formula...? | |
128 | + MaxTemperature = ( int )sourceInfo.BoilingPoint, | |
129 | + //SmokeLevel = sourceInfo.SmokeLevel, | |
133 | 130 | SmeltedRatio = 100, |
134 | - SmeltedStack = new JsonItemStack( ) { Type = EnumItemClass.Item, Code = sourceMetalItem.Code.Clone( ), Quantity = (int)Math.Floor(metalUnits * AnvilMetalRecoveryMod.CachedConfiguration.VoxelEquivalentValue) } | |
131 | + SmeltedStack = new JsonItemStack( ) { Type = EnumItemClass.Item, Code = metalAssetCode.Clone( ), Quantity = (int)Math.Floor(metalUnits * AnvilMetalRecoveryMod.CachedConfiguration.VoxelEquivalentValue) } | |
135 | 132 | }; |
136 | 133 | aCombustibleProps.SmeltedStack.Resolve(api.World, "VariableMetalItem_regen", true); |
137 | 134 |
@@ -168,7 +165,9 @@ namespace AnvilMetalRecovery | ||
168 | 165 | var metalCode = MetalCode(inputStack); |
169 | 166 | var metalUnits = MetalQuantity(inputStack); |
170 | 167 | |
171 | - Item metalBits = api.World.GetItem(new AssetLocation(GlobalConstants.DefaultDomain, @"metalbit-" + metalCode)); | |
168 | + //TODO: Smarter lookup here - allow for 3rd party metals | |
169 | + Item metalBits = api.World.GetItem(new AssetLocation(GlobalConstants.DefaultDomain, default_MetalbitCode + metalCode)); | |
170 | + //This whole scenario can't work for multi-material items...spawn remainder of items in grid, or on craft? | |
172 | 171 | if (metalBits != null) |
173 | 172 | { |
174 | 173 | gridRecipe.Output.Quantity = ( int )(Math.Round(metalUnits * AnvilMetalRecoveryMod.CachedConfiguration.VoxelEquivalentValue) / 5); |
@@ -15,8 +15,9 @@ using Vintagestory.Server; | ||
15 | 15 | |
16 | 16 | /* IDEAS / ISSUES |
17 | 17 | * # DONE: Watering Can (molten-metal state) Ingot Cooling *Tssss* |
18 | - * # WIP : Ingot breaks -> Metal fragments / bits (or a blob?) | |
18 | + * # WIP : Mold breaks -> Metal fragments : bits... | |
19 | 19 | * # DONE: Tool-break configurable ratio |
20 | + * # IDEA: Recycling Bench block/tool | |
20 | 21 | */ |
21 | 22 | namespace AnvilMetalRecovery |
22 | 23 | { |
@@ -36,7 +37,8 @@ namespace AnvilMetalRecovery | ||
36 | 37 | |
37 | 38 | public event Action AMR_DataReady; |
38 | 39 | |
39 | - private RecoveryEntryTable itemToVoxelLookup = new RecoveryEntryTable();//Item Asset Code to: Ammount & Material | |
40 | + protected RecoveryEntryTable itemToVoxelLookup = new RecoveryEntryTable();//Item Asset Code to: Ammount & Material | |
41 | + public static Dictionary<string, MetalInfo> MetalProperties;//for easy lookup | |
40 | 42 | |
41 | 43 | private ICoreAPI CoreAPI; |
42 | 44 |
@@ -115,7 +117,7 @@ namespace AnvilMetalRecovery | ||
115 | 117 | if (api.Side.IsServer()) |
116 | 118 | { |
117 | 119 | if (api is ServerCoreAPI) { |
118 | - ServerCore = api as ServerCoreAPI; | |
120 | + ServerCore = api as ServerCoreAPI; | |
119 | 121 | } |
120 | 122 | } |
121 | 123 | else |
@@ -138,7 +140,8 @@ namespace AnvilMetalRecovery | ||
138 | 140 | PrepareDownlinkChannel( ); |
139 | 141 | ServerCore.Event.PlayerJoin += SendClientConfigMessage; |
140 | 142 | ServerCore.Event.ServerRunPhase(EnumServerRunPhase.Shutdown, PersistServersideConfig); |
141 | - ServerCore.Event.ServerRunPhase(EnumServerRunPhase.GameReady, MaterialDataGathering); | |
143 | + ServerCore.Event.ServerRunPhase(EnumServerRunPhase.GameReady, UnravelMetalProperties); | |
144 | + ServerCore.Event.ServerRunPhase(EnumServerRunPhase.GameReady, MaterialDataGathering); | |
142 | 145 | ServerCore.Event.ServerRunPhase(EnumServerRunPhase.RunGame, CacheRecoveryDataTable); |
143 | 146 | |
144 | 147 | SetupGeneralObservers( ); |
@@ -172,9 +175,11 @@ namespace AnvilMetalRecovery | ||
172 | 175 | public override void AssetsFinalize(ICoreAPI api) |
173 | 176 | { |
174 | 177 | Mod.Logger.VerboseDebug("AssetsFinalize"); |
175 | - | |
176 | - //PerformBlockClassSwaps( ); | |
177 | - AttachExtraBlockBehaviors( ); | |
178 | + | |
179 | + if (api.Side.IsServer()) | |
180 | + { | |
181 | + AttachExtraBlockBehaviors( ); | |
182 | + } | |
178 | 183 | } |
179 | 184 | |
180 | 185 | private void RegisterItemClassMappings( ) |
@@ -192,24 +197,7 @@ namespace AnvilMetalRecovery | ||
192 | 197 | this.CoreAPI.RegisterCollectibleBehaviorClass(MoldDestructionRecovererBehavior.BehaviorClassName, typeof(MoldDestructionRecovererBehavior)); |
193 | 198 | } |
194 | 199 | |
195 | - /* | |
196 | - private void PerformBlockClassSwaps() | |
197 | - { | |
198 | - #if DEBUG | |
199 | - Mod.Logger.Debug("PerformBlockClassSwaps"); | |
200 | - #endif | |
201 | - | |
202 | - if (ServerCore.World is ServerMain) { | |
203 | - var serverMain = ServerCore.World as ServerMain; | |
204 | - var wateringCanBlock = serverMain.GetBlock(BlockWateringCanPlus.TargetCode); | |
205 | - #if DEBUG | |
206 | - Mod.Logger.VerboseDebug("Change class from {0} to {1}", wateringCanBlock.Class, BlockWateringCanPlus.BlockClassName); | |
207 | - #endif | |
208 | - wateringCanBlock.Class = BlockWateringCanPlus.BlockClassName; | |
209 | - ServerCore.World.Blocks[wateringCanBlock.BlockId] = wateringCanBlock;//Mabey redundant? | |
210 | - } | |
211 | 200 | |
212 | - }*/ | |
213 | 201 | |
214 | 202 | private void AttachExtraBlockBehaviors() |
215 | 203 | { |
@@ -1,6 +1,8 @@ | ||
1 | 1 | using System; |
2 | +using System.Collections.Generic; | |
2 | 3 | using System.Linq; |
3 | 4 | |
5 | +using Newtonsoft.Json.Linq; | |
4 | 6 | |
5 | 7 | using Vintagestory.API.Common; |
6 | 8 | using Vintagestory.API.Config; |
@@ -16,9 +18,37 @@ namespace AnvilMetalRecovery | ||
16 | 18 | { |
17 | 19 | public partial class MetalRecoverySystem : ModSystem |
18 | 20 | { |
21 | + private void UnravelMetalProperties( ) | |
22 | + { | |
23 | + MetalProperties = new Dictionary<string, MetalInfo>( ); | |
24 | + var metalAsset = ServerCore.Assets.TryGet("game:worldproperties/block/metal.json",true); | |
25 | + JObject originalJson = JObject.Parse(metalAsset.ToText()); | |
26 | + var variants = originalJson.SelectToken(@"variants").Children( ).ToList( ); | |
27 | + | |
28 | + foreach (var variant in variants) | |
29 | + { | |
30 | + var metalI = variant.ToObject<MetalInfo>(); | |
31 | + | |
32 | + if (!MetalProperties.ContainsKey(metalI.Code)) MetalProperties.Add(metalI.Code, metalI); | |
33 | + | |
34 | + #if DEBUG | |
35 | + Mod.Logger.Debug($"parsed '{metalI.Code}' T:{metalI.Tier}, {(metalI.Elemental ?"Element":"Alloy")} Melt:{metalI.MeltingPoint}℃"); | |
36 | + #endif | |
37 | + } | |
38 | + | |
39 | + | |
40 | + } | |
41 | + | |
42 | + /// <summary> | |
43 | + /// Materials the data gathering. | |
44 | + /// </summary> | |
45 | + /// <remarks> | |
46 | + /// Sum, tally Voxels in smthing recipes for all 'metal'-ingot derived items | |
47 | + /// </remarks> | |
48 | + /// <returns>The data gathering.</returns> | |
19 | 49 | private void MaterialDataGathering( ) |
20 | 50 | { |
21 | - //Count out Voxels in smthing recipes for all metal-ingot(?) derived items; | |
51 | + //TODO: FIX 3rd-PARTY MOD COMPATIBILITY !!! | |
22 | 52 | var examineList = this.SmithingRecipies.Where(sr => sr.Enabled && sr.Ingredient.Type == EnumItemClass.Item && sr.Output.Type == EnumItemClass.Item); |
23 | 53 | |
24 | 54 | foreach (var recipie in examineList) { |
@@ -43,7 +73,8 @@ namespace AnvilMetalRecovery | ||
43 | 73 | if (metalObject != null && metalObject.CombustibleProps != null && metalObject.CombustibleProps.SmeltingType == EnumSmeltType.Smelt && metalObject.CombustibleProps.SmeltedRatio > 0) { |
44 | 74 | //Item Input Has a metal Unit value...(Smeltable) |
45 | 75 | //Resolve? |
46 | - int setVoxels = 0; | |
76 | + int setVoxels = 0, meltPoint = 0; | |
77 | + float meltDur = 0; | |
47 | 78 | setVoxels = recipie.Voxels.OfType<bool>( ).Count(vox => vox); |
48 | 79 | |
49 | 80 | #if DEBUG |
@@ -56,16 +87,13 @@ namespace AnvilMetalRecovery | ||
56 | 87 | Mod.Logger.Warning($"Duplicate recipie '{recipie.Name}' output item: '{outputItem.Code.ToString()}'"); |
57 | 88 | } |
58 | 89 | else { |
59 | - itemToVoxelLookup.Add(new RecoveryEntry(outputItem.Code, metalObject.Code, | |
60 | - ( uint )(setVoxels / recipie.Output.Quantity), | |
61 | - metalObject.CombustibleProps.MeltingDuration, | |
62 | - metalObject.CombustibleProps.MeltingPoint) | |
63 | - ); | |
90 | + LookupMetalCode(metalObject.Code, out meltDur, out meltPoint); | |
91 | + | |
92 | + itemToVoxelLookup.Add(new RecoveryEntry(outputItem.Code, metalObject.Code, ( uint )(setVoxels / recipie.Output.Quantity))); | |
64 | 93 | #if DEBUG |
65 | 94 | Mod.Logger.VerboseDebug($"Mapped: ('tool') '{outputItem.Code}' -> ('tool') '{outputItem.Code}'"); |
66 | 95 | #endif |
67 | - } | |
68 | - | |
96 | + } | |
69 | 97 | } |
70 | 98 | else { |
71 | 99 | //Tool-head map to Tool item; decode |
@@ -83,12 +111,10 @@ namespace AnvilMetalRecovery | ||
83 | 111 | if (itemToVoxelLookup.ContainsKey(itemToolCode)) { |
84 | 112 | Mod.Logger.Warning($"Duplicate recipie '{recipie.Name}' output tool-item: '{itemToolCode.ToString( )}'"); |
85 | 113 | } |
86 | - else | |
87 | - itemToVoxelLookup.Add( new RecoveryEntry(itemToolCode.Clone( ), metalObject.Code, | |
88 | - ( uint )(setVoxels / recipie.Output.Quantity), | |
89 | - metalObject.CombustibleProps.MeltingDuration, | |
90 | - metalObject.CombustibleProps.MeltingPoint) | |
91 | - ); | |
114 | + else { | |
115 | + LookupMetalCode(metalObject.Code, out meltDur, out meltPoint); | |
116 | + itemToVoxelLookup.Add(new RecoveryEntry(itemToolCode.Clone( ), metalObject.Code, ( uint )(setVoxels / recipie.Output.Quantity))); | |
117 | + } | |
92 | 118 | #if DEBUG |
93 | 119 | Mod.Logger.VerboseDebug($"Mapped: (head) '{outputItem.Code}' -> (tool) '{itemToolCode}'"); |
94 | 120 | #endif |
@@ -98,7 +124,7 @@ namespace AnvilMetalRecovery | ||
98 | 124 | } |
99 | 125 | } |
100 | 126 | |
101 | - Mod.Logger.Event("tallied {0} smithables totaling {1} metal units from {2} smithing recipies!", itemToVoxelLookup.Count, itemToVoxelLookup.Sum(ie => ie.Quantity), this.SmithingRecipies.Count); | |
127 | + Mod.Logger.Event("tallied {0} smithables totaling {1} metal units from {2} smithing recipies!", itemToVoxelLookup.Count, itemToVoxelLookup.Sum(ie => ie.TotalQuantity), this.SmithingRecipies.Count); | |
102 | 128 | } |
103 | 129 | |
104 | 130 | private bool SmithingRecipieValidator(SmithingRecipe aRecipie ) |
@@ -127,7 +153,7 @@ namespace AnvilMetalRecovery | ||
127 | 153 | |
128 | 154 | RecoveryEntry rec = itemToVoxelLookup[hotbarData.ItemCode]; |
129 | 155 | #if DEBUG |
130 | - Mod.Logger.VerboseDebug("broken-item {0} abs. WORTH: {1:F1}*{2} units", hotbarData.ItemCode.ToString( ), (rec.Quantity * CachedConfiguration.VoxelEquivalentValue), rec.IngotCode.ToShortString( )); | |
156 | + Mod.Logger.VerboseDebug("broken-item {0} abs. WORTH: {1:F1}*{2} units", hotbarData.ItemCode.ToString( ), (rec.TotalQuantity * CachedConfiguration.VoxelEquivalentValue), rec.PrimaryMaterial.ToShortString( )); | |
131 | 157 | #endif |
132 | 158 | |
133 | 159 | if (String.IsNullOrEmpty(hotbarData.PlayerUID) || String.IsNullOrEmpty(hotbarData.InventoryID)) return; |
@@ -223,6 +249,19 @@ namespace AnvilMetalRecovery | ||
223 | 249 | } |
224 | 250 | |
225 | 251 | } |
252 | + | |
253 | + private bool LookupMetalCode(AssetLocation metalAssetCode, out float melting_duration, out int melting_point) | |
254 | + { | |
255 | + melting_duration = 30f;//same for ALL metals? | |
256 | + melting_point = 0; | |
257 | + string metalName = metalAssetCode.PathEnding();//Better be an Ingot! | |
258 | + if (MetalProperties.ContainsKey(metalName)) { | |
259 | + melting_point = ( int )MetalProperties[metalName].MeltingPoint; | |
260 | + return true; | |
261 | + } | |
262 | + | |
263 | + return false; | |
264 | + } | |
226 | 265 | } |
227 | 266 | } |
228 | 267 |
@@ -8,6 +8,7 @@ | ||
8 | 8 | } |
9 | 9 | }, |
10 | 10 | storageFlags: 5, |
11 | + dimensions: { width: 0.26, height: 0.26, length: 0.26 }, | |
11 | 12 | shape: { base: "fma:item/metal/fragments" }, |
12 | 13 | textures: { |
13 | 14 | "metal": { base: "game:block/metal/plate/gold" }, |
@@ -27,4 +27,5 @@ | ||
27 | 27 | "fma:itemdesc-item-metal_fragments": "Try, chopping it apart with a Chisel...", |
28 | 28 | "fma:metal_worth":"Worth {0} units of {1}.", |
29 | 29 | "fma:spray_cooler_text":"\n...mabey it can cool off hot things, too?", |
30 | + "fma:cant_recover":"<font color=\"red\">This work isn't recoverable.</font>", | |
30 | 31 | } |
\ No newline at end of file |
@@ -0,0 +1,34 @@ | ||
1 | +[ | |
2 | +{ | |
3 | + "file": "game:config/remaps.json", | |
4 | + "op": "add", | |
5 | + "side": "server", | |
6 | + "path": "/fma:v0.1.18-rc.3", | |
7 | + "value": [ | |
8 | + "/iir map fma:metal_shaving-copper game:metalbit-copper", | |
9 | + "/iir map fma:metal_shaving-bismuth game:metalbit-bismuth ", | |
10 | + "/iir map fma:metal_shaving-bismuthbronze game:metalbit-bismuthbronze ", | |
11 | + "/iir map fma:metal_shaving-blackbronze game:metalbit-blackbronze ", | |
12 | + "/iir map fma:metal_shaving-brass game:metalbit-brass ", | |
13 | + "/iir map fma:metal_shaving-chromium game:metalbit-chromium ", | |
14 | + "/iir map fma:metal_shaving-gold game:metalbit-gold ", | |
15 | + "/iir map fma:metal_shaving-iron game:metalbit-iron ", | |
16 | + "/iir map fma:metal_shaving-meteoriciron game:metalbit-meteoriciron ", | |
17 | + "/iir map fma:metal_shaving-lead game:metalbit-lead ", | |
18 | + "/iir map fma:metal_shaving-molybdochalkos game:metalbit-molybdochalkos ", | |
19 | + "/iir map fma:metal_shaving-platinum game:metalbit-platinum ", | |
20 | + "/iir map fma:metal_shaving-rhodium game:metalbit-rhodium ", | |
21 | + "/iir map fma:metal_shaving-silver game:metalbit-silver ", | |
22 | + "/iir map fma:metal_shaving-stainlesssteel game:metalbit-stainlesssteel ", | |
23 | + "/iir map fma:metal_shaving-steel game:metalbit-steel ", | |
24 | + "/iir map fma:metal_shaving-tin game:metalbit-tin ", | |
25 | + "/iir map fma:metal_shaving-tinbronze game:metalbit-tinbronze ", | |
26 | + "/iir map fma:metal_shaving-titanium game:metalbit-titanium ", | |
27 | + "/iir map fma:metal_shaving-uranium game:metalbit-uranium ", | |
28 | + "/iir map fma:metal_shaving-zinc game:metalbit-zinc ", | |
29 | + "/iir map fma:metal_shaving-blistersteel game:metalbit-blistersteel ", | |
30 | + "/iir map fma:metal_shaving-leadsolder game:metalbit-leadsolder ", | |
31 | + "/iir map fma:metal_shaving-silversolder game:metalbit-silversolder " | |
32 | + ] | |
33 | +} | |
34 | +] | |
\ No newline at end of file |
@@ -4,9 +4,9 @@ | ||
4 | 4 | "description" : "Get back smithing discards, broken tool scrap, failed molds; and MORE!", |
5 | 5 | "authors": ["Melchior"], |
6 | 6 | "ModID":"metalrecovery", |
7 | - "version": "0.1.18-rc.8", | |
7 | + "version": "0.1.19-pre.0", | |
8 | 8 | "dependencies": { |
9 | - "game": "1.17.0-rc.0", | |
9 | + "game": "1.18.0", | |
10 | 10 | "survival": "" |
11 | 11 | }, |
12 | 12 | "website": "http://nowebsite.nope" |