• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

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

Revisãob3c470593faa82cac96cd917eb426cc129c4430d (tree)
Hora2022-08-13 08:56:12
Autormelchior <melchior@user...>
Commitermelchior

Mensagem de Log

Mold/Ingot recovery A-OK

Also, steam particles as intended

Mudança Sumário

Diff

--- a/AnvilMetalRecovery/BlockBehaviors/MoldDestructionRecovererBehavior.cs
+++ b/AnvilMetalRecovery/BlockBehaviors/MoldDestructionRecovererBehavior.cs
@@ -14,6 +14,10 @@ namespace AnvilMetalRecovery
1414 public class MoldDestructionRecovererBehavior : BlockBehavior
1515 {
1616 public static readonly string BehaviorClassName = @"MoldDestructionRecoverer";
17+ private readonly AssetLocation MetalBits_partial = new AssetLocation(GlobalConstants.DefaultDomain, @"metalbit");
18+ private const int shavingValue = 5;
19+
20+
1721
1822 public MoldDestructionRecovererBehavior(Block block) : base(block)
1923 {
@@ -41,17 +45,53 @@ namespace AnvilMetalRecovery
4145 #if DEBUG
4246 world.Api.Logger.VerboseDebug("{0} Ingot Mold(s) with L {1} Units, R {2} Units", ingotMold.quantityMolds, ingotMold.fillLevelLeft, ingotMold.fillLevelRight);
4347 #endif
44- }
4548
49+ if ( ingotMold.fillLevelLeft >= shavingValue && ingotMold.contentsLeft != null)
50+ {
51+ var ingotMetal = ingotMold.contentsLeft.Collectible.Variant[@"metal"];
52+ SpawnMetalBits(world, pos, ingotMold.fillLevelLeft, ingotMetal);
53+ }
54+
55+ if ( ingotMold.fillLevelRight >= shavingValue && ingotMold.contentsRight != null)
56+ {
57+ var ingotMetal = ingotMold.contentsLeft.Collectible.Variant[@"metal"];
58+ SpawnMetalBits(world, pos, ingotMold.fillLevelRight, ingotMetal);
59+ }
60+
61+ return;
62+ }
4663
4764 if (someBlockEntity is BlockEntityToolMold) {
4865 var toolMold = someBlockEntity as BlockEntityToolMold;
4966 #if DEBUG
5067 world.Api.Logger.VerboseDebug("Tool Mold with {0} Units", toolMold.fillLevel);
5168 #endif
69+ if ( toolMold.fillLevel >= shavingValue && toolMold.metalContent != null)
70+ {
71+ var metalCode = toolMold.metalContent.Collectible.Variant.AnyKeys(@"metal", @"material");
72+ SpawnMetalBits(world, pos, toolMold.fillLevel, metalCode);
73+ }
5274 }
5375
5476 }
77+
78+ internal void SpawnMetalBits(IWorldAccessor world, BlockPos pos, int unitQuantity, string baseMetalCode)
79+ {
80+ if (unitQuantity > 0)
81+ {
82+ int shavingQty = unitQuantity / shavingValue;
83+ Item metalShavingsItem = world.Api.World.GetItem(MetalBits_partial.AppendPathVariant(baseMetalCode));
84+
85+ if (shavingQty >= 1 && metalShavingsItem != null)
86+ {
87+ var metalShavingsStack = new ItemStack(metalShavingsItem, shavingQty);
88+ #if DEBUG
89+ world.Api.Logger.VerboseDebug("Creating '{0}' @{1} *{2} Units",metalShavingsItem, pos, shavingQty);
90+ #endif
91+ world.Api.World.SpawnItemEntity(metalShavingsStack, pos.ToVec3d( ).Add(0.1d, 0, 0));
92+ }
93+ }
94+ }
5595 }
5696 }
5797
--- a/AnvilMetalRecovery/Helpers.cs
+++ b/AnvilMetalRecovery/Helpers.cs
@@ -100,6 +100,14 @@ namespace AnvilMetalRecovery
100100 {
101101 return parameters.All(parm => parm != null);
102102 }
103+
104+ internal static string AnyKeys(this RelaxedReadOnlyDictionary<string, string> source, params string[ ] keys)
105+ {
106+ foreach (var key in keys) {
107+ if (source.ContainsKey(key)) return source[key];
108+ }
109+ return String.Empty;
110+ }
103111 }
104112 }
105113