pub struct Registry { /* private fields */ }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!.
§Safety
api must point to the runtime’s YogApi table, valid for the rest of
the process.
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)
Sourcepub fn on_machine_craft<F>(&mut self, handler: F)
pub fn on_machine_craft<F>(&mut self, handler: F)
A machine making a recipe — see MachineCraftEvent.
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_recipe(&mut self, recipe: Recipe)
pub fn add_recipe(&mut self, recipe: Recipe)
Register a recipe (Yog’s format — see Recipe; the host writes
its Minecraft version’s JSON).
Sourcepub fn add_recipe_json(&mut self, id: &str, json: &str)
pub fn add_recipe_json(&mut self, id: &str, json: &str)
Register a recipe given as Yog’s recipe JSON — how yog build
registers the mod’s own kinds ({"type": "mymod:infusion", "slots": …}), which stay the mod’s data: for its machines and its books.
pub fn register_item(&mut self, def: ItemDef)
pub fn register_block(&mut self, def: BlockDef)
Sourcepub fn add_biome_feature(&mut self, feature: &str, biomes: &str, step: &str)
pub fn add_biome_feature(&mut self, feature: &str, biomes: &str, step: &str)
Add placed feature feature (the mod’s datapack’s, like an ore’s
mymod:mythril_ore) to the biomes of tag biomes at generation
step (underground_ores). An ore .ydef does this for you.
Sourcepub fn register_tool_material(&mut self, material: ToolMaterial)
pub fn register_tool_material(&mut self, material: ToolMaterial)
Register a tool material — what tool items naming it
(ItemDef::tool) are made of. The game’s are built in.
Sourcepub fn register_armor_material(&mut self, material: ArmorMaterial)
pub fn register_armor_material(&mut self, material: ArmorMaterial)
Register an armor material — what armor items naming it
(ItemDef::armor) are made of. The game’s are built in.
Sourcepub fn register_sound_group(&mut self, group: SoundGroup)
pub fn register_sound_group(&mut self, group: SoundGroup)
Register a sound group — what blocks naming it (BlockDef::sound)
sound like. The game’s groups are built in.
Sourcepub fn register_inventory(&mut self, def: InventoryDef)
pub fn register_inventory(&mut self, def: InventoryDef)
Register a real Container/Menu inventory screen — see
yog_inventory::InventoryDef. Attach it to a block via
BlockDef::inventory(id).
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.
Sourcepub fn register_book_data(&mut self, id: &str, data: &[u8])
pub fn register_book_data(&mut self, id: &str, data: &[u8])
Register a book given as Yog Data, binary — what yog build makes
of a content/**/*.ybook; the bytes go to the runtime as they are.
Sourcepub fn register_dimension(&mut self, def: &YogDimensionDef)
pub fn register_dimension(&mut self, def: &YogDimensionDef)
Register (or patch) a dimension’s type (sky, lighting, physics, …).
def.id need not be a new custom id — pass a vanilla id
("minecraft:overworld", "minecraft:the_nether",
"minecraft:the_end") to patch that dimension’s type/generator
instead of creating a new one (e.g. to replace the overworld’s
terrain with your own generator type).
Must be called from register() — the same mod-init window as
blocks/items — so the host can declare/patch the dimension before
Minecraft’s registries freeze. See the yog-dimensions crate docs;
set def.generator_type (via YogDimensionDef::generator_type) to
pick a generator type registered with
Registry::register_chunk_generator.
Sourcepub fn register_dimension_data(&mut self, id: &str, data: &[u8])
pub fn register_dimension_data(&mut self, id: &str, data: &[u8])
Register a dimension given as Yog Data, binary — what yog build
makes of a .ydef of kind dimension (its terrain generated by
the runtime itself); the bytes go to the runtime as they are.
Sourcepub fn register_chunk_generator<F>(
&mut self,
generator_type_id: &str,
generator: F,
)
pub fn register_chunk_generator<F>( &mut self, generator_type_id: &str, generator: F, )
Register a named, reusable chunk-generator type under
generator_type_id (e.g. "mymod:custom_terrain") — analogous to
how Biomes O’Plenty registers selectable world-type presets. Any
dimension (custom or vanilla) can opt into this generator via
YogDimensionDef::generator_type; the platform host may also list
registered generator type ids as options on the world-creation screen.
generator is called once per chunk column that needs generating in
any dimension using this type — write whatever terrain logic you want
using the ChunkWriter handle (combine as many noise layers as you
like; this crate doesn’t prescribe a generation style).
Sourcepub fn installed_mods(&self) -> Vec<ModInfo>
pub fn installed_mods(&self) -> Vec<ModInfo>
Register a menu entry — the host renders a button on vanilla screens
(TitleScreen on Fabric, ModListScreen on Forge/NeoForge) that opens ui_id.
label is the human-readable button text (e.g. “Yog Mods”).
ui_id is the UI to open when clicked (e.g. “example:menu”).
See installed_mods. During register() the list only contains
mods loaded before this one.
Sourcepub fn interop(&self) -> Interop
pub fn interop(&self) -> Interop
Access the inter-mod communication layer.
Allows exporting function pointers from this mod and importing function pointers from other mods.
Sourcepub fn raw_api(&self) -> *const YogApi
pub fn raw_api(&self) -> *const YogApi
Raw YogApi pointer — for passing to interop-imported functions
that register content through the C ABI table directly.
Sourcepub fn register_ui<F, R>(&mut self, ui_id: &str, handler: F)
pub fn register_ui<F, R>(&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) for the screen’s input: click:X:Y,
drag:X:Y, release:X:Y, scroll:DY, key:KEY:MODS (GLFW key code
and modifier bits, on press and repeat) and char:CODEPOINT (a typed
character). It returns () or a bool: true marks a key:/char:
event as used, so the host skips its default handling of the key
(Esc closing the screen, …) — see UiHandled.
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_ui_render<F>(&mut self, ui_id: &str, handler: F)
pub fn on_ui_render<F>(&mut self, ui_id: &str, handler: F)
Register a render callback for a specific UI screen (ui_id).
Called from YogUIScreen.render() — i.e. AFTER renderBackground() darkens
the screen — so your UI draws on top of the dimmed world view.
Use this instead of on_hud_render for book/inventory screens.
Clicks are forwarded as "click:X:Y" via the register_ui handler so you
can do hit-testing on your own stored layout.
Sourcepub fn on_book_page<F>(&mut self, drawer: &str, handler: F)
pub fn on_book_page<F>(&mut self, drawer: &str, handler: F)
Draw the pictures of book pages of type drawn whose drawer is
drawer ("mymod:diagram"): handler gets the page’s data and
the picture’s box [x, y, w, h] in screen pixels, every frame the
page is open.
{ type: "drawn", drawer: "mymod:diagram", title: "Wiring", height: 64,
caption: "{u|in} → {u|out}", text: "…", data: { nodes: 3 } }Sourcepub fn on_item_tooltip<S, D>(&mut self, item: &str, size: S, draw: D)
pub fn on_item_tooltip<S, D>(&mut self, item: &str, size: S, draw: D)
A picture under the tooltips of item (as Hex Casting’s scrolls show
their pattern): size(item, snbt) says whether a stack — its custom
data as SNBT — gets one and its size in GUI pixels; draw draws it
in the box [x, y, w, h] (screen pixels) while the tooltip shows.
Sourcepub fn on_item_text<F>(&mut self, item: &str, text: F)
pub fn on_item_text<F>(&mut self, item: &str, text: F)
A stack’s own name and tooltip, from its custom data (SNBT): text(item, snbt) gives Some((name, lines)) — name None keeps the item’s;
lines stand instead of the item’s description — or None for the
item’s own. A written blueprint names its design:
registry.on_item_text(Items::BLUEPRINT, |_, snbt| {
let bp = Blueprint::from_nbt(snbt)?;
Some((Some(bp.name.clone()), vec![format!("{} ports", bp.ports)]))
});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.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Registry
impl RefUnwindSafe for Registry
impl Unpin for Registry
impl UnsafeUnpin for Registry
impl UnwindSafe for Registry
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.