Skip to main content

Overview

The Entity API provides the foundation for all moving and interactive objects in Minecraft Community Edition. This includes players, mobs, items, projectiles, and vehicles.

Class Hierarchy

Entity Class

Abstract base class for all entities. Header: Minecraft.World/Entity.h
Inherits: enable_shared_from_this<Entity>

Constants

Core Members

Constructor

constructor
Creates a new entity in the specified world.Parameters:
  • level - World to spawn in
  • useSmallId - Use optimized small ID (for most entities)
Note: Abstract class - cannot be instantiated directly

Position & Movement

void
Sets entity position and updates bounding box.Parameters:
  • x, y, z - New world coordinates
void
Moves entity to position with rotation.Parameters:
  • yRot - Yaw rotation in degrees
  • xRot - Pitch rotation in degrees
void
Absolute move without interpolation (teleport).
void
Moves entity with collision detection.Parameters:
  • xa, ya, za - Movement delta
  • noEntityCubes - Ignore entity collisions
Updates xd, yd, zd based on actual movement after collisions.
void
Rotates entity.Parameters:
  • xo - Pitch change
  • yo - Yaw change
void
Sets rotation directly.
void
Applies relative movement based on current rotation.Parameters:
  • xa, za - Strafe and forward movement
  • speed - Movement multiplier
Use case: Player WASD movement, mob pathfinding

Collision & Physics

bool
Checks if entity can move to an offset position.Returns: true if no collision at new position
AABB*
Gets the collision bounding box.Returns: Pointer to AABB or null if non-solid
AABB*
Gets the box other entities collide against.Returns: AABB for entity-entity collisions
void
Handles entity-to-entity collision.
void
Applies push/knockback force.

Size & Bounding Box

void
Sets entity dimensions.Parameters:
  • w - Width (X and Z)
  • h - Height (Y)
Note: Protected - called in entity constructors
float
Gets eye/camera height.Returns: Height offset from feet to eyes

Distance Calculations

float
Calculates distance to another entity.Returns: Distance in blocks
double
Calculates squared distance (faster - no sqrt).
double
Calculates distance to coordinates.
double
Calculates squared distance to coordinates.

Tick & Update

void
Updates entity for one game tick (1/20 second).Override: Implement entity-specific behavior
void
Performs common tick operations.
  • Updates position history
  • Handles fire damage
  • Updates air supply
  • Manages invulnerability frames

Damage & Death

bool
Applies damage to entity.Parameters:
  • source - Source of damage (entity, lava, fall, etc.)
  • damage - Damage amount
Returns: true if damage was applied
void
Applies fire damage.Parameters:
  • dmg - Damage amount
Note: Protected - called by fire tick logic
void
Sets entity on fire.Parameters:
  • numberOfSeconds - Duration in seconds
void
Extinguishes fire.
bool
Checks if entity is immune to fire.

Water & Breathing

bool
Checks if entity is in water.
bool
Checks if entity is in lava.
bool
Checks if entity is wet.
bool
Updates water collision state.Returns: true if in water
int
Gets remaining air ticks while underwater.Returns: Air ticks (max 300)
void
Sets air supply.

Fall Damage

void
Applies fall damage based on distance.Parameters:
  • distance - Fall distance in blocks
Note: Protected - override for custom fall damage

Interaction

bool
Handles player right-click interaction.Returns: true if interaction was handledExamples: Riding minecart, breeding animal, trading with villager
void
Handles player collision/touch.Examples: Item pickup, damage from cactus/mob
bool
Checks if entity can be clicked/targeted.
bool
Checks if entity can be pushed by other entities.
bool
Checks if entity can be hit by projectiles.

Riding & Vehicles

void
Mounts another entity.Parameters:
  • e - Entity to ride (minecart, pig, boat, etc.)
void
Updates riding state each tick.
void
Positions the rider entity.Override: Customize rider position on vehicle
double
Gets height offset for rider.
double
Gets mount point height.
bool
Checks if entity is riding something.

Rendering & Display

bool
Checks if entity should be rendered from camera position.Parameters:
  • c - Camera position
double
Checks if entity should render at distance.
float
Gets lighting brightness for rendering.Parameters:
  • a - Partial tick (0.0-1.0)
Returns: Brightness multiplier (0.0-1.0)
int
Gets packed light color value.Returns: Combined sky and block light

Flags & State

bool
Checks if entity is burning.
bool
Checks if entity is sneaking.
void
Sets sneaking state.
bool
Checks if entity is sprinting.
void
Sets sprinting state.
bool
Checks if entity is invisible.
void
Sets invisibility.

Lifecycle

void
Marks entity for removal from world.
bool
Checks if entity is alive (not removed).

Data Persistence

bool
Saves entity to NBT tag.Returns: true if saved successfully
void
Loads entity from NBT tag.
void
Reads entity-specific NBT data.Note: Abstract - must be implemented
void
Writes entity-specific NBT data.Note: Abstract - must be implemented

Type System

eINSTANCEOF
Gets entity type enum.Returns: Type constant (eTYPE_PLAYER, eTYPE_MOB, etc.)Use case: Fast type checking without dynamic_cast

Entity Damage Types

Example Usage

Creating & Spawning

Movement & Collision

Proximity Checks

Type Checking

See Also