How to Make Another Mod Communicate With Distant Horizons Using the API
Why Use the API Instead of Direct Calls
Distant Horizons changes its internal classes between versions and loaders. The Distant Horizons API Mod exists so your mod can talk to Distant Horizons through a stable, loader-independent surface. Always call through the API rather than importing Distant Horizons classes directly, or your mod will break whenever Distant Horizons updates.
Steps to Wire Up Communication
1. Add the API mod as a dependency in your build and mod metadata.
2. At mod init, query the API for whether Distant Horizons is present and active. Do not assume it is installed — handle the absent case gracefully so your mod still loads.
3. Use the API's provided methods to read Distant Horizons state (for example, whether distant rendering is enabled) and to push changes you want to make.
4. Wrap all API calls in a check that the API is available, and log clearly if a call fails, so players can report issues accurately.
Common Pitfalls
Do not cache references to Distant Horizons objects across world reloads; re-acquire them through the API each time. Do not assume a specific loader — the whole point of this API is that the same call works everywhere. If a feature you need is not exposed, request it upstream rather than bypassing the API, since bypassing reintroduces the compatibility problems the API was built to solve.