Faucet Mod SDK 1.0.0
Modding API for Minecraft Legacy Console Edition
Loading...
Searching...
No Matches
SDK Namespace Reference

Top-level mod API. Wraps singleton access and common operations. More...

Functions

MinecraftServerGetServer ()
 Get the MinecraftServer singleton.
MinecraftGetClient ()
 Get the Minecraft client singleton.
ServerLevelGetServerLevel (int dimension=0)
 Get the server-side level for a given dimension.
MultiPlayerLevel * GetClientLevel (int dimension=0)
 Get the client-side level for a given dimension.
PlayerListGetPlayerList ()
 Get the PlayerList (all connected server players).
MultiplayerLocalPlayer * GetLocalPlayer ()
 Get the primary local player on the client.
MultiplayerLocalPlayer * GetLocalPlayer (int index)
 Get a local player by splitscreen index (0–3).
void Log (const wstring &message)
 Write a message to mods/modloader.log and OutputDebugString.
void LogWarn (const wstring &message)
 Write a warning to the log (prefixed with [WARN]).
void LogError (const wstring &message)
 Write an error to the log (prefixed with [ERROR]).
void BroadcastMessage (const wstring &message)
 Send a chat message to all connected players.
void SendMessageToPlayer (const wstring &playerName, const wstring &message)
 Send a private chat message to a specific player by name.
void ExecuteCommand (const wstring &command)
 Execute a server console command.
void SetTimeOfDay (__int64 time)
 Set the world time for a dimension.
void SaveAll (bool force=false)
 Save all worlds immediately.
bool IsPvpAllowed ()
 Check whether PvP is currently allowed on the server.
void SetPvpAllowed (bool enabled)
 Enable or disable PvP on the server.
bool IsFlightAllowed ()
 Check whether flight is allowed on the server.
void SetFlightAllowed (bool enabled)
 Enable or disable flight on the server.

Detailed Description

Top-level mod API. Wraps singleton access and common operations.

You can use these helpers, or call the real game classes directly after obtaining them via SDK::GetServer() / SDK::GetClient().

Function Documentation

◆ BroadcastMessage()

void SDK::BroadcastMessage ( const wstring & message)

Send a chat message to all connected players.

Internally calls PlayerList::sendMessage for every connected player.

Parameters
messageWide string message to broadcast.
Example
SDK::BroadcastMessage(L"Server restarting in 60 seconds!");
void BroadcastMessage(const wstring &message)
Send a chat message to all connected players.

◆ ExecuteCommand()

void SDK::ExecuteCommand ( const wstring & command)

Execute a server console command.

Equivalent to typing into the server console.

Parameters
commandCommand string, e.g. L"time set day".
Example
SDK::ExecuteCommand(L"time set 0");
SDK::ExecuteCommand(L"weather clear");
void ExecuteCommand(const wstring &command)
Execute a server console command.

◆ GetClient()

Minecraft * SDK::GetClient ( )

Get the Minecraft client singleton.

Equivalent to Minecraft::GetInstance().

Example
if (mc) mc->pauseGame();
The main Minecraft client class. One instance per process.
Definition SDK.h:307
void pauseGame()
Pause the game (shows pause menu).
Minecraft * GetClient()
Get the Minecraft client singleton.

◆ GetClientLevel()

MultiPlayerLevel * SDK::GetClientLevel ( int dimension = 0)

Get the client-side level for a given dimension.

Parameters
dimension0 = Overworld, -1 = Nether, 1 = End.

◆ GetLocalPlayer() [1/2]

MultiplayerLocalPlayer * SDK::GetLocalPlayer ( )

Get the primary local player on the client.

Returns the first active local player (splitscreen index 0). Returns nullptr if no level is loaded.

◆ GetLocalPlayer() [2/2]

MultiplayerLocalPlayer * SDK::GetLocalPlayer ( int index)

Get a local player by splitscreen index (0–3).

Parameters
indexSplitscreen slot index.

◆ GetPlayerList()

PlayerList * SDK::GetPlayerList ( )

Get the PlayerList (all connected server players).

Use this to iterate all online players, send messages, kick, etc.

Example
if (list) {
for (auto& sp : list->players)
sp->sendMessage(L"Hello!", ChatPacket::e_ChatCustom);
}
Manages all connected ServerPlayers on the server.
Definition PlayerList.h:27
vector< shared_ptr< ServerPlayer > > players
All currently connected players. Iterate this for all players.
Definition PlayerList.h:32
PlayerList * GetPlayerList()
Get the PlayerList (all connected server players).

◆ GetServer()

MinecraftServer * SDK::GetServer ( )

Get the MinecraftServer singleton.

Equivalent to MinecraftServer::getInstance(). Returns nullptr if the server is not running yet (check in OnInit or later).

Example
if (srv) srv->broadcastStartSavingPacket();
The dedicated server / integrated server class.
MinecraftServer * GetServer()
Get the MinecraftServer singleton.

◆ GetServerLevel()

ServerLevel * SDK::GetServerLevel ( int dimension = 0)

Get the server-side level for a given dimension.

Parameters
dimension0 = Overworld, -1 = Nether, 1 = End.
Returns
ServerLevel pointer, or nullptr if that dimension isn't loaded.
Example
The server-side representation of a loaded dimension/world.
Definition SDK.h:970
ServerLevel * GetServerLevel(int dimension=0)
Get the server-side level for a given dimension.

◆ Log()

void SDK::Log ( const wstring & message)

Write a message to mods/modloader.log and OutputDebugString.

Parameters
messageWide string message.
Example
SDK::Log(L"MyMod: tick " + std::to_wstring(tickCount));
void Log(const wstring &message)
Write a message to mods/modloader.log and OutputDebugString.

◆ LogError()

void SDK::LogError ( const wstring & message)

Write an error to the log (prefixed with [ERROR]).

Parameters
messageError text.

◆ LogWarn()

void SDK::LogWarn ( const wstring & message)

Write a warning to the log (prefixed with [WARN]).

Parameters
messageWarning text.

◆ SaveAll()

void SDK::SaveAll ( bool force = false)

Save all worlds immediately.

Parameters
forceIf true, saves even if nothing is dirty.

◆ SendMessageToPlayer()

void SDK::SendMessageToPlayer ( const wstring & playerName,
const wstring & message )

Send a private chat message to a specific player by name.

Parameters
playerNameTarget player's username.
messageMessage to send.

◆ SetFlightAllowed()

void SDK::SetFlightAllowed ( bool enabled)

Enable or disable flight on the server.

Parameters
enabledTrue to allow flight.

◆ SetPvpAllowed()

void SDK::SetPvpAllowed ( bool enabled)

Enable or disable PvP on the server.

Parameters
enabledTrue to allow PvP.

◆ SetTimeOfDay()

void SDK::SetTimeOfDay ( __int64 time)

Set the world time for a dimension.

Wraps MinecraftServer::SetTimeOfDay().

Parameters
timeTicks (0 = dawn, 6000 = noon, 12000 = dusk, 18000 = midnight).
Example
SDK::SetTimeOfDay(6000); // Set to noon
void SetTimeOfDay(__int64 time)
Set the world time for a dimension.