Skip to main content

YogApi

Struct YogApi 

Source
#[repr(C)]
pub struct YogApi {
Show 47 fields pub abi_version: u32, pub size: u32, pub ctx: *mut c_void, pub server: *const YogServer, pub on_block_break: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogBlockBreakEvent, u8) -> bool), pub on_chat: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogChatEvent, u8) -> bool), pub on_player_join: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerEvent, u8) -> bool), pub on_player_leave: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerEvent, u8) -> bool), pub on_use_item: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogUseItemEvent, u8) -> bool), pub on_use_block: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogUseBlockEvent, u8) -> bool), pub on_attack_entity: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogAttackEntityEvent, u8) -> bool), pub on_entity_damage: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntityDamageEvent, u8) -> bool), pub on_entity_death: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntityDeathEvent, u8) -> bool), pub on_entity_spawn: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntitySpawnEvent, u8) -> bool), pub on_player_place_block: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlaceBlockEvent, u8) -> bool), pub on_player_death: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerDeathEvent, u8) -> bool), pub on_player_respawn: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerRespawnEvent, u8) -> bool), pub on_advancement: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogAdvancementEvent, u8) -> bool), pub on_entity_interact: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntityInteractEvent, u8) -> bool), pub on_item_craft: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogCraftEvent, u8) -> bool), pub on_explosion: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogExplosionEvent, u8) -> bool), pub on_item_pickup: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogItemPickupEvent, u8) -> bool), pub on_player_move: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerMoveEvent, u8) -> bool), pub on_container_open: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogContainerOpenEvent, u8) -> bool), pub on_container_close: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogContainerCloseEvent, u8) -> bool), pub on_projectile_hit: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogProjectileHitEvent, u8) -> bool), pub on_server_tick: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer)), pub on_server_started: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer)), pub on_server_stopping: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer)), pub on_packet: unsafe extern "C" fn(*mut c_void, YogStr, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPacketEvent)), pub on_client_packet: unsafe extern "C" fn(*mut c_void, YogStr, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPacketEvent)), pub register_command: unsafe extern "C" fn(*mut c_void, YogStr, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogCommandEvent, *mut u8, u32, *mut u32)), pub register_typed_command: unsafe extern "C" fn(*mut c_void, YogStr, YogStr, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogCommandEvent, *mut u8, u32, *mut u32)), pub register_recipe_json: unsafe extern "C" fn(*mut c_void, YogStr, YogStr, YogStr), pub register_item: unsafe extern "C" fn(*mut c_void, *const YogItemDef), pub register_block: unsafe extern "C" fn(*mut c_void, *const YogBlockDef), pub schedule_once: unsafe extern "C" fn(*mut c_void, u64, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer)), pub schedule_repeating: unsafe extern "C" fn(*mut c_void, u64, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer)), pub on_client_tick: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void)), pub on_hud_render: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogGfxApi)), pub on_key_press: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogKeyPressEvent) -> bool), pub on_screen_open: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, YogStr) -> bool), pub on_screen_close: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, YogStr) -> bool), pub on_world_render: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogGfxApi)), pub register_startup_grant: unsafe extern "C" fn(*mut c_void, *const YogStartupGrantDef), pub register_book: unsafe extern "C" fn(*mut c_void, YogStr, YogStr), pub register_ui: unsafe extern "C" fn(*mut c_void, YogStr, YogStr, *mut c_void, unsafe extern "C" fn(*mut c_void, YogStr, YogStr)),
}
Expand description

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.

When mods compiled against ABI N load on a runtime with ABI M > N: fields beyond size are not present in the mod’s view — check size before accessing fields added in later minor versions.

Fields§

§abi_version: u32§size: u32

sizeof(YogApi) at the runtime’s build time.

§ctx: *mut c_void

Opaque pointer to runtime handler storage.

§server: *const YogServer

Stable server action table — pass to handlers.

§on_block_break: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogBlockBreakEvent, u8) -> bool)§on_chat: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogChatEvent, u8) -> bool)§on_player_join: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerEvent, u8) -> bool)§on_player_leave: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerEvent, u8) -> bool)§on_use_item: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogUseItemEvent, u8) -> bool)§on_use_block: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogUseBlockEvent, u8) -> bool)§on_attack_entity: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogAttackEntityEvent, u8) -> bool)§on_entity_damage: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntityDamageEvent, u8) -> bool)§on_entity_death: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntityDeathEvent, u8) -> bool)§on_entity_spawn: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntitySpawnEvent, u8) -> bool)§on_player_place_block: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlaceBlockEvent, u8) -> bool)§on_player_death: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerDeathEvent, u8) -> bool)§on_player_respawn: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerRespawnEvent, u8) -> bool)§on_advancement: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogAdvancementEvent, u8) -> bool)§on_entity_interact: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntityInteractEvent, u8) -> bool)§on_item_craft: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogCraftEvent, u8) -> bool)§on_explosion: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogExplosionEvent, u8) -> bool)§on_item_pickup: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogItemPickupEvent, u8) -> bool)§on_player_move: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerMoveEvent, u8) -> bool)§on_container_open: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogContainerOpenEvent, u8) -> bool)§on_container_close: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogContainerCloseEvent, u8) -> bool)§on_projectile_hit: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogProjectileHitEvent, u8) -> bool)§on_server_tick: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer))§on_server_started: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer))§on_server_stopping: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer))§on_packet: unsafe extern "C" fn(*mut c_void, YogStr, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPacketEvent))§on_client_packet: unsafe extern "C" fn(*mut c_void, YogStr, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPacketEvent))§register_command: unsafe extern "C" fn(*mut c_void, YogStr, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogCommandEvent, *mut u8, u32, *mut u32))§register_typed_command: unsafe extern "C" fn(*mut c_void, YogStr, YogStr, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogCommandEvent, *mut u8, u32, *mut u32))§register_recipe_json: unsafe extern "C" fn(*mut c_void, YogStr, YogStr, YogStr)

Register a recipe by supplying Minecraft JSON (data/ format). namespace + name form the file path: data/{ns}/recipes/{name}.json.

§register_item: unsafe extern "C" fn(*mut c_void, *const YogItemDef)§register_block: unsafe extern "C" fn(*mut c_void, *const YogBlockDef)§schedule_once: unsafe extern "C" fn(*mut c_void, u64, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer))§schedule_repeating: unsafe extern "C" fn(*mut c_void, u64, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogServer))§on_client_tick: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void))§on_hud_render: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogGfxApi))§on_key_press: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogKeyPressEvent) -> bool)§on_screen_open: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, YogStr) -> bool)§on_screen_close: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, YogStr) -> bool)§on_world_render: unsafe extern "C" fn(*mut c_void, *mut c_void, unsafe extern "C" fn(*mut c_void, *const YogGfxApi))

Register a handler that fires after world geometry is rendered. gfx.view_proj and gfx.camera_pos are filled; use them to project custom 3D geometry into clip space.

§register_startup_grant: unsafe extern "C" fn(*mut c_void, *const YogStartupGrantDef)§register_book: unsafe extern "C" fn(*mut c_void, YogStr, YogStr)§register_ui: unsafe extern "C" fn(*mut c_void, YogStr, YogStr, *mut c_void, unsafe extern "C" fn(*mut c_void, YogStr, YogStr))

Register a UI tree. ui_id is the unique identifier (e.g. “mymod:menu”). layout_json is the serialized layout tree. handler is called when an interactive element is clicked/keyed.

Trait Implementations§

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.