Game systems
These pages cover the systems a player interacts with: stats and hunger, eating and drinking, crafting, heat, smelting and forging, cooking, XP and skills, farming, trading and a few smaller ones. Everything here is in Root.Township (build main-1.7.2.1.42203).
Pages
| Page | What it covers |
|---|---|
| Stats | StatManager, Stat, StatDefinition, modifiers. Health, hunger and every other number on a body. |
| Hunger, eating and drinking | HungerStat, FullnessStat, ConsumptionManager, EdibleObject, PlayerDrinkingMouth. |
| Effects | Alta.Alchemy: what food, drinks and potions do to the body. |
| Progression | PlayerProgressionManager, PathExperience, ProgressionSettings. Where XP comes from. |
| Skills and unlocks | Skill trees, shrines and orbs, and the climbing tower's stations (PlayerUnlockStation). |
| Crafting | Joining parts, generic crafting stations (recipe page and nails), RaycastCrafter. |
| Heat | HeatPoint, heat sources, fires and fuel. |
| Smelting and forging | Smelter, smelting recipes, moulds, bellows, ForgedModel, the recycler. |
| Cooking | Roasting (Cookable) and stews (CookingPot, StewManager, StewRecipe). |
| Liquids | Liquid containers, liquid data and how liquid moves. |
| Farming, woodcutting and carpentry | Growing plants, trees, chiselling. |
| Trading | Trade vendors, tax, the ATM bank, postboxes. |
| Customization | Cosmetics, outfits and armour visuals. |
| Other systems | Enchantments, mechanisms, logic circuits, fuses, GameTaskManager. |
Who runs what
Almost all game rules run on the server. The pattern is the same everywhere:
- A component subscribes to its events in
InitializeAsServer, or checksNetworkSceneManager.IsServerbefore it acts. Docking an ore in a smelter, a pot reaching temperature, food finishing a bite: the client sees the same events, but only the server's copy does anything. - The server sends results to clients with the entity's
MethodSyncmessages (stat syncs, smelter icons, stew changes). A client never decides an outcome. Changing a value on a client changes only what that player sees until the next sync overwrites it. - Clients run visuals: particles, sounds, the stat bar, the bellows' light. Most visual code is skipped when
ApplicationManager.IsHeadlessis true, which it is on a dedicated server.
So a mod that changes rules (recipe results, XP, hunger, fuel) only needs to be on the server. A mod that adds something players must see in a new way (a new stat bar, a new liquid colour no client knows) needs a client part too, and the client half has to handle a server without it. See Networking for how messages work, and Entity sync for MethodSync.
Shared building blocks
You meet these in every system:
- Assets with hashes. Recipes, stat definitions, effects, liquids, moulds and smelter upgrades are
ScriptableObjects that derive fromHashedGeneralValue<T>(inAlta.Values).T.Alllists every loaded one,T.Get(uint hash)finds one by hash, andT.Get(string name)finds one by asset name. The name lookup strips spaces from what you pass but doesn't lower-case it, while the table is lower-cased, so pass lower case with no spaces ("hungerstat", not "Hunger Stat"). The network sends these by hash, so a client can only understand assets it has too. - Global settings. Tuning lives in
GlobalSettings<T>.Instance(Alta.Global):ProgressionSettings,CookingSettings,GenericCraftingSettings,LiquidSettings. They're shared assets, so changing a field changes it for the whole process. - Server settings. The host's
ServerSettings(ServerHandler.Current.ServerConfig.Settings) holds knobs these systems read every time they run. Prefer these over a patch when they do what you need:
| Setting | Default | Read by |
|---|---|---|
HungerTick | 0.0005 | HungerStat, every stat tick |
HealthRegenMultiplier | 1 | HungerStat regeneration |
HungerDealsDamage | true | HungerStat starvation |
IsResetingHungerOnDeath | false | StatManager.DeathReset |
XPX and ForgingXPX, WoodcuttingXPX, MiningXPX, ChiselingXPX, CookingXPX, MeleeXPX, RangedXPX | 1 | PathExperience.GainExperience |
UnspentExperienceLostOnDeath | 0 | PlayerProgressionManager on death |
DecayMultiplier, SpawningRateMultiplier | 1 | decay and spawning, through NetworkScene |
TimeSpeedMultiplier | 1 | Timeline.Instance.TimeSpeed (set by TimeManager). Everything scheduled on the Timeline speeds up with it: stat ticks (so hunger and regeneration), timed modifiers, growth stages, vendor tax and tree respawns. |
Real values
Pages in this area quote values from the game's assets (build main-1.7.2.1.42203) where they matter, marked as asset values: player stats, hunger levels, cooking temperatures, stew and smelting recipes, fuel, the XP curve, skill trees and trading costs. The full generated lists of items, recipes and stats are in the reference tables: Items and materials, Recipes and Stats.
Hooks that cover a lot
A few methods sit where many systems meet:
PlayerProgressionManager.GainExperience(IPlayer, ProgressionPath, int): every XP grant in the game ends here. See Progression.ConsumptionManager.HandleConsumptionEffects(internal): everything a player eats or drinks. See Hunger, eating and drinking.GameTaskManager.ActionExecuted(IPlayer, GameTaskActionArgument): a static the game calls for achievement counters when a player eats, smelts, crafts, docks or spawns certain things. See Other systems.StatManager.Tick(protected virtual): once a second per body, on the server.
What existing mods hook
Real mods are a good map of what works. From their source:
- CookingLib patches
CookingPot(InitializeAsServer,StartWarmingUpStage,LoadAtCurrentStage),StewManager(CheckForValidRecipe,HandleNewStewStage,CreateContentWithTint),StewRecipe.FindStewRecipeForIngredients,Cookable(SpawnCookedVersion,SwapToBurntVersion),ConsumptionManager.HandleConsumptionEffects,EdibleObject.StartEat,PlayerDrinkingMouth.LiquidAmountChangedandLiquidData's save and network code. - CustomRecipesAPI adds
SmeltingRecipeandMouldDefinitionassets by writing them intoHashedGeneralValue<T>'s privateitemstable and intoSmelterUpgrades.recipes, and adds items to the ore dock'sPickupDockSettings. - Hydrate or Dierate keeps its thirst value in its own code and sends it with its own message, rather than adding a game stat. Stats explains why that's the safe choice.
- DyeingAPI and CookingLib both patch
LiquidContainerTrigger.OnTriggerEnterto react to items dipped in liquid.
All of these have to work against the vanilla client, which is why most of them change server-side rules and leave the visuals alone.