Skip to main content
The entity rendering system handles all moving objects in the game, including mobs, players, projectiles, and items, using a flexible model-based architecture.

Architecture

Base Class Hierarchy

EntityRenderer Base Class

See: EntityRenderer.h:20

Core Methods

Render Method

Parameters:
  • entity - The entity to render
  • x, y, z - Interpolated position
  • rot - Body rotation
  • a - Frame interpolation alpha (0.0 to 1.0)
See: EntityRenderer.h:39

Texture Binding

See: EntityRenderer.h:41-45

Shadow Rendering

See: EntityRenderer.h:48

Post-Render

Handles name tags and additional post-rendering effects. See: EntityRenderer.h:57

MobRenderer

See: MobRenderer.h:11

Render Pipeline

The MobRenderer::render method follows this sequence:
  1. Setup Position - setupPosition()
  2. Setup Rotations - setupRotations()
  3. Render Model - renderModel()
  4. Render Armor - Multiple passes for armor layers
  5. Additional Rendering - additionalRendering()
  6. Name Tag - renderName()
See: MobRenderer.h:26

Model Rendering

Parameters:
  • wp - Walk position
  • ws - Walk speed
  • bob - Bobbing amount
  • headRotMinusBodyRot - Head rotation relative to body
  • headRotx - Head pitch rotation
  • scale - Model scale
See: MobRenderer.h:28

Rotation Setup

Handles:
  • Death animation rotation
  • Body rotation
  • Bobbing animation
  • Flip degrees when dying
See: MobRenderer.h:30

Armor Rendering

Armor is rendered in multiple layers:
See: MobRenderer.h:14 and MobRenderer.h:34-36

Name Tag Rendering

See: MobRenderer.h:41 Name tags are visible within specific distances:
See: MobRenderer.h:6-8

Model System

Base Model Class

See: Model.h:10

Model Parts

Models are composed of ModelPart objects representing body parts:
Each part can have:
  • Position and rotation
  • Child parts
  • Texture coordinates
  • Compiled display lists

Texture Mapping

See: Model.h:17-29

HumanoidModel

See: HumanoidModel.h:4

Animation System

HumanoidModel supports various animation overrides:
See: HumanoidModel.h:20-40

Setup Animation

Calculates limb rotations based on:
  • Walking animation
  • Idle animation
  • Sneaking pose
  • Bow drawing
  • Eating
  • Riding
  • Swimming
  • Custom skin animations
See: HumanoidModel.h:58

Rendering Components

See: HumanoidModel.h:59-61

Specialized Models

BookModel

See: BookModel.h:5 Used for enchantment tables and books.

QuadrupedModel

For animals with four legs:
  • PigModel
  • CowModel
  • SheepModel
  • WolfModel
  • OzelotModel

Specialized Mob Models

  • SpiderModel - 8 legs with articulation
  • GhastModel - Floating body with tentacles
  • SlimeModel - Scalable cube
  • EnderDragonModel - Complex multi-part dragon
  • SquidModel - Body with 8 tentacles

Example Renderers

BlazeRenderer

See: BlazeRenderer.h:5

BoatRenderer

See: BoatRenderer.h:4 Renders boats with:
  • Water bobbing animation
  • Paddle animation
  • Damage texture overlay

EntityRenderDispatcher

Central registry for all entity renderers:
Maintains a map of entity types to renderers.

TileEntityRenderDispatcher

Similar system for tile entities:

Custom Skin Support

The system supports custom player skins:
  • 64×64 texture support (via _reinit)
  • HD skin textures
  • Animated skin features
  • Custom model parts
See: HumanoidModel.h:53

Performance Considerations

Compiled Models

Models can use OpenGL display lists:

Shadow Rendering

Shadows are rendered as:
  • Projected texture on ground
  • Strength fades with height
  • Radius based on entity size
  • Optional tile-based shadow occlusion

Flame Rendering

Entities on fire have flames rendered:
See: EntityRenderer.h:47

Integration with Rendering Pipeline

Entity rendering is called from LevelRenderer::renderEntities:
  1. Prepare dispatchers with camera offset
  2. Enable lighting layer
  3. Render global entities (no culling)
  4. Render regular entities (with frustum culling)
  5. Render tile entities
  6. Disable lighting layer
See: LevelRenderer.cpp:494-604