Skip to main content

Crate yog_api

Crate yog_api 

Source
Expand description

Yog API — the single crate mod authors depend on.

A facade that re-exports every Yog domain plus the central Registry hub. Add a new domain crate, re-export it here, and mods pick it up via yog_api::*. Items are available both flat (yog_api::Registry) and namespaced by domain (yog_api::world::World).

Modules§

book
In-game book/documentation system (Patchouli-like).
command
Commands.
config
Mod configuration (typed key/value files).
content
Content registration (custom items / blocks / food).
core
Core types and handles.
entity
Entity access (teleport, position, health, … by UUID).
event
Events and the subscription registry.
gfx_core
Core graphics constants and enumerations.
gfx_draw2d
2D drawing helpers — thin wrappers over the draw2d_* ABI functions.
gfx_gl
Low-level GPU resource wrappers: Buffer, VertexArray, ShaderProgram, Texture.
network
Networking (raw-byte packets over channels).
player
Player access (give item, teleport).
storage
Persistent key-value storage for mod data.
ui
UI framework — flexbox layout + widgets on top of yog-gfx.
widget
Widget types and styling.
world
World access (block get/set, dimensions).

Macros§

error
Logging macros (yog_api::info!, warn!, error!). Log at ERROR level.
export_mod
Export a Mod as a dynamically loadable Yog mod.
info
Logging macros (yog_api::info!, warn!, error!). Log at INFO level.
packet
Declare a typed packet struct whose fields are automatically encoded/decoded.
warn
Logging macros (yog_api::info!, warn!, error!). Log at WARN level.

Structs§

AdvancementEvent
Fired when a player earns an advancement (Post only).
AdvancementReward
AttackEntityEvent
Fired when a player attacks (left-clicks) an entity (server side).
BlockBreakEvent
Fired when a player breaks a block (server side).
BlockDef
A custom block to register; it also gets a matching block-item.
BlockPos
A block position in the world.
Book
The top-level book definition — replaces patchouli_books/<id>/book.json.
BookCategory
Represents a book category tab (e.g. “Basics”, “Patterns”).
BookEntry
One entry in a book (like a “page” in the TOC sidebar).
BookMacro
A macro substitution (e.g. $(thing) → red color span).
BookRecipe
A shapeless recipe that produces a book from yog-book. Replaces patchouli:shapeless_book_recipe.
BookRegistry
Global registry for all in-game books.
CServer
A handle to the runtime’s server actions, backed by YogServer fn pointers. Given to every handler as &dyn Server.
ChatEvent
Fired when a player sends a chat message.
ClientTickEvent
Fired every client tick on the render thread.
CommandContext
Details of a command invocation.
Config
A key/value configuration file backed by <game_dir>/yog-config/<mod_id>.cfg.
ContainerCloseEvent
Fired when a player closes a container screen (Post only).
ContainerOpenEvent
Fired when a player opens a container screen.
CraftEvent
Fired when a player takes a crafted item from a crafting output slot (Post only).
Entity
A handle to one entity by UUID, bound to a Server.
EntityDamageEvent
Fired after a living entity takes damage (server side).
EntityDeathEvent
Fired after a living entity dies (server side).
EntityInteractEvent
Fired when a player right-clicks (interacts with) an entity (server side).
EntitySpawnEvent
Fired when any entity is loaded into a world (server side).
ExplosionEvent
Fired when an explosion occurs in a world.
FoodDef
Nutritional properties for a food item.
FurnaceRecipe
A furnace smelting recipe.
GfxContext
Handle to the GPU and draw capabilities for a single render frame.
ItemDef
A custom item to register, identified by namespace:path.
ItemModifier
An item modifier applied during loot generation (like smelting, enchanted, etc.).
ItemPickupEvent
Fired when a player picks up an item entity.
KeyPressEvent
Fired on every key press, release, or repeat (client-side).
PacketEvent
A packet received on a channel.
PlaceBlockEvent
Fired when a player places a block (server side).
Player
A handle to one player, bound to a Server.
PlayerDeathEvent
Fired when a player dies.
PlayerJoinEvent
Fired when a player joins the server.
PlayerLeaveEvent
Fired when a player leaves the server.
PlayerMoveEvent
Fired every time a player sends a movement packet (very high frequency).
PlayerRespawnEvent
Fired when a player respawns after death (Post only).
ProjectileHitEvent
Fired when a persistent projectile (arrow, trident, etc.) hits a target.
Registry
Wraps the YogApi table and provides an ergonomic registration API.
ScreenEvent
Fired when a GUI screen opens or closes.
ShapedRecipe
A shaped crafting recipe (3×3 grid with a pattern and key mapping).
ShapelessRecipe
A shapeless crafting recipe (unordered ingredients).
StartupGrant
Grant items/books to every player once when they first join. This is the Yog-side replacement for grant_patchi_book.json.
Storage
Typed, scoped persistent key-value store.
UiRoot
Top-level UI tree. Build it, call layout, then [render] each frame.
UseBlockEvent
Fired when a player right-clicks a block (server side).
UseItemEvent
Fired when a player right-clicks with an item (server side).
World
An ergonomic handle to one dimension’s blocks, bound to a Server.
YogApi
Stable C ABI — re-exported so mods don’t need a direct yog-abi dependency. Passed to yog_mod_register. Call the function pointers here to register handlers, commands, content, and schedulers.

Enums§

Align
Cross-axis alignment.
BookPage
A single page variant inside a book entry.
EventPhase
Whether a handler is running before or after the action.
FlexDir
Layout direction for flex containers.
StorageScope
Determines which backing file a Storage uses.
Value
A typed storage value.

Constants§

ABI_VERSION
Stable C ABI — re-exported so mods don’t need a direct yog-abi dependency. ABI_MAJOR * 10_000 + ABI_MINOR. Checked at mod load time.

Traits§

Mod
Implemented by every Yog mod. Called once at startup to register handlers.
Packet
A typed packet that can be encoded to / decoded from a raw byte buffer.
PacketField
Encode/decode a single field to/from a byte buffer.
Server
Low-level capabilities the Yog runtime exposes to mods (the engine contract).

Functions§

crafting_page
entity_page
image_page
pattern_page
relations_page
smelting_page
spotlight_page
text_page