• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythongamewindowsbathyscaphephpguic翻訳omegattwitterframeworktestbtronarduinovb.net計画中(planning stage)directxpreviewerゲームエンジンdom

First Machine Age's Mods (Combined repo.)


Commit MetaInfo

Revisão52139e12ee090af1587f2c36fac9d9ad0b42d28a (tree)
Hora2020-03-25 01:28:00
Autormelchior <melchior@user...>
Commitermelchior

Mensagem de Log

W.I.P. #2: track split state via workitem instead, ect...

Mudança Sumário

Diff

--- a/AnvilMetalRecovery/AnvilMetalRecovery.csproj
+++ b/AnvilMetalRecovery/AnvilMetalRecovery.csproj
@@ -70,6 +70,9 @@
7070 <None Include="assets\fma\shapes\item\shavings\metal_shavings.json">
7171 <CopyToOutputDirectory>Always</CopyToOutputDirectory>
7272 </None>
73+ <None Include="assets\fma\lang\en.json">
74+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
75+ </None>
7376 </ItemGroup>
7477 <ItemGroup>
7578 <Folder Include="assets\" />
@@ -79,6 +82,7 @@
7982 <Folder Include="assets\fma\itemtypes\shavings\" />
8083 <Folder Include="assets\fma\shapes\item\" />
8184 <Folder Include="assets\fma\shapes\item\shavings\" />
85+ <Folder Include="assets\fma\lang\" />
8286 </ItemGroup>
8387 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
8488 </Project>
\ No newline at end of file
--- a/AnvilMetalRecovery/MetalRecovery_BlockEntityAnvil.cs
+++ b/AnvilMetalRecovery/MetalRecovery_BlockEntityAnvil.cs
@@ -11,10 +11,14 @@ namespace AnvilMetalRecovery
1111 {
1212 public class MetalRecovery_BlockEntityAnvil : BlockEntityAnvil
1313 {
14- private uint SplitCount;
14+ private const string splitCountKey = @"splitCount";
1515
16-
17- private ILogger Logger { get; set; }
16+ private ILogger Logger {
17+ get
18+ {
19+ return Api.World.Logger;
20+ }
21+ }
1822
1923 public static AssetLocation MetalShavingsCode {
2024 get
@@ -23,40 +27,23 @@ namespace AnvilMetalRecovery
2327 }
2428 }
2529
26- public override void Initialize(ICoreAPI api)
27- {
28- base.Initialize(api);
29- Logger = api.World.Logger;
30-#if DEBUG
31- Logger.VerboseDebug("Metal Recovery - Initialize");
32-#endif
33- }
34-
35- public override void FromTreeAtributes(ITreeAttribute tree, IWorldAccessor worldForResolving)
36- {
37- base.FromTreeAtributes(tree, worldForResolving);
38- Logger = worldForResolving.Logger;
39-#if DEBUG
40- Logger.VerboseDebug("Metal Recovery - FromTreeAtributes");
41-#endif
42- //Get SplitCount
43- }
4430
45- public override void ToTreeAttributes(ITreeAttribute tree)
31+ internal int SplitCount
4632 {
47- base.ToTreeAttributes(tree);
48-#if DEBUG
49- Logger.VerboseDebug("Metal Recovery - ToTreeAttributes");
50-#endif
51- //Set SplitCount
33+ get {
34+ return this.WorkItemStack?.Attributes.TryGetInt(splitCountKey) ?? 0;
35+ }
36+ set {
37+ this.WorkItemStack?.Attributes.SetInt(splitCountKey, value);
38+ }
5239 }
5340
5441 public override void OnSplit(Vec3i voxelPos)
5542 {
5643 if (Voxels[voxelPos.X, voxelPos.Y, voxelPos.Z] == ( byte )EnumVoxelMaterial.Metal) {
57-#if DEBUG
44+ #if DEBUG
5845 Logger.VerboseDebug("Split some {0} @{1}, Total:{2}", this.BaseMaterial.Collectible.LastCodePart( ), voxelPos, SplitCount);
59-#endif
46+ #endif
6047 SplitCount++;
6148 }
6249
@@ -67,6 +54,7 @@ namespace AnvilMetalRecovery
6754 //Would be great if this returned a bool!
6855 public override void CheckIfFinished(IPlayer byPlayer)
6956 {
57+ int splitTemp = SplitCount;
7058 base.CheckIfFinished(byPlayer);
7159 // base.MatchesRecipe( ) -- Private; argh
7260 /*
@@ -77,8 +65,8 @@ namespace AnvilMetalRecovery
7765 base.MarkDirty (false);
7866 */
7967
80- if (SplitCount > 0 && this.WorkItemStack == null && this.SelectedRecipe == null) {
81- int metalShavings = ( int )(SplitCount / 5);
68+ if (splitTemp > 0 && this.WorkItemStack == null && this.SelectedRecipe == null) {
69+ int metalShavings = ( int )(splitTemp / 5);
8270
8371 if (metalShavings > 0)
8472 {
@@ -87,7 +75,7 @@ namespace AnvilMetalRecovery
8775 #endif
8876
8977 Item metalShavingsItem = Api.World.GetItem(MetalShavingsCode.WithPathAppendix("-" + this.BaseMaterial.Collectible.LastCodePart( )));
90- ItemStack metalShavingsStack = new ItemStack(metalShavingsItem, ( int )(SplitCount / 5));
78+ ItemStack metalShavingsStack = new ItemStack(metalShavingsItem, metalShavings);
9179
9280 if (byPlayer != null) {
9381 byPlayer.InventoryManager.TryGiveItemstack(metalShavingsStack, false);
--- /dev/null
+++ b/AnvilMetalRecovery/assets/fma/lang/en.json
@@ -0,0 +1,4 @@
1+{
2+ "itemdesc-metal_shaving-*": "Various small bits of metal. Looks re-smeltable.",
3+ "item-metal_shaving-*":"Metal Shavings",
4+}
\ No newline at end of file
--- a/AnvilMetalRecovery/modinfo.json
+++ b/AnvilMetalRecovery/modinfo.json
@@ -3,7 +3,7 @@
33 "name": "Anvil Metal Recovery",
44 "description" : "Get back that lost scrap and smithing discards!",
55 "authors": ["Melchior"],
6- "version": "0.1.0",
6+ "version": "0.1.1",
77 "dependencies": {
88 "game": "1.12.11",
99 "survival": ""