Changing the game's own code

Hooks, Parts and [[inject]] listeners cover most mods, and they work the same on native and wasm. When no hook fits and you need to change what a game function itself does, a native mod can take the native route: tables under [native] in sunrise-mod.toml, applied to the prebuilt game without rebuilding it. You work with the game's real types, pinned to the exact game build.

From Sunrise's modding bookead8a1e

  • [[native.mixin]]

    Use it to
    run code at the start or end of a game function, change a value or a call inside it, or replace its body
    Page
    Mixins
  • [[native.loop]]

    Use it to
    run your code before and after each entry of a hot loop the game publishes, such as the block entity tick
    Page
    Published loops
  • [[native.bridge]]

    Use it to
    read, write or call a private field or method of a game type from your mixin code
    Page
    Bridges
  • [[native.module]]

    Use it to
    add a module of your own code inside a game source file, for your mixin code to share
    Page
    Support modules
  • [[native.state]]

    Use it to
    add a field to a game type: refused, use an attachment
    Page
    Native state

Edit this page on GitHub · Spotted something wrong? Open an issue or ask on Discord.