Getting Started
The easiest way to think about CampAPI is this: pick the thing you want to react to, then attach your logic to it.
1) Pick the feature you actually need
A few common choices:
BeforeRenderScreenEventwhen you want to stop or replace a screen renderAfterRenderScreenEventwhen you want to run code after a screen has drawnOnKeyEventandOnTouchEventwhen you want to react to player inputGetSplashTextEventwhen you want to change the startup splash textRPMConstructorwhen you want to observe resource-pack manager setupgetLibBase()andgetVtableClass()when you need native addresses
2) Put listeners inside a scope
ModuleScope keeps things tidy. When the scope ends, its listeners are cleaned up automatically.
cpp
CampAPI::ModuleScope scope;
scope.AddListener<OnKeyEvent>([](OnKeyEvent& event) {
if (event.isKeyDown && event.keyCode == 66) {
event.Consume();
}
});3) Make a JavaScript mod
A normal JS mod usually looks like this:
text
{CampAPIRootFolder}/scripts/ExampleMod/
manifest.json
scripts/
index.js
utils.jsExample manifest.json:
json
{
"name": "Example Mod",
"author": "Alvin",
"version": "1.0.0",
"namespace": "example",
"export": true,
"entry": "index.js"
}Example scripts/index.js:
js
import { getModInfoByName } from 'internal:mod'
import { sigscan } from 'internal:modding'
import { fetch } from 'internal:network'
console.log('Loaded:', getModInfoByName('Example Mod'))
const addr = sigscan('libminecraftpe.so', '48 8B ?? ??')
console.log('Signature result:', addr)
const res = fetch('https://example.com/version.json')
console.log(res.status, res.ok)4) Reuse files from other exported mods
If a mod is marked "export": true, other mods can import from it using @namespace/path.
js
import { helper } from '@example/utils.js'That is handy for shared utilities, constants, and small bootstraps you do not want to copy everywhere.
Practical tip
Start small. A mod that changes splash text or reacts to one key is much easier to debug than a huge mod with everything mixed together.