Sunrise's machine sample, forked from ari's horizon-machine-sample and ported to the Sunrise mod API. Sunrise's daily run builds it against the day's API.
A small native Sunrise mod with a working machine, a screen and a pipe. It also serves as a tour of the mod API: each example is a small module you can read, change and try in a fresh world.
| Example | What it demonstrates | In the game |
|---|---|---|
| Machine | Pull an item from the west, process it, and send the result east through a pipe. | ![]() |
| Services | An operator announcement registered with Command::executes, with typed sources and source-routed feedback. |
Chat messages |
| Fluid tank | A saved 4,000 mB tank; fill and drain it using a held bucket and transactions. | ![]() |
| Energy | Recover 25 energy per recipe into a saved buffer exposed on every face. | Saved block-entity data |
| Client | A remappable inspection key, camera changes, local sound and a screen overlay. | ![]() |
| Reload | Read processing times from data/ and a screen label from assets/, with pack overrides. |
Label above the machine screen |
| Tags and gamerules | A reloadable input tag and a gamerule that pauses automatic intake. | Recipe membership and intake policy |
| Attachments | Inspect an entity with an empty main hand to record a persistent visit count. | ![]() |
| Tick-rate hook | Observe a server tick-rate update through the typed server_tick_rate_changed hook. |
Earlier implementation |
The default recipe turns cobblestone into stone in 40 ticks. The machine's own menu keeps five backing indices. Its slot rules reject placing or taking items in slots 2–4. A client factory starts those slots inactive; its Deposit button asks the server to move the carried stack into the input. This is a fixed west-to-east transfer example, not a pipe network.
Try each example for the commands, gestures and expected results. Hooks, Parts and the registered screen factory use the public API.
The sample is built the way a mod author builds against an unpublished commit: with the
launcher's developer SDK, from a checkout of the pinned commit. Whether
an sdk-<build id> release exists for the current pin was not checked
(VALIDATION lists what that route did at an earlier pin).
Native mods run with your rights: read the source before trusting it. The steps
below follow Sunrise's
local developer builds
page; SUNRISE is a clean checkout of the pinned commit with its companion programs,
exporters and prepared resources made as that page lists, installed once with
sunrise-launcher developer-install (it prints a developer-… tag, DEVELOPER_TAG below).
git clone https://github.com/sunrise-org/sunrise-machine-sample.git
cd sunrise-machine-sample
(cd SUNRISE && python3 tools/prebuilt_game.py build SDK_FOLDER)
export SUNRISE_LAUNCHER_DEVELOPER_SDK=SDK_FOLDER
sunrise-launcher instance create "Machine Sample"
sunrise-launcher instance version "Machine Sample" DEVELOPER_TAG
sunrise-launcher native-build "$PWD" --instance "Machine Sample" --version DEVELOPER_TAG --trust-native-codeThe last command ends with:
Built (optimized, prebuilt)
native-c417323-<key> built and selected for its instance.
That output, and the timings and run below, are from the earlier pin
c417323915f5051092ff1c4649a0e96ef3022394; they were not repeated at the current pin.
A second run with nothing changed prints Up to date (no build needed). Measured for this
mod on one busy 8-CPU box (three runs each, Rust already downloaded, SDK already built):
unchanged 0.31–0.35 s, after editing src/lib.rs 2.0–2.8 s. A clean build and the SDK's
own build were not timed. The game was started and driven with the sunrise-ctl that
native-build installs beside the executable, with SUNRISE_LAUNCHER_DEVELOPER_OFFLINE=1
(the launcher's play was not run); VALIDATION
lists what was done and seen.
The project names the API by its SDK path, .sunrise/sdk/api/crates/sunrise-mod-api
(ignored by git). cargo sunrise-mod fetches the signed SDK there for a published
build; for an unpublished one, the launcher's build does not need the folder, but an editor or
cargo check does. Run this from the sample's root, giving the exporter's absolute path in the
SUNRISE checkout, so the output lands in the sample:
python3 "$SUNRISE/tools/sdk_api_source.py" build .sunrise/sdk/api (CI does the same). Once an
sdk-<build id> release exists for the pin, cargo sunrise-mod check and build do this by themselves.
Development and packaging covers exact revisions, the flat package layout, source checks and common build prerequisites.
- CI checks formatting, clippy and standalone unit tests. Sunrise's daily run builds the sample at its pinned commit against that day's API source.
- The staging test checks the pinned source export, canonical package writer, deterministic output and that the original checkout stays unchanged.
- The older pictures come from an actual linked Developer build on software Vulkan. Processing and pipe output, tank transfers, saved machine data, and an entity's inspection counter across save/reopen were exercised. They are not proof of every API path; keyboard camera/sound and pack overrides remain unverified.
Validation separates automated checks from gameplay checks and lists the triggers for every module. Contributing has the commands to run before a code change.
MIT: see LICENSE.





