Skip to main content

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.
Parameters:
  • 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)
Returns: Success probability (0.0 to 1.0) Formula:
Example:

computeCycleTicks()

Compute gathering cycle in ticks (OSRS-accurate, skill-specific).
Parameters:
  • skill - The gathering skill (“mining”, “woodcutting”, “fishing”)
  • baseCycleTicks - Base cycle ticks from resource manifest
  • toolData - Tool data from tools.json manifest (may have rollTicks for mining)
  • bonusRollTriggered - Whether dragon/crystal pickaxe bonus speed triggered (caller rolls this server-side)
Returns: Number of ticks between gathering attempts
Deterministic Function: This function contains NO randomness. For dragon/crystal pickaxe bonus speed, the caller must roll and pass bonusRollTriggered.
Example:

Mining Constants

Location: packages/shared/src/constants/GatheringConstants.ts

Success Rates

Depletion

100% Depletion: Mining rocks ALWAYS deplete after yielding one ore. This matches OSRS behavior. The only exception would be Mining gloves (not currently implemented).

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.
Purpose: Some 3D modeling tools export models with non-uniform scales baked into internal nodes (e.g., scale (2, 0.5, 1)). This causes models to appear “squished” or “stretched”. Behavior:
  • 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
Example:

Resource Entity

Location: packages/shared/src/entities/world/ResourceEntity.ts

Depleted Models

Resources can define depleted models in their manifest:
Behavior:
  • When resource depletes, swaps to depleted model
  • When resource respawns, swaps back to full model
  • Works for all resource types (trees, rocks, fishing spots)
Methods:

Testing

Success Rate Tests

Pickaxe Bonus Tests