Skip to main content
The Minecraft class is the core client-side class that manages the game instance, including rendering, player management, level handling, and game loop execution.

Constructor

Creates a new Minecraft game instance.
Component*
Component for mouse input handling
Canvas*
Parent canvas for rendering
MinecraftApplet*
Applet context (can be NULL)
int
Display width
int
Display height
bool
Whether to run in fullscreen mode

Core Methods

init

Initializes the Minecraft game instance, setting up textures, fonts, renderers, and other core systems.

run

Starts the main game loop. This method runs continuously until the game is stopped.

run_middle

Executes the middle portion of the game loop. Split from run() to allow integration with platform-specific game loops (Xbox, PlayStation).

run_end

Executes the end portion of the game loop and cleanup.

tick

Updates game state for one tick (called 20 times per second).
bool
True for the first active viewport in splitscreen
bool
True if renderer textures should be updated

destroy

Cleans up and destroys the Minecraft instance, releasing all resources.

Level Management

setLevel

Sets the active level/world.
MultiPlayerLevel*
The level to set as active
int
default:"-1"
Message ID to display during level transition
shared_ptr<Player>
default:"nullptr"
Player to force insert into the level
bool
default:"true"
Whether to force save player statistics
bool
default:"false"
Whether the primary player signed out

getLevel

Gets the level for a specific dimension.
int
Dimension ID (0 = Overworld, -1 = Nether, 1 = The End)

selectLevel

Selects and loads a level from a save file.

releaseLevel

Releases the current level and displays a message.

Player Management

createPrimaryLocalPlayer

Creates the primary local player for a given controller/input device.
int
Input device index (0-3 for Xbox/PlayStation controllers)

createExtraLocalPlayer

Creates an additional local player for splitscreen multiplayer.
int
Player index (0-3)
const wstring&
Player name
int
Controller pad index
int
Starting dimension

addLocalPlayer

Adds a local player to the game and rearranges the screen for splitscreen.

removeLocalPlayerIdx

Removes a local player from the game.

setLocalPlayerIdx

Sets the active local player index.

getLocalPlayerIdx

Gets the currently active local player index.

Screen Management

setScreen

Sets the current screen/menu.
Screen*
The screen to display (NULL for in-game)

getScreen

Returns the currently displayed screen.

pauseGame

Pauses the game and displays the pause menu.

Connection Management

connectTo

Connects to a multiplayer server.
const wstring&
Server address or hostname
int
Server port number

getConnection

Gets the client connection for a specific player.
int
Player input device index

clearConnectionFailed

Clears connection failure flags.

Utility Methods

GetInstance

Returns the singleton Minecraft instance.

getAspectRatio

Returns the true physical aspect ratio for perspective projection.

getLevelSource

Returns the level storage source for loading/saving worlds.

getWorkingDirectory

Gets the game’s working directory.

onWindowResize

Handles window resize events.

emergencySave

Performs an emergency save of the current game state.

Public Member Variables

int
Current display width
int
Current display height
int
Physical framebuffer width
int
Physical framebuffer height
MultiPlayerLevel*
Current active level
shared_ptr<MultiplayerLocalPlayer>
Current local player
shared_ptr<MultiplayerLocalPlayer>[4]
Array of all local players for splitscreen
MultiPlayerGameMode*
Current game mode handler
Textures*
Texture manager
Options*
Game options and settings
SoundEngine*
Sound and music manager
Gui*
In-game GUI renderer
LevelRenderer*
Level/world renderer
GameRenderer*
Main game renderer
volatile bool
Whether the game is paused
volatile bool
Whether the game is running
TexturePackRepository*
Texture pack/skin repository

Static Constants

The game version string.
Frame timing data for performance monitoring.
Tick timing data for performance monitoring.

Example Usage

Creating a Minecraft Instance

Loading a World

Managing Splitscreen Players

Connecting to a Server

Thread Safety

The setLevel method uses a critical section (m_setLevelCS). Always ensure proper synchronization when modifying level state from multiple threads.

Platform Considerations

The Minecraft class includes platform-specific code for:
  • Xbox (DURANGO)
  • PlayStation (ORBIS)
  • PC (WINDOWS64)
  • PS Vita (PSVITA)
Widescreen support maintains vertical FOV while adjusting horizontal FOV based on the physical aspect ratio.