pub struct Registry { /* private fields */ }Expand description
Wraps the YogApi table and provides an ergonomic registration API.
Obtained inside yog_mod_register via export_mod!. Closures registered
here are boxed and leaked — they live as long as the process (which is the
correct lifetime for a server mod).
Implementations§
Source§impl Registry
impl Registry
Sourcepub unsafe fn from_raw(api: *const YogApi) -> Self
pub unsafe fn from_raw(api: *const YogApi) -> Self
Build from the pointer passed by the runtime. Only called by export_mod!.
pub fn on_block_break<F>(&mut self, handler: F)
pub fn on_chat<F>(&mut self, handler: F)
pub fn on_player_join<F>(&mut self, handler: F)
pub fn on_player_leave<F>(&mut self, handler: F)
pub fn on_use_item<F>(&mut self, handler: F)
pub fn on_use_block<F>(&mut self, handler: F)
pub fn on_attack_entity<F>(&mut self, handler: F)
pub fn on_entity_damage<F>(&mut self, handler: F)
pub fn on_entity_death<F>(&mut self, handler: F)
pub fn on_entity_spawn<F>(&mut self, handler: F)
pub fn on_player_place_block<F>(&mut self, handler: F)
pub fn on_player_death<F>(&mut self, handler: F)
pub fn on_player_respawn<F>(&mut self, handler: F)
pub fn on_advancement<F>(&mut self, handler: F)
pub fn on_entity_interact<F>(&mut self, handler: F)
pub fn on_item_craft<F>(&mut self, handler: F)
pub fn on_explosion<F>(&mut self, handler: F)
pub fn on_item_pickup<F>(&mut self, handler: F)
pub fn on_player_move<F>(&mut self, handler: F)
pub fn on_container_open<F>(&mut self, handler: F)
pub fn on_container_close<F>(&mut self, handler: F)
pub fn on_projectile_hit<F>(&mut self, handler: F)
pub fn on_tick<F>(&mut self, listener: F)
pub fn on_server_started<F>(&mut self, listener: F)
pub fn on_server_stopping<F>(&mut self, listener: F)
pub fn on_command<F>(&mut self, name: impl AsRef<str>, handler: F)
Sourcepub fn on_typed_command<F>(
&mut self,
name: impl AsRef<str>,
schema: impl AsRef<str>,
handler: F,
)
pub fn on_typed_command<F>( &mut self, name: impl AsRef<str>, schema: impl AsRef<str>, handler: F, )
Register a command with Brigadier-typed arguments.
schema is a space-separated list of argument types:
int, float, word, string (greedy, must be last), player, blockpos.
In the handler use ctx.arg_int(0), ctx.arg_blockpos(1), etc.
pub fn on_packet<F>(&mut self, channel: impl AsRef<str>, handler: F)
pub fn on_client_packet<F>(&mut self, channel: impl AsRef<str>, handler: F)
Sourcepub fn on_typed_packet<P, F>(&mut self, channel: impl AsRef<str>, handler: F)
pub fn on_typed_packet<P, F>(&mut self, channel: impl AsRef<str>, handler: F)
Register a typed-packet handler.
The payload is decoded from raw bytes using P’s Packet impl.
Malformed payloads are silently dropped.
Sourcepub fn add_shaped_recipe(&mut self, recipe: ShapedRecipe)
pub fn add_shaped_recipe(&mut self, recipe: ShapedRecipe)
Register a shaped crafting recipe.
Sourcepub fn add_shapeless_recipe(&mut self, recipe: ShapelessRecipe)
pub fn add_shapeless_recipe(&mut self, recipe: ShapelessRecipe)
Register a shapeless crafting recipe.
Sourcepub fn add_furnace_recipe(&mut self, recipe: FurnaceRecipe)
pub fn add_furnace_recipe(&mut self, recipe: FurnaceRecipe)
Register a furnace smelting recipe.
pub fn register_item(&mut self, def: ItemDef)
pub fn register_block(&mut self, def: BlockDef)
Sourcepub fn register_startup_grant(&mut self, grant: StartupGrant)
pub fn register_startup_grant(&mut self, grant: StartupGrant)
Register a startup grant: items/books to give once when a player first joins.
Sourcepub fn register_book(&mut self, book: &Book)
pub fn register_book(&mut self, book: &Book)
Register a book with its JSON-serialized content.
Sourcepub fn register_ui<F>(&mut self, ui_id: &str, handler: F)
pub fn register_ui<F>(&mut self, ui_id: &str, handler: F)
Register a UI tree with an event callback.
ui_id is the unique identifier (e.g. “mymod:menu”).
handler receives (ui_id, event_id) when a widget is clicked.
pub fn schedule_once<F>(&self, delay_ticks: u64, handler: F)
pub fn schedule_repeating<F>(&self, period_ticks: u64, handler: F)
Sourcepub fn on_client_tick<F>(&mut self, handler: F)
pub fn on_client_tick<F>(&mut self, handler: F)
Register a handler called every client tick (render thread, no server).
Sourcepub fn on_hud_render<F>(&mut self, handler: F)
pub fn on_hud_render<F>(&mut self, handler: F)
Register a handler called every frame when the HUD is rendered.
gfx provides full GPU pipeline access plus 2D convenience draw calls.
view_proj and camera_pos are zero in HUD context; use gfx.draw2d() for HUD elements.
Sourcepub fn on_world_render<F>(&mut self, handler: F)
pub fn on_world_render<F>(&mut self, handler: F)
Register a handler called every frame at the end of world rendering.
gfx.view_proj() is the combined projection × view matrix (camera-relative).
gfx.camera_pos() is the camera world position.
To render at world position P, translate by P - camera_pos before drawing.
Sourcepub fn on_key_press<F>(&mut self, handler: F)
pub fn on_key_press<F>(&mut self, handler: F)
Register a handler for keyboard input (client-side).
Return false to prevent Minecraft from processing the key.
Sourcepub fn on_screen_open<F>(&mut self, handler: F)
pub fn on_screen_open<F>(&mut self, handler: F)
Register a handler called when a GUI screen is opened.
Sourcepub fn on_screen_close<F>(&mut self, handler: F)
pub fn on_screen_close<F>(&mut self, handler: F)
Register a handler called when a GUI screen is closed.