A client-server synchronized BepInEx plugin for Valheim that tracks comprehensive player statistics and exports them to JSON for external dashboards and analytics.
This plugin uses a client-server model where:
- Clients capture game events (kills, damage, crafting, etc.) using Harmony patches
- Server receives stats via RPC and persists them to JSON
- Mod Enforcement ensures all connecting players have the mod installed (players without it are kicked after 10 seconds)
This design is necessary because Valheim's combat and many other events only fire on the client side.
- Kill Tracking - Records every creature kill by type per player
- Boss Kills - Tracks all 7 boss defeats separately
- Death Tracking - Records deaths with cause (creature name, PvP, or environmental)
- Damage Dealt - Total damage dealt by each player
- Resource Gathering - Tracks 21 resource types (wood, ores, hides, etc.)
- Foraging - Berries, mushrooms, thistle, and other pickables
- Farming - Seeds planted and crops harvested
- Crafting - Records every item crafted with quantities
- Processing - Ore smelted, coal produced, flour milled, etc.
- Cooking - Meat roasted on cooking stations
- Brewing - Meads fermented in fermenters
- Building - Every structure placed and deconstructed tracked by type
- Skills - Snapshots of all 18 skill levels
- Inventory - Current inventory contents with item quality
- Time Played - Total session time per player
- Distance Traveled - Cumulative distance moved
- Last Seen - Timestamp of last activity
- Event History - Complete timeline of all game events with Valheim's in-game day
- Kill Events - Every creature and boss kill with game day
- Death Events - Player deaths with cause and game day
- Crafting Events - Items crafted, cooked, brewed, processed
- Gathering Events - Resources collected, items foraged
- Building Events - Structures placed and deconstructed, seeds planted
- Session Tracking - Player join/leave events with timestamps
- Day-End Snapshots - Skills and distance captured at end of each game day for progression tracking
- Download
ValheimKillStats.dllfrom the Releases page - Copy to your server's
BepInEx/plugins/folder - Restart the server
Stats are written to BepInEx/plugins/stats.json every 2 seconds.
Timeline events are written to BepInEx/plugins/timeline.json every 2 seconds.
All players must install the mod to play on the server. Players without the mod will be kicked after 10 seconds.
- Install BepInEx if not already installed
- Download
ValheimKillStats.dllfrom the Releases page - Copy to your client's
BepInEx/plugins/folder - Launch Valheim
The client version must match the server version.
{
"lastUpdated": "2025-12-14T10:30:00Z",
"players": {
"Viking": {
"totalKills": 150,
"killsByCreature": {
"Greydwarf": 45,
"Greydwarf_Elite": 8,
"Troll": 3,
"Skeleton": 22
},
"bossKills": {
"Eikthyr": 1,
"gd_king": 1
},
"deaths": 5,
"deathsByCause": {
"Greydwarf": 2,
"Troll": 1,
"Fall": 1,
"PvP": 1
},
"damageDealt": 125430.0,
"resourcesGathered": {
"Wood": 2500,
"Stone": 800,
"Copper Ore": 150,
"Fine Wood": 320
},
"itemsCrafted": {
"item_sword_iron": 2,
"item_bow_huntsman": 1,
"item_shield_wood": 3
},
"itemsGathered": {
"Raspberry": 45,
"Blueberry": 32,
"Mushroom": 28,
"Thistle": 15
},
"seedsPlanted": {
"Carrot": 50,
"Turnip": 30,
"Barley": 100
},
"itemsProcessed": {
"CopperOre (Smelter)": 80,
"TinOre (Smelter)": 40,
"Wood (Charcoal Kiln)": 200,
"Barley (Windmill)": 50
},
"foodCooked": {
"Cooked Meat": 45,
"Grilled Neck Tail": 12,
"Cooked Fish": 8
},
"meadsBrewed": {
"MeadBaseTasty": 10,
"MeadBaseHealthMinor": 5,
"MeadBaseStaminaMinor": 8
},
"structuresBuilt": {
"piece_wall_wood": 150,
"piece_floor_wood": 80,
"piece_roof_wood": 45,
"piece_workbench": 3,
"piece_chest_wood": 12
},
"skills": {
"Swords": 45.5,
"Axes": 38.2,
"Wood Cutting": 52.0,
"Run": 28.3
},
"currentInventory": [
{"name": "item_sword_iron", "amount": 1, "quality": 3},
{"name": "Wood", "amount": 50, "quality": 0},
{"name": "Coins", "amount": 234, "quality": 0}
],
"timePlayedSeconds": 36000,
"distanceTraveled": 45230.5,
"lastSeen": "2025-12-14T10:25:00Z"
}
},
"serverTotals": {
"totalKills": 523,
"totalDeaths": 28,
"totalDamageDealt": 482000.0,
"totalItemsCrafted": 156,
"totalItemsGathered": 892,
"totalSeedsPlanted": 340,
"totalItemsProcessed": 1250,
"totalFoodCooked": 245,
"totalMeadsBrewed": 89,
"totalStructuresBuilt": 1547,
"bossesDefeated": ["Eikthyr", "gd_king", "Bonemass"]
}
}{
"version": "1.0",
"lastUpdated": "2025-12-20T10:30:00Z",
"currentGameDay": 45,
"eventCount": 1523,
"events": [
{
"id": "a1b2c3...",
"eventType": "Kill",
"player": "Viking",
"gameDay": 5,
"realTimestamp": "2025-12-20T08:15:00Z",
"target": "Greydwarf"
},
{
"id": "b2c3d4...",
"eventType": "BossKill",
"player": "Viking",
"gameDay": 45,
"realTimestamp": "2025-12-20T12:30:00Z",
"target": "Eikthyr",
"isBoss": true
},
{
"id": "c3d4e5...",
"eventType": "DayEnd",
"player": "Viking",
"gameDay": 45,
"realTimestamp": "2025-12-20T22:00:00Z",
"skills": { "Swords": 52.3, "Axes": 28.1, "Run": 45.0 },
"distance": 12500.0
}
]
}See TIMELINE_SCHEMA.md for complete documentation.
| Category | Resources |
|---|---|
| Wood | Wood, Fine Wood, Core Wood, Ancient Bark, Yggdrasil Wood, Ashwood |
| Stone | Stone, Flint, Obsidian, Grausten, Black Marble |
| Ores | Copper Ore, Tin Ore, Iron Scrap, Silver Ore, Black Metal, Flametal Ore |
| Gemstones | Bloodstone, Iolite, Jade |
| Hides | Leather Scraps, Deer Hide, Troll Hide, Wolf Pelt, Lox Pelt, Scale Hide, Asksvin Hide |
| Mistlands | Sap, Carapace, Mandible, Bilebag, Blood Clot, Soft Tissue, Seeker Meat, Blue Jute |
| Ashlands | Sulfur, Charcoal Resin, Proustite Powder, Molten Core, Celestial Feather |
| Ashlands Drops | Asksvin Bladder/Neck, Morgen Heart/Sinew, Bonemaw Meat, Vulture Meat |
| Other | Coal, Resin, Guck, Chitin, Black Core, Feathers, Tar |
| Category | Skills |
|---|---|
| Combat | Swords, Knives, Clubs, Polearms, Spears, Axes, Unarmed, Bows, Crossbows, Blocking |
| Gathering | Pickaxes, Wood Cutting |
| Movement | Run, Jump, Sneak, Swim |
| Other | Fishing, Ride |
| Prefab Name | Boss | Type |
|---|---|---|
Eikthyr |
Eikthyr | Main |
gd_king |
The Elder | Main |
Bonemass |
Bonemass | Main |
Dragon |
Moder | Main |
GoblinKing |
Yagluth | Main |
SeekerQueen |
The Queen | Main |
Fader |
Fader | Main |
Brenna |
Brenna | Mini |
Geirrhafa |
Geirrhafa | Mini |
Zil |
Zil | Mini |
Thungr |
Thungr | Mini |
LordReto |
Lord Reto | Mini |
| Category | Items |
|---|---|
| Berries | Raspberry, Blueberry, Cloudberry |
| Mushrooms | Mushroom, Blue Mushroom, Yellow Mushroom, Jotunpuffs, Magecap |
| Plants | Thistle, Dandelion, Carrot, Turnip, Onion, Barley, Flax |
| Other | Honey, Surtling Core, Greydwarf Eye, Freeze Gland, Royal Jelly, Dragon Egg |
| Ashlands | Smoke Puff, Fiddlehead, Vineberry Cluster |
| Eggs | Egg, Chicken Egg |
| Category | Items |
|---|---|
| Vegetables | Carrot, Turnip, Onion |
| Crops | Barley, Flax |
| Trees | Beech, Birch, Oak, Pine, Fir |
| Processor | Function |
|---|---|
| Smelter | Ore → Metal bars |
| Blast Furnace | Advanced ore → Metal |
| Charcoal Kiln | Wood → Coal |
| Windmill | Barley → Flour |
| Spinning Wheel | Flax → Linen |
| Eitr Refinery | Sap + Soft Tissue → Eitr |
| Prefab | Display Name | Station |
|---|---|---|
CookedMeat |
Cooked Meat | Standard |
NeckTailGrilled |
Grilled Neck Tail | Standard |
CookedFish |
Cooked Fish | Standard |
CookedLoxMeat |
Cooked Lox Meat | Standard |
CookedHareMeat |
Cooked Hare Meat | Standard |
CookedChickenMeat |
Cooked Chicken Meat | Standard |
CookedDeerMeat |
Cooked Deer Meat | Standard |
CookedWolfMeat |
Cooked Wolf Meat | Standard |
CookedBugMeat |
Cooked Bug Meat | Standard |
SerpentMeatCooked |
Cooked Serpent Meat | Standard |
CookedBoarMeat |
Cooked Boar Meat | Standard |
CookedSeekerMeat |
Cooked Seeker Meat | Iron |
CookedBonemawMeat |
Cooked Bonemaw Meat | Iron |
CookedAsksvintail |
Cooked Asksvin Tail | Iron |
CookedVultureMeat |
Cooked Vulture Meat | Iron |
Bread |
Bread | Oven |
| Prefab | Display Name | Type |
|---|---|---|
SoupCarrot |
Carrot Soup | Soup |
SoupMushroomBlue |
Blue Mushroom Soup | Soup |
SoupMushroom |
Mushroom Soup | Soup |
SoupThistleBlood |
Blood Thistle Soup | Soup |
SoupFish |
Fish Soup | Soup |
SoupFishFancy |
Fancy Fish Soup | Soup |
SoupDumplings |
Dumpling Soup | Soup |
SoupYggdrasilFlesh |
Yggdrasil Flesh Soup | Soup |
StewIronbind |
Ironbind Stew | Stew |
StewBlood |
Blood Stew | Stew |
StewFishWraith |
Fish Wraith Stew | Stew |
StewSnowball |
Snowball Stew | Stew |
StewSerpent |
Serpent Stew | Stew |
StewCholesterol |
Cholesterol Stew | Stew |
SaladPreparedGreen |
Green Salad | Salad |
SaladPreparedCold |
Cold Salad | Salad |
SaladPreparedCookedVegetable |
Vegetable Salad | Salad |
Sausages |
Sausages | Other |
BlackSoup |
Black Soup | Other |
| Prefab | Display Name |
|---|---|
Bread |
Bread |
BarleyFlour |
Barley Flour |
PieApple |
Apple Pie |
PieVegetable |
Vegetable Pie |
CookedCarrot |
Cooked Carrot |
CookedOnion |
Cooked Onion |
CookedTurnip |
Cooked Turnip |
CookedMushroom |
Cooked Mushroom |
CookedBeetsoup |
Beet Soup |
Tracks when mead bases are added to fermenters:
- MeadBaseTasty, MeadBaseHealthMinor, MeadBaseHealthMedium, MeadBaseHealthMajor
- MeadBaseStaminaMinor, MeadBaseStaminaMedium, MeadBaseFrostResist
- MeadBasePoisonResist, MeadBaseEitrMinor, and more
All pieces placed via the hammer are tracked by piece name, including:
- Walls, floors, roofs, beams, poles, stairs
- Workbenches, forges, stonecutters, artisan stations
- Beds, chests, signs, portals, wards
- Decorations, furniture, and all other placeable structures
- Distance updates: Every 2 seconds (filters teleports >100 units)
- Stats save: Every 2 seconds
- Timeline save: Every 2 seconds
- Skill/inventory snapshots: Every 2 seconds
- Day-end snapshots: Emitted when in-game day changes (captures skills + distance for each player)
- Thread-safe: All stats operations are locked for concurrent access
- Persistent: Stats and timeline accumulate across server restarts
- Timeline rotation: Rotates to archive file when >10MB
Client Side (Event Capture)
The plugin uses Harmony to patch Valheim game methods on the client:
Character.Damage- Track damage and last attackerCharacter.OnDeath- Attribute kills and record deathsInventory.AddItem- Track resource gatheringInventoryGui.DoCrafting- Track crafting and cauldron/oven foodsPickable.RPC_Pick- Track foraging (berries, mushrooms, etc.)Player.PlacePiece- Track farming (planting seeds) and building (structures)Smelter.OnAddOre/Smelter.OnAddFuel- Track processingCookingStation.UpdateCooking- Track cooking (when food finishes cooking)Fermenter.AddItem- Track brewing (meads)Player.OnSpawned/Player.OnDestroy- Session tracking
Server Side (Persistence)
- Receives stats via
ZRoutedRpcRPCs from clients - Persists cumulative stats to
stats.json - Enforces mod installation via version handshake
RPC Messages
KillStats_Kill- Kill event with creature nameKillStats_BossKill- Boss defeatKillStats_Death- Player death with causeKillStats_Damage- Damage dealtKillStats_Resource- Resource gatheredKillStats_Craft- Item craftedKillStats_Gather- Item foragedKillStats_Plant- Seed plantedKillStats_Process- Item processedKillStats_Cook- Food cookedKillStats_Brew- Mead brewedKillStats_Build- Structure builtKillStats_Skills- Skill snapshotKillStats_Inventory- Inventory snapshotKillStats_Distance- Distance traveledKillStats_Playtime- Session timeKillStats_ModCheck- Version handshakeKillStats_Timeline- Timeline event (v0.6.0+)
- Valheim Dedicated Server with BepInEx 5.4.x
- All clients must have BepInEx 5.4.x and the same version of this mod
dotnet restore
dotnet build --configuration ReleaseOutput: ValheimKillStats/bin/Release/net462/ValheimKillStats.dll
MIT License
Built for the mrberto Valheim server.