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/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,
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)
+
+
+
+
+