Skip to main content

Overview

The Level API provides core functionality for world management in Minecraft Community Edition. The Level class serves as the foundation for both single-player and multiplayer worlds, handling block manipulation, entity management, lighting, and game logic.

Class Hierarchy

Level Class

The abstract base class for all game worlds. Header: Minecraft.World/Level.h
Inherits: LevelSource

Constants

Core Members

Constructors

constructor
Creates a new level with the specified storage, name, dimension, and settings.Parameters:
  • levelStorage - Shared pointer to level storage system
  • name - World name
  • dimension - Dimension instance (Overworld, Nether, End)
  • levelSettings - World generation and gameplay settings
constructor
Creates a dimension variant of an existing level.Parameters:
  • level - Source level to derive from
  • dimension - Target dimension

Block Access & Modification

int
Gets the block ID at the specified coordinates.Returns: Block/tile ID, or 0 if air or unloaded
int
Gets the block metadata/data value at the specified coordinates.Returns: Block data value (0-15)
bool
Sets a block at the specified position with lighting and updates.Parameters:
  • x, y, z - Block coordinates
  • tile - Block ID to place
Returns: true if block was changed
bool
Sets both block ID and metadata at the specified position.Parameters:
  • x, y, z - Block coordinates
  • tile - Block ID to place
  • data - Metadata value (0-15)
Returns: true if block was changed
bool
Sets a block without triggering neighbor updates or lighting recalculation.Warning: Use sparingly - can cause lighting bugs if not followed by checkLight()
void
Sets block metadata/data value.Parameters:
  • data - Metadata value (0-15)
  • forceUpdate - Force neighbor updates even if data unchanged

Chunk Management

bool
Checks if a chunk is loaded (may return true for chunks being generated).Parameters:
  • x, z - Chunk coordinates (not block coordinates)
bool
Checks if a chunk is actually loaded and ready.Note: More strict than hasChunk() - doesn’t include chunks being generated
LevelChunk*
Gets a chunk, loading it if necessary.Returns: Pointer to chunk (never null - will load/generate if needed)
LevelChunk*
Gets the chunk containing the specified block coordinates.Parameters:
  • x, z - Block coordinates (will be converted to chunk coords)

Lighting

int
Gets light level at coordinates for the specified layer.Parameters:
  • layer - LightLayer::Sky or LightLayer::Block
  • x, y, z - Block coordinates
Returns: Light level (0-15)
void
Sets light level at coordinates.Parameters:
  • brightness - Light level (0-15)
void
Recalculates lighting at the specified position.Parameters:
  • force - Force recalculation even if lighting appears correct
  • rootOnlyEmissive - Only recalculate emissive (block) lighting
int
Gets raw brightness combining sky and block light.Returns: Combined light level (0-15)

Entity Management

bool
Adds an entity to the world.Returns: true if entity was added successfully
void
Marks an entity for removal on next tick.
vector<shared_ptr<Entity>>*
Gets all entities within a bounding box.Parameters:
  • except - Entity to exclude from results
  • bb - Axis-aligned bounding box
vector<shared_ptr<Entity>>*
Gets entities of a specific type within a bounding box.Example:

World Queries

int
Gets the Y coordinate of the highest non-air block.Returns: Y coordinate of topmost solid block
bool
Checks if a position has direct line of sight to the sky.
bool
Checks if a position contains air.
Biome*
Gets the biome at the specified coordinates.
int
Gets the sea level for this world.Returns: Y coordinate of sea level (typically 63)

Time & Weather

__int64
Gets the current world time in ticks.
void
Sets the world time.
bool
Checks if it’s currently daytime.
bool
Checks if it’s currently raining.
bool
Checks if there’s currently a thunderstorm.
void
Sets rain intensity (0.0 to 1.0).

Tick & Update

void
Advances the world by one tick (1/20th of a second).Updates entities, tile entities, scheduled ticks, weather, and mob spawning.
void
Updates all entities in the world.

MultiPlayerLevel Class

Client-side implementation of Level for multiplayer worlds. Header: Minecraft.Client/MultiPlayerLevel.h
Inherits: Level

Key Features

  • Receives world updates from server via ClientConnection
  • Manages chunk visibility and streaming
  • Handles entity synchronization
  • Supports multiple local players (split-screen)

Constructor

constructor
Creates a multiplayer client-side level.Parameters:
  • connection - Connection to server
  • levelSettings - World settings
  • dimension - Dimension ID (0=Overworld, -1=Nether, 1=End)
  • difficulty - Difficulty level

Methods

void
Marks a chunk as visible or invisible to the client.Used for chunk streaming - invisible chunks can be unloaded.
void
Registers an entity with a network ID for synchronization.
shared_ptr<Entity>
Gets an entity by its network ID.
shared_ptr<Entity>
Removes and returns an entity by network ID.

Example Usage

Basic Block Manipulation

Finding Entities

Lighting Updates

See Also