A minimal example demonstrating how to use ToastAPI from a native Minecraft Bedrock mod.
This project shows how a native shared library can call ToastAPI to create & show a Minecraft Toast message.
- Native C++20 Minecraft Bedrock mod
- Preloader-based native hooking
- ARM64 (
arm64-v8a) support - CMake-based build system
- Lightweight release configuration
- Automatic hook installation when the library is loaded
- Automatic hook cleanup when the library is unloaded
The example hooks StartMenuScreenController::open from libminecraftpe.so.
Once the original function executes, the mod calls:
nexcaise::toastapi::sendToastMessage("ToastAPI !!!!!!");The execution flow is:
Minecraft Bedrock
│
▼
StartMenuScreenController::open
│
▼
Native Hook
│
▼
ToastAPI
│
▼
Android Toast
The hook is installed through a constructor function when the shared library is loaded and removed through a destructor function when the library is unloaded.
ToastAPI-Example/
├── include/
├── libs/
│ └── arm64-v8a/
│ ├── libToastAPI.so
│ └── libpreloader.so
├── src/
│ └── main.cpp
├── third_party/
│ └── preloader/
├── CMakeLists.txt
├── buildmod
└── LICENSE
- Android NDK
- CMake 3.22 or newer
- ARM64 Android target
- Minecraft Bedrock native library environment
libToastAPI.solibpreloader.so
The project requires the Android NDK toolchain and uses C++20.
The repository includes a simple build script:
chmod +x buildmod
./buildmodThe script removes the previous build directory, configures a Release CMake build, and builds the shared library using all available CPU cores.
You can also build manually:
rm -rf build
mkdir -p build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . -j$(nproc)The resulting library is:
build/libToastAPI-Example.so
Include the ToastAPI header:
#include "ToastAPI.hpp"Then send a Toast message:
nexcaise::toastapi::sendToastMessage("Hello from ToastAPI!");For example:
void showNotification() {
nexcaise::toastapi::sendToastMessage("Module enabled");
}The repository demonstrates hooking a Minecraft Bedrock function and displaying a Toast after the original function executes:
LL_TYPED_HOOK(
StartMenuScreenController_open,
memory::HookPriority::Normal,
StartMenuScreenController,
pl::memory::resolveVtableFunction("25StartMenuScreenController", 7, "libminecraftpe.so"),
"libminecraftpe.so",
void
) {
origin();
nexcaise::toastapi::sendToastMessage("ToastAPI !!!!!!");
}The hook is registered automatically when the library is loaded:
__attribute__((constructor))
void onLoad() {
StartMenuScreenController_open::hook();
}and removed when the library is unloaded:
__attribute__((destructor))
void onUnload() {
StartMenuScreenController_open::unhook();
}The implementation is provided in src/main.cpp.
Once ToastAPI is available, a mod can use it to provide user-facing runtime notifications such as:
nexcaise::toastapi::sendToastMessage("Module loaded");
nexcaise::toastapi::sendToastMessage("Configuration loaded");
nexcaise::toastapi::sendToastMessage("Feature enabled");
nexcaise::toastapi::sendToastMessage("Feature disabled");This can be useful for mod status messages, feature feedback, configuration events, and other notifications.
This example depends on the following native components:
ToastAPI
Preloader
Minecraft Bedrock native libraries
Android NDK
Make sure the required .so files and Preloader headers are available before building.
This project is licensed under the Apache License 2.0.
See LICENSE for the complete license text.
ToastAPI
ToastAPI provides the native interface used by this example to create & show Minecraft Toast messages.
Made for Minecraft Bedrock native mod development.