From 9d5ba93c6c22e3ae5d4564fb32bd3bcf3717b99c Mon Sep 17 00:00:00 2001 From: SketchFoxsky <109103755+SketchFoxsky@users.noreply.github.com> Date: Thu, 4 Dec 2025 18:12:37 -0500 Subject: [PATCH 1/2] 1.1.5 Updated NetFramework to 8.0 Updated Workflow to use Directory.Build.props (make a Local.VS.props with your VS install path to avoid missing assemblies) Added Harvest Configs Added Config Save/Load --- .gitignore | 4 +- Directory.Build.props | 14 ++++++ Substrate/Substrate/Directory.Build.props | 14 ++++++ Substrate/Substrate/Substrate.csproj | 2 +- Substrate/Substrate/SubstrateConfig.cs | 24 +++++++++ Substrate/Substrate/SubstrateModSystem.cs | 56 ++++++++++++++++++++- Substrate/Substrate/modinfo.json | 4 +- Substrate/ZZCakeBuild/CakeBuild.csproj | 2 +- Substrate/ZZCakeBuild/Directory.Build.props | 14 ++++++ 9 files changed, 127 insertions(+), 7 deletions(-) create mode 100644 Directory.Build.props create mode 100644 Substrate/Substrate/Directory.Build.props create mode 100644 Substrate/Substrate/SubstrateConfig.cs create mode 100644 Substrate/ZZCakeBuild/Directory.Build.props diff --git a/.gitignore b/.gitignore index 9491a2f..b68756c 100644 --- a/.gitignore +++ b/.gitignore @@ -360,4 +360,6 @@ MigrationBackup/ .ionide/ # Fody - auto-generated XML schema -FodyWeavers.xsd \ No newline at end of file +FodyWeavers.xsd +Substrate/Substrate/Local.VS.props +Substrate/ZZCakeBuild/Local.VS.props diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..296d506 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,14 @@ + + + + + + $(MSBuildThisFileDirectory) + + + + + diff --git a/Substrate/Substrate/Directory.Build.props b/Substrate/Substrate/Directory.Build.props new file mode 100644 index 0000000..296d506 --- /dev/null +++ b/Substrate/Substrate/Directory.Build.props @@ -0,0 +1,14 @@ + + + + + + $(MSBuildThisFileDirectory) + + + + + diff --git a/Substrate/Substrate/Substrate.csproj b/Substrate/Substrate/Substrate.csproj index ecae52d..7602bfb 100644 --- a/Substrate/Substrate/Substrate.csproj +++ b/Substrate/Substrate/Substrate.csproj @@ -1,7 +1,7 @@  - net7.0 + net8.0 false bin\$(Configuration)\Mods\mod diff --git a/Substrate/Substrate/SubstrateConfig.cs b/Substrate/Substrate/SubstrateConfig.cs new file mode 100644 index 0000000..f9464f3 --- /dev/null +++ b/Substrate/Substrate/SubstrateConfig.cs @@ -0,0 +1,24 @@ +using System; + +namespace Substrate +{ + /// + /// Configuration for the Substrate mod. + /// Serialized to /ModConfig/substrateconfig.json. + /// + [Serializable] + public class SubstrateConfig + { + /// + /// Global multiplier for mushroom harvest size. + /// 1.0 = default behavior, 0.5 = half, 2.0 = double, etc. + /// + public float HarvestMultiplier { get; set; } = 1.0f; + + /// + /// Clamp for the final effective grow chance (0..1 typically). + /// Keeps things from going too crazy if HarvestMultiplier is very high. + /// + public float MaxEffectiveChance { get; set; } = 1.0f; + } +} diff --git a/Substrate/Substrate/SubstrateModSystem.cs b/Substrate/Substrate/SubstrateModSystem.cs index cbf61b6..433d6b0 100644 --- a/Substrate/Substrate/SubstrateModSystem.cs +++ b/Substrate/Substrate/SubstrateModSystem.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using HarmonyLib; using Substrate.Behaviors; @@ -21,12 +22,23 @@ namespace Substrate { public class SubstrateModSystem : ModSystem { + private const string ConfigFileName = "substrateconfig.json"; + internal static ILogger Logger { get; private set; } + /// + /// Active configuration for the Substrate mod. + /// Loaded on the server, defaults used if no file exists. + /// + internal static SubstrateConfig Config { get; private set; } = new SubstrateConfig(); + + #region Lifecycle + // Called on server and client // Useful for registering block/entity classes on both sides public override void Start(ICoreAPI api) { + // Register blocks / block entities api.RegisterBlockClass("BlockFruitingBag", typeof(BlockFruitingBag)); api.RegisterBlockClass("BlockGrowBed", typeof(BlockGrowBed)); api.RegisterBlockEntityClass("FruitingBag", typeof(BlockEntityFruitingBag)); @@ -34,16 +46,24 @@ public override void Start(ICoreAPI api) api.RegisterBlockClass("BlockSporePaper", typeof(BlockSporePaper)); api.RegisterBlockEntityClass("SporePaper", typeof(BlockEntitySporePaper)); + // Behaviors api.RegisterCollectibleBehaviorClass("UseInventoryShape", typeof(BehaviorShapeInventory)); api.RegisterBlockBehaviorClass("BehaviorMushroomGrower", typeof(BehaviorMushroomGrower)); + // Harmony patches var harmony = new Harmony(Mod.Info.ModID); harmony.PatchAll(typeof(SubstrateModSystem).Assembly); + + // Only the server needs to own the config file (SP server included) + if (api.Side == EnumAppSide.Server) + { + LoadOrCreateConfig(api); + } } public override void AssetsFinalize(ICoreAPI api) { - // Add UseInventoryShape behavior to all spore harvestable mushrooms + // Add UseInventoryShape behavior to all spore-harvestable mushrooms foreach (var obj in api.World.Collectibles) { if (obj == null || obj.Code == null) continue; @@ -64,5 +84,37 @@ public override void StartClientSide(ICoreClientAPI api) { Logger = Mod.Logger; } + + #endregion + + #region Config + + private static void LoadOrCreateConfig(ICoreAPI api) + { + try + { + var loaded = api.LoadModConfig(ConfigFileName); + if (loaded != null) + { + Config = loaded; + } + else + { + // No file yet, create with defaults + Config = new SubstrateConfig(); + } + + // Write back to ensure the file exists / is updated with new fields + api.StoreModConfig(Config, ConfigFileName); + Logger?.Notification("[Substrate] Loaded config from {0}", ConfigFileName); + } + catch (Exception e) + { + Logger?.Error("[Substrate] Failed to load config {0}: {1}", ConfigFileName, e); + Config = new SubstrateConfig(); + } + } + + #endregion } } diff --git a/Substrate/Substrate/modinfo.json b/Substrate/Substrate/modinfo.json index 8895895..f97856f 100644 --- a/Substrate/Substrate/modinfo.json +++ b/Substrate/Substrate/modinfo.json @@ -3,10 +3,10 @@ "modid": "substrate", "name": "Substrate", "authors": [ - "willis81808" + "Willis81808, SketchFoxsky" ], "description": "To be added", - "version": "1.1.1", + "version": "1.1.5", "dependencies": { "game": "" } diff --git a/Substrate/ZZCakeBuild/CakeBuild.csproj b/Substrate/ZZCakeBuild/CakeBuild.csproj index 8e2c970..67807c1 100644 --- a/Substrate/ZZCakeBuild/CakeBuild.csproj +++ b/Substrate/ZZCakeBuild/CakeBuild.csproj @@ -1,7 +1,7 @@ Exe - net7.0 + net8.0 $(MSBuildProjectDirectory) diff --git a/Substrate/ZZCakeBuild/Directory.Build.props b/Substrate/ZZCakeBuild/Directory.Build.props new file mode 100644 index 0000000..296d506 --- /dev/null +++ b/Substrate/ZZCakeBuild/Directory.Build.props @@ -0,0 +1,14 @@ + + + + + + $(MSBuildThisFileDirectory) + + + + + From a293df438ec4654fdb8acaf33fefa92c224115ea Mon Sep 17 00:00:00 2001 From: SketchFoxsky <109103755+SketchFoxsky@users.noreply.github.com> Date: Thu, 4 Dec 2025 18:20:38 -0500 Subject: [PATCH 2/2] Update woodchip.json Updated to sticks x 2 to be compatible with Firewood to Sticks --- .../Substrate/assets/substrate/recipes/grid/woodchip.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Substrate/Substrate/assets/substrate/recipes/grid/woodchip.json b/Substrate/Substrate/assets/substrate/recipes/grid/woodchip.json index 3550597..f495e04 100644 --- a/Substrate/Substrate/assets/substrate/recipes/grid/woodchip.json +++ b/Substrate/Substrate/assets/substrate/recipes/grid/woodchip.json @@ -4,7 +4,8 @@ "A": { type: "item", code: "game:axe-*", isTool: true }, "L": { "type": "item", - "code": "game:firewood" + "code": "game:stick", + quantity: 2 } }, width: 1,