Eating & Healing System
The eating system provides OSRS-accurate food consumption with proper eat delays, combat integration, and server-authoritative validation.Eating code lives in
packages/shared/src/systems/shared/character/EatDelayManager.ts and integrates with InventorySystem and PlayerSystem.Overview
Food consumption follows Old School RuneScape mechanics:- 3-tick eat delay (1.8 seconds) between eating
- Instant healing when food is consumed
- Combat integration - eating delays your next attack
- Server-authoritative - all validation happens server-side
- Works at full health - shows message and applies delay even when HP is full
How to Eat
Inventory Context Menu
Right-click food in your inventory and select Eat:Left-Click Primary Action
Left-click food to eat immediately (if “Eat” is the primary action in the manifest).Eat Delay Mechanics
OSRS-Accurate Timing
EatDelayManager
TheEatDelayManager tracks eat cooldowns per player:
Server-Authoritative Flow
1. Client Initiates
Player clicks “Eat” on food item:2. Server Validates
Server receivesuseItem message and validates:
3. InventorySystem Processes
4. PlayerSystem Heals
Combat Integration
Attack Delay
Eating applies a 3-tick delay to your next attack:PvP Gear + Eat Combos
OSRS allows rapid gear switching + eating combos. The system uses a separate rate limiter for consume actions to prevent abuse while allowing legitimate combos:Food Types
Food items are defined initems.json manifest with healAmount:
Common Foods
Event Flow
Testing
The eating system has comprehensive test coverage:Related Systems
- Inventory System - Item storage and management
- Combat System - Attack delays and damage
- Cooking Skill - Preparing food
- Item Manifests - Defining food items
API Reference
EatDelayManager
Events
Configuration
Constants
Item Manifest
Food items requirehealAmount and type: "consumable":
Security Features
Server-Side Validation
All eating validation happens server-side:- Slot verification - Item must exist at claimed slot
- Item matching - Item ID must match slot contents
- Eat delay check - Enforced via
EatDelayManager - Rate limiting - Separate consume rate limiter (100ms minimum)
Rate Limiting
OSRS Behavior Parity
Eating at Full Health
OSRS allows eating at full health (shows message, applies delay):Combat Interaction
Eating during combat:- Delays next attack by 3 ticks
- Does not cancel combat - auto-retaliate continues
- Instant healing - HP updates immediately
- No animation interrupt - combat animations continue
Implementation Details
Event-Driven Architecture
The eating system uses event-driven flow to avoid tight coupling:Health Bar Updates
Health bars are event-driven only to prevent stale snapshot race conditions:Related Documentation
- Inventory System - Item management
- Combat System - Attack delays
- Cooking Skill - Preparing food
- Item Manifests - Defining food items