Mining System API
The mining system implements OSRS-accurate mechanics including level-dependent success rates, pickaxe speed bonuses, and 100% rock depletion.Success Rate Calculation
Location:packages/shared/src/systems/shared/entities/gathering/SuccessRateCalculator.ts
computeSuccessRate()
Calculate mining success rate based on player level.skill- The gathering skill (“mining”, “woodcutting”, “fishing”)level- Player’s skill level (1-99)successRateData- Success rate bounds from manifest (or null for 100% success)
computeCycleTicks()
Compute gathering cycle in ticks (OSRS-accurate, skill-specific).skill- The gathering skill (“mining”, “woodcutting”, “fishing”)baseCycleTicks- Base cycle ticks from resource manifesttoolData- Tool data from tools.json manifest (may have rollTicks for mining)bonusRollTriggered- Whether dragon/crystal pickaxe bonus speed triggered (caller rolls this server-side)
Deterministic Function: This function contains NO randomness. For dragon/crystal pickaxe bonus speed, the caller must roll and pass
bonusRollTriggered.Mining Constants
Location:packages/shared/src/constants/GatheringConstants.ts
Success Rates
Depletion
Pickaxe Tool Data
Location:packages/shared/src/data/DataManager.ts
GatheringToolData Interface
Pickaxe Speeds
Example Tool Data:
Server-Side Implementation
Location:packages/shared/src/systems/shared/entities/ResourceSystem.ts
computeCycleTicks() (Server Wrapper)
Server-side wrapper that rolls for dragon/crystal pickaxe bonus speed:Server Authority: The random roll happens ONLY on the server. The computed cycle time is sent to the client via the gathering session state, ensuring perfect sync.
Model Loading
Location:packages/shared/src/utils/rendering/ModelCache.ts
normalizeScales()
Normalize non-uniform scales in GLTF model hierarchy.- Traverses all nodes in the scene
- Resets non-uniform scales to (1, 1, 1)
- Preserves uniform scales (intentional sizing)
- Called ONCE when model is first loaded, before caching
Resource Entity
Location:packages/shared/src/entities/world/ResourceEntity.ts
Depleted Models
Resources can define depleted models in their manifest:- When resource depletes, swaps to depleted model
- When resource respawns, swaps back to full model
- Works for all resource types (trees, rocks, fishing spots)