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).
Re-exports§
pub use java::mod_loaded;pub use yog_data;pub use yog_ids;pub use yog_sync as sync;pub use ctor;
Modules§
- advancements
- Advancements: a mod’s are content (
.ydefkind: "advancement"); one granted by the mod’s code says so (criteria: [{ granted: true }]) and is awarded here. What a player has is asked here too, and on the client bycrate::client::advancement_done. - block
- The bus’s domains: each one’s actions as functions
(
world::get_block(dim, pos),entity::position(uuid),player::give_item(name, item, count)) beside its events. What happens to blocks. - body
- Bodies, camera and movement (
yog-body, see its docs): pose and dress entities, disguise and morph them, move the camera, replace the local player’s travel step. Register handlers withRegistry::on_body,Registry::on_cameraandRegistry::on_travel; say which entities to ask about withtrackandtrack_type. - book
- Guide books: the
.ybookformat and its renderer. - bossbar
- The bus’s domains: each one’s actions as functions
(
world::get_block(dim, pos),entity::position(uuid),player::give_item(name, item, count)) beside its events. Boss bars: the host’s actions. - chat
- The bus’s domains: each one’s actions as functions
(
world::get_block(dim, pos),entity::position(uuid),player::give_item(name, item, count)) beside its events. Messages to players: the host’s actions. - client
- Client-side helpers (ABI minor 1): opening a screen with flags, sounds
only the local player hears, the local player’s held items and the
keyboard state. All are no-ops (or
None/false) on a dedicated server and before the mod registered. - command
- Commands.
- config
- Mod configuration (typed key/value files).
- content
- Content registration (custom items / blocks / food).
- core
- Core types and handles.
- dimension
- Custom dimensions — dimension-type definitions and runtime chunk generation.
- entities
- Mod entities the loader draws: a type registered with a
modelgets its body model, playing the clip of its state —walkwhile it walks, elseidle, or the state in its entity datayog:state(a string the mod sets on the server) — timed by the world’s clock, alike for everyone. - entity
- The bus’s domains: each one’s actions as functions
(
world::get_block(dim, pos),entity::position(uuid),player::give_item(name, item, count)) beside its events. What happens to entities. - entity_
flags - What kind of entity something is, as a bit set (
EntityInfo::flags). - event
- Events by plane —
event::player::session::Join,event::block::Break, … — subscribed withRegistry::on/before/after. - game
- The bus’s domains: each one’s actions as functions
(
world::get_block(dim, pos),entity::position(uuid),player::give_item(name, item, count)) beside its events. The game: the host’s actions. - 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. - gfx_
image - Yog image sources — the names every Yog API that shows a picture takes instead of raw Minecraft resource paths, so mods don’t depend on the game version, the loader or where Mojang keeps a texture this release.
- inventory
- Inventory framework — real Container/Menu screens (BlockEntity-backed),
as opposed to
ui’s HUD-drawn overlays. Seeyog-inventory’s DESIGN.md. - item
- The bus’s domains: each one’s actions as functions
(
world::get_block(dim, pos),entity::position(uuid),player::give_item(name, item, count)) beside its events. Items’ services: what a mod says about its items’ stacks. - java
- Other mods — Yog’s and Java ones — from a Yog mod: whether one is
loaded (
crate::mod_loaded), and calls into a Java mod’s API by reflection (call). - loot
- Loot: change what loot tables give — a chest’s, a block’s drops, a
mob’s.
crate::Registry::changewithyog_event::world::loot::Rollsees every table rolled; aLootModifier(a.ydef, or built in code) adds and scales items on some tables, finishing the stacks it adds with the mod’s named loot functions (crate::Registry::loot_function). - mirror
- Mirrors (
docs/design/bus.md, “Mirrors”): data read every tick kept in shared memory. A mod declares the fields it reads (Declared: read in place, released on drop) or provides a mirror (Registry::provide_mirror: its writer is called when fields are due, with only those). Usually through#[yog_mirror], which generates both sides typed. - net
- The bus’s domains: each one’s actions as functions
(
world::get_block(dim, pos),entity::position(uuid),player::give_item(name, item, count)) beside its events. Sending over the network: the host’s actions. - network
- Networking (raw-byte packets over channels).
- particle
- The bus’s domains: each one’s actions as functions
(
world::get_block(dim, pos),entity::position(uuid),player::give_item(name, item, count)) beside its events. Particles: the host’s actions. - player
- The bus’s domains: each one’s actions as functions
(
world::get_block(dim, pos),entity::position(uuid),player::give_item(name, item, count)) beside its events. What players do. - scoreboard
- The bus’s domains: each one’s actions as functions
(
world::get_block(dim, pos),entity::position(uuid),player::give_item(name, item, count)) beside its events. The scoreboard: the host’s actions. - sound
- The bus’s domains: each one’s actions as functions
(
world::get_block(dim, pos),entity::position(uuid),player::give_item(name, item, count)) beside its events. Sounds: the host’s actions. - storage
- Where the mod keeps its data (typed stores by scope, values kept with the world).
Where the mod keeps its data — typed values in stores scoped the way web
storage is (
yog-storage), opened for this mod in the right folder: - tag
- The bus’s domains: each one’s actions as functions
(
world::get_block(dim, pos),entity::position(uuid),player::give_item(name, item, count)) beside its events. Tags: the host’s actions. - ui
- UI framework — flexbox layout + widgets on top of yog-gfx.
- vanilla
- The game’s ids as constants (
yog_api::vanilla::items::REDSTONE), so mod code names them instead of spelling them. Generated byyog-cli/src/vanilla/gen_api.pyfrom the supported versions (1.20.1, 1.21.1); one missing from a version says so. Don’t edit — rerun the script. - widget
- Widget types and styling.
- world
- The bus’s domains: each one’s actions as functions
(
world::get_block(dim, pos),entity::position(uuid),player::give_item(name, item, count)) beside its events. What happens to the world.
Macros§
- content
- Pulls the mod’s blocks and items —
content/**/*.yblockand*.yitem, made in Yog-IDLE’s model editor — in as modulecontent, and registers them (every file without"register": "manual") right afterMod::register: - error
- Logging macros (
yog_api::info!,warn!,error!). Log at ERROR level. - export_
mod - Export a
Modas a dynamically loadable Yog mod. - import
- Inter-mod communication proc-macros.
Another mod’s exports, callable here:
import! { from "mod_id" { pub fn name(a: A) -> R; pub struct T { .. } } }— each fn callsmod_id:nameon the bus and answersOption<R>(None: the mod isn’t loaded, or it failed); each type gets the schema its values cross with. - info
- Logging macros (
yog_api::info!,warn!,error!). Log at INFO level. - resources
- Pulls the mod’s
.yresresources in as moduleres— one type per resource set, with an accessor per entry: - tr
tr!("key")=tr("key");tr!("key", a, b)fills the text’s%sspecifiers withaandb(anythingDisplay) — seeformat_translation.- ui_
component - Registers
.yuicomponents (types implementingui::component::Component) when the mod’s library loads, so screens can use<Name …/>and Yog-IDLE’s designer host can draw them. The codeyog buildgenerates from a<Component>.yuicalls this — mods don’t write it themselves. - ui_
components - Compiles in the mod’s component
.yuifiles that have no code-behind.rs(those with one are pulled in by itsui_include!) — call it once, insrc/lib.rs: - ui_
include - Pulls a
.yuiscreen’s generated code into the current module — the code-behind’s half ofsrc/<name>.yui: - warn
- Logging macros (
yog_api::info!,warn!,error!). Log at WARN level.
Structs§
- Armor
Defense - Defense points per armor piece.
- Armor
Material - What armor is made of. The game’s are built in
(
ArmorMaterial::built_ins); a mod declares its own in a.ydef(kind: "armor_material") or registers one. - Armor
Piece - An item as a piece of armor.
- Block
Def - A custom block to register; it also gets a matching block-item.
- Block
Hit - A block a ray stopped at.
- Block
Info - A block’s properties (
block::Info). - Block
Pos - A block position in the world.
- Block
Property - A property of a block’s own: its name and values (the first the
default;
false,trueis a yes/no). - Book
- A guide book: what a
.ybookfile holds. - Book
Category - A category of the book’s home page.
- Book
Entry - One entry: its pages, in a category.
- Book
Renderer - A book being read: what it shows, laid out for the screen it was last drawn on.
- Client
Packet Event - A packet the server or the client received (
on_packet/on_client_packet). A packet the server sent on a mod’s channel; keyed by the channel. - Command
Context - Details of a command invocation.
- Config
- A key/value configuration file backed by
<game_dir>/yog-config/<mod_id>.cfg. - Entity
- An entity, by its uuid: every action whose first field is
uuid. - Entity
Def - An entity type to register (
.yentity). Its look is a body model (model,.ymodel) with clips by state; what it does beyondgoalsis the mod’s code (entity events, a tick of its own). - Entity
Info - A loaded entity (
entity::Info). - EventCx
- What a handler is handed besides the event: when it runs.
- FoodDef
- Nutritional properties for a food item.
- Generated
Chunk - A chunk column a generator fills (the
world/generation/chunkevent, keyed bygenerator): where it is, and every block placed so far — a palette and a cell per block, like the game’s chunk sections, so the host sets them a section at a time. Several handlers fill one column in turn (terrain, then a mod’s ores). - GfxContext
- Handle to the GPU and draw capabilities for a single render frame.
- Inventory
Def - Describes one inventory-backed screen: how many slots a mod block has, where they sit, whether the player’s own inventory is appended below, and which background texture to draw (vanilla default, or a mod’s own).
- ItemDef
- A custom item to register, identified by
namespace:path. - Layout
Node - ModInfo
- An installed mod.
- Packet
Event - A packet the server or the client received (
on_packet/on_client_packet). A packet a client sent on a mod’s channel; keyed by the channel. - Placed
Block - A block found in the world: where, and its state.
- Player
- An online player, by name: every action whose first field is
player. - Player
Info - An online player’s state (
player::Info). - Point
- A point in a world (blocks, fractional).
- Recipe
- A recipe, in Yog’s own format — what a
.yrecipesays. The host writes the recipe JSON of its Minecraft version from it. - Rect
- A rectangle: its corner
x, y(the one with the smallest coordinates) and its size. - Registry
- Rotation
- Which way an entity faces, in degrees.
- Screen
Slot - A slot of an open inventory screen: what it holds, where it’s drawn (GUI pixels from the screen’s corner).
- Slot
Layout - Pixel position of a single slot in vanilla GUI coordinate space (the same space vanilla screens use: origin at the panel’s top-left corner, one vanilla slot = 18×18px).
- Slot
Stack - A stack in an inventory slot.
- Sound
Group - What a block sounds like: the sound events it plays when broken,
stepped on, placed, hit while mining and fallen on. The game’s groups
are built in (
SoundGroup::built_in); a mod registers its own (Registry::register_sound_group, or a.ydefof kindsound_group) and names it inBlockDef::sound. - Stack
- A stack of items: what it is, how many, its data (SNBT).
- Startup
Grant - Grant items/books to every player once when they first join.
This is the Yog-side replacement for
grant_patchi_book.json. - Tool
Item - An item as a tool or weapon.
- Tool
Material - What tools are made of. The game’s are built in
(
ToolMaterial::built_ins); a mod declares its own in a.ydef(kind: "tool_material") or registers one (Registry::register_tool_material). - UiRoot
- Top-level UI tree. Build it, call
layout, then [render] each frame. - World
- A dimension (
minecraft:overworld): every action whose first field isdim. - YogApi
- Stable C ABI — re-exported so mods don’t need a direct
yog-abidependency. Passed toyog_mod_register: the bus — everything a mod does goes through it (docs/design/bus.md) — and the one thing that can’t afford a message, the frame’s graphics. - YogDimension
Def - A dimension definition — what a mod registers to create a custom
dimension, or to patch an existing (including vanilla) one. Sent as Yog
Data via
Registry::register_dimension(inyog-api); the host registers (or patches) aLevelStem/DimensionTypeentry from it at mod-init time. - YogDimension
Type Def - Properties of a dimension type — mirrors Java’s
YogDimensionType.
Enums§
- Align
- Armor
Slot - Where a piece of armor, or something else worn, is worn.
- Book
Page - One page of an entry:
{"type": "spotlight", "item": "@item:minecraft:stick", …}. - Cooking
- How a cooking recipe cooks.
- Dock
- WinForms-style dock — which edge(s) the widget attaches to inside its parent.
- Entity
Kind - What kind of entity a type is.
- Event
Phase - Whether a handler is running before or after the action.
- Face
- The six block faces, in Minecraft’s
Directionorder, named asyog_ids::directionnames them (a test holds them to it). - Facing
- Which ways a block can turn.
- FlexDir
- Flow
- What a handler decides about an event.
- Focus
Style - How a focused widget shows its focus indicator.
- Placement
- Which way a block turns when placed.
- Recipe
Kind - What a recipe is made of besides its result.
- Stretch
- How an image fills the box it’s given — WPF’s
Stretch. - Units
- A size value — either a fixed pixel amount, a CSS-style percentage of the
parent’s own resolved content size (0.0–100.0), or
Auto(size to content/available space, this crate’s original behaviour).
Constants§
- ABI_
VERSION - Stable C ABI — re-exported so mods don’t need a direct
yog-abidependency.ABI_MAJOR * 10_000 + ABI_MINOR. Checked at mod load time.
Traits§
- Event
- An event the bus carries; its payload is
Selfinyog-data’s binary form. - Into
Flow - What a handler may return: nothing (
Continue), whether to let it happen (falsecancels), or aFlow. - Message
- A message the bus carries; its payload is
Selfas a frame (yog_data::frame: packed by position — both sides have the schema). - Mod
- Implemented by every Yog mod. Called once at startup to register handlers.
- Packet
- A packet’s payload as bytes and back — every
Schematype is one. - Schema
#[derive(Schema)]: a type read and written as Yog Data (stores, packets, frames). A Yog Data format.- Service
- A call the bus carries: its payload is
Self, its answer aService::Reply. - UiHandled
- What a
Registry::register_uihandler returns:()(never marks events as used) orbool(true= the handler used thiskey:/char:event — the host then doesn’t, e.g. Esc doesn’t close the screen).
Functions§
- call
- Calls
request’s provider: its answer,Nonewhen no one answers (a service not on this host, or this mod not registered yet). - call_
export - Calls mod
mod_id’s exportnamewithargs: its answer,Nonewhen it isn’t there (the mod isn’t loaded) or failed. - close_
ui - Close the Yog UI screen showing
ui_id— e.g. from that screen’s own “Done” button. Does nothing when another screen is open. Deferred onto the render thread, so the handler that calls it finishes first. Client side; a no-op on dedicated servers. - emit
- Emits
eventon the bus — a mod’s own event, or the game’s on its behalf; whether no handler cancelled it (before the event, where it can be). - export_
address - Where mod
mod_id’s exportnameis provided:mod_id:name. - format_
translation - Fills Minecraft-style format specifiers in
pattern(what lang files use):%s/%dtake the next argument,%1$s/%2$da numbered one (from 1),%%is a literal%. A specifier without an argument stays as written. - installed_
mods - All installed mods known to the loader: .yog mods plus, where the host
exposes them, platform (Java) mods. Callable at any time after this mod’s
register()ran — including client-side UI handlers. Note that duringregister()mods that load after this one are not in the list yet; query lazily (e.g. on first render) for a complete view. - mod_id
- This mod’s id (its manifest’s), once the runtime has loaded it.
- open_ui
- Open the Yog UI registered as
ui_id(client side; no-op on dedicated servers).modalblocks game input,pausepauses singleplayer. Callable from any handler after registration — e.g. anon_client_packethandler. - split_
state - A block state (
"ns:id[k=v,...]") as its id and its properties. - tag_
name - A tag’s name in the player’s language —
kindthe content’s (item,block,entity,fluid,biome),idthe tag’s (yog:ingots/iron): the translation recipe viewers show (tag.item.yog.ingots.iron), else the id itself. - tr
- The text of translation
keyin the current language, orkeyitself when it has none — what Minecraft shows for an unknown key, so a missing translation is easy to spot. Call it each time the text is shown (e.g. while building a UI tree): the player can switch language at any time. - tr_args
trwith arguments for the text’s format specifiers — seeformat_translation. Thetr!macro is shorter.- translation
- The text of translation
keyin the current language, unformatted —Nonewhen no lang file defines it (or before the mod registered).
Attribute Macros§
- bench
- Inter-mod communication proc-macros.
Marks a function in a mod’s
benches/*.rsas a benchmarkyog benchruns:fn name(b: &mut criterion::Bencher)for one benchmark, orfn name(c: &mut criterion::Criterion)to set up groups. yog generates the file’smain; this only makes the function reachable from it. - yog_
export - Inter-mod communication proc-macros.
- yog_
mirror - Inter-mod communication proc-macros.
Makes a struct a mirror’s row (see
mirror.rs):#[yog_mirror(space = …, owner = "mod")], a field’s fact named by#[fact(…)].
Derive Macros§
- Schema
#[derive(Schema)]: a type read and written as Yog Data (stores, packets, frames).