7 Commits
1.1.0 ... 1.3.0

Author SHA1 Message Date
mikx
e9603a9019 (1.3.0) readme update 2026-01-29 22:45:12 -05:00
mikx
6cdc527dba (1.3.0) Individual Item Weight > 'BepInEx\config\mxvalheim.custom_weights.json' 2026-01-29 22:42:34 -05:00
mikx
4aaeed7abc (1.2.1) reverted to 1.2.0 due to ConfigSync problems 2026-01-28 21:03:52 -05:00
mikx
a50d7df8d5 (1.2.1) reverted to 1.2.0 due to ConfigSync problems 2026-01-28 21:03:26 -05:00
mikx
e8b579db54 (1.3.0) readme update 2026-01-28 20:07:46 -05:00
mikx
766c3f7608 (1.3.0) Added ServerSync compatibility 2026-01-28 20:05:17 -05:00
mikx
3db032a530 (1.2.0) Bow Draw Speed + Rain Damage 2026-01-27 05:33:36 -05:00
8 changed files with 154 additions and 11 deletions

View File

@@ -1,28 +1,76 @@
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using UnityEngine;
using Newtonsoft.Json;
[BepInPlugin(ModGUID, ModName, ModVersion)]
public class MxValheimMod : BaseUnityPlugin
{
public static MxValheimMod Instance; // Singleton reference
private const string ModGUID = "ovh.mxdev.mxvalheim";
private const string ModName = "MxValheim";
private const string ModVersion = "1.1.0";
private const string ModVersion = "1.3.0";
public static ConfigEntry<int> OreMultiplier;
public static ConfigEntry<float> rangeMultiplier;
public static ConfigEntry<bool> Config_Locked;
public static ConfigEntry<int> Config_OreMultiplier;
public static ConfigEntry<float> Config_rangeMultiplier;
public static ConfigEntry<float> Config_bowDrawSpeedBonusPerLevel;
public static ConfigEntry<bool> Config_rainDamage;
public static ConfigEntry<float> Config_boatSpeed;
// Set your multiplier here
public static int Multiplier = 3;
private static string WeightConfigPath => Path.Combine(Paths.ConfigPath, "mxvalheim.custom_weights.json");
public static Dictionary<string, float> WeightSettings = new Dictionary<string, float>();
void Awake()
{
OreMultiplier = Config.Bind("General","OreMultiplier",3,"How many items should drop for every 1 ore/scrap found.");
rangeMultiplier = Config.Bind("General", "CraftingRangeMultiplier",2.0f,"Multiplier for the workbench build/crafting range. Default is 2x.");
Instance = this;
Config_OreMultiplier = Config.Bind("General","OreMultiplier",3,"How many items should drop for every 1 ore/scrap found.");
Config_rangeMultiplier = Config.Bind("General", "CraftingRangeMultiplier",2.0f,"Multiplier for the workbench build/crafting range. Default is 2x.");
Config_bowDrawSpeedBonusPerLevel = Config.Bind("General", "BowDrawSpeedBonusPercentPerLevel", 1.0f, "Shorten the bow draw speed by this percent for every bow upgrade level.");
Config_rainDamage = Config.Bind("General", "RainDamage", true, "Set to true to stop rain damage, false to return to vanilla behavior.");
Config_boatSpeed = Config.Bind("General", "BoatSpeedMultiplier", 2.0f, "Your boat/raft will move without wind at a speed multiplied by this value.");
LoadJsonConfig();
Harmony harmony = new Harmony(ModGUID);
harmony.PatchAll();
}
private void Update()
{
// Only check while in the game world to save resources
if (ObjectDB.instance == null) return;
}
private bool LoadJsonConfig()
{
try
{
if (!File.Exists(WeightConfigPath))
{
WeightSettings = new Dictionary<string, float> { { "Wood", 1.0f }, { "Stone", 1.0f } };
File.WriteAllText(WeightConfigPath, JsonConvert.SerializeObject(WeightSettings, Newtonsoft.Json.Formatting.Indented));
return true;
}
string json = File.ReadAllText(WeightConfigPath);
WeightSettings = JsonConvert.DeserializeObject<Dictionary<string, float>>(json);
Logger.LogInfo($"Successfully parsed {WeightSettings.Count} items.");
return true;
}
catch (Exception ex)
{
Logger.LogWarning($"Could not read JSON (might be busy): {ex.Message}");
return false;
}
}
}

View File

@@ -10,6 +10,7 @@
<RootNamespace>MxValheim</RootNamespace>
<AssemblyName>MxValheim</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<LangVersion>12.0</LangVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
@@ -34,12 +35,19 @@
<Reference Include="0Harmony">
<HintPath>E:\SteamLibrary\steamapps\common\Valheim\BepInEx\core\0Harmony.dll</HintPath>
</Reference>
<Reference Include="assembly_valheim">
<HintPath>E:\SteamLibrary\steamapps\common\Valheim\Valheim_Data\Managed\assembly_valheim.dll</HintPath>
<Reference Include="Assembly-CSharp-publicized">
<HintPath>E:\SteamLibrary\steamapps\common\Valheim\Valheim_Data\Managed\Assembly-CSharp-publicized.dll</HintPath>
</Reference>
<Reference Include="assembly_valheim-publicized">
<HintPath>E:\SteamLibrary\steamapps\common\Valheim\Valheim_Data\Managed\assembly_valheim-publicized.dll</HintPath>
</Reference>
<Reference Include="BepInEx">
<HintPath>E:\SteamLibrary\steamapps\common\Valheim\BepInEx\core\BepInEx.dll</HintPath>
</Reference>
<Reference Include="gui_framework, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" />
<Reference Include="Newtonsoft.Json">
<HintPath>E:\SteamLibrary\steamapps\common\Valheim\BepInEx\plugins\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
@@ -48,6 +56,7 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="Unity.TextMeshPro, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" />
<Reference Include="UnityEngine">
<HintPath>E:\SteamLibrary\steamapps\common\Valheim\Valheim_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
@@ -61,9 +70,15 @@
</ItemGroup>
<ItemGroup>
<Compile Include="MxValheim.cs" />
<Compile Include="Patch\Bow.cs" />
<Compile Include="Patch\CraftingStation.cs" />
<Compile Include="Patch\Items.cs" />
<Compile Include="Patch\Ores.cs" />
<Compile Include="Patch\WearNTear.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="E:\SteamLibrary\steamapps\common\Valheim\Valheim_Data\Managed\assembly_guiutils.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

25
MxValheim/Patch/Bow.cs Normal file
View File

@@ -0,0 +1,25 @@
using BepInEx;
using HarmonyLib;
using UnityEngine;
using BepInEx.Logging;
using HarmonyLib.Tools;
namespace MxValheim.Patch
{
public class Bow_Patch
{
// We patch Start because that's when the Attack object initializes its timers
[HarmonyPatch(typeof(Player), "UpdateAttackBowDraw")]
public static class Patch_AttackStart
{
static void Prefix(ItemDrop.ItemData weapon, ref float ___m_attackDrawTime, bool ___m_attackHold)
{
if (___m_attackDrawTime >= 0f && ___m_attackHold)
{
int quality = weapon.m_quality;
___m_attackDrawTime += UnityEngine.Time.fixedDeltaTime * (MxValheimMod.Config_bowDrawSpeedBonusPerLevel.Value*quality);
}
}
}
}
}

View File

@@ -17,7 +17,7 @@ namespace MxValheim.Patch
if (rangeField.FieldExists())
{
float currentRange = rangeField.GetValue<float>();
rangeField.SetValue(currentRange * MxValheimMod.rangeMultiplier.Value);
rangeField.SetValue(currentRange * MxValheimMod.Config_rangeMultiplier.Value);
}
}
}

33
MxValheim/Patch/Items.cs Normal file
View File

@@ -0,0 +1,33 @@
using HarmonyLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace MxValheim.Patch
{
internal class Items
{
[HarmonyPatch(typeof(ObjectDB), nameof(ObjectDB.Awake))]
public static class ObjectDB_Patch
{
public static void Postfix()
{
if (ObjectDB.instance == null) return;
int count = 0;
foreach (GameObject item in ObjectDB.instance.m_items)
{
ItemDrop itemDrop = item.GetComponent<ItemDrop>();
if (itemDrop != null && MxValheimMod.WeightSettings.TryGetValue(item.name, out float newWeight))
{
itemDrop.m_itemData.m_shared.m_weight = newWeight;
count++;
}
}
}
}
}
}

View File

@@ -14,7 +14,7 @@ namespace MxValheim.Patch
{
if (__result == null || __result.Count == 0) return;
int countToAdd = MxValheimMod.OreMultiplier.Value - 1;
int countToAdd = MxValheimMod.Config_OreMultiplier.Value - 1;
if (countToAdd <= 0) return;
List<GameObject> extraDrops = new List<GameObject>();

View File

@@ -0,0 +1,19 @@
using BepInEx;
using HarmonyLib;
namespace MxValheim.Patch
{
public class WearNTear_Patch
{
[HarmonyPatch(typeof(WearNTear), "HaveRoof")]
class WearNTear_HaveRoof_Patch
{
static void Postfix(WearNTear __instance, ref bool __result)
{
if (!MxValheimMod.Config_rainDamage.Value) return;
__result = true;
}
}
}
}

View File

@@ -4,8 +4,11 @@
Official Mx Valheim Mod.
## Features
- Tweak individual item(s) weight in "BepInEx\config\mxvalheim.custom_weights.json".
- Ore drop multiplier. (Value available in the generated config.)
- Workbench crafting range multiplier. (Value available in the generated config.)
- Reduce Bow draw time for each upgrade level. (Value available in the generated config.)
- Disable rain damage. (Enable/Disable in the generated config.)
## How-To Install
1. Download the latest dll.