use std::os::raw::c_void;
pub const ABI_MAJOR: u32 = 1;
pub const ABI_MINOR: u32 = 3;
pub const ABI_VERSION: u32 = ABI_MAJOR * 10_000 + ABI_MINOR;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct YogStr {
pub ptr: *const u8,
pub len: u32,
}
impl YogStr {
pub const EMPTY: Self = Self {
ptr: std::ptr::null(),
len: 0,
};
#[allow(clippy::should_implement_trait)]
#[inline]
pub fn from_str(s: &str) -> Self {
Self {
ptr: s.as_ptr(),
len: s.len() as u32,
}
}
#[inline]
pub fn is_empty(self) -> bool {
self.len == 0 || self.ptr.is_null()
}
#[inline]
pub unsafe fn as_str<'a>(self) -> &'a str {
unsafe {
if self.ptr.is_null() || self.len == 0 {
return "";
}
std::str::from_utf8_unchecked(std::slice::from_raw_parts(self.ptr, self.len as usize))
}
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct YogOwnedStr {
pub ptr: *mut u8,
pub len: u32,
}
impl YogOwnedStr {
pub const NONE: Self = Self {
ptr: std::ptr::null_mut(),
len: 0,
};
pub fn from_string(s: String) -> Self {
let len = s.len() as u32;
let ptr = Box::into_raw(s.into_bytes().into_boxed_slice()) as *mut u8;
Self { ptr, len }
}
#[inline]
pub fn is_none(self) -> bool {
self.ptr.is_null()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct YogBlockPos {
pub x: i32,
pub y: i32,
pub z: i32,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct YogVec3 {
pub x: f64,
pub y: f64,
pub z: f64,
}
#[repr(C)]
pub struct YogBlockBreakEvent {
pub player: YogStr,
pub block: YogStr,
pub pos: YogBlockPos,
pub dimension: YogStr,
}
#[repr(C)]
pub struct YogChatEvent {
pub player: YogStr,
pub message: YogStr,
pub dimension: YogStr,
}
#[repr(C)]
pub struct YogPlayerEvent {
pub player: YogStr,
pub uuid: YogStr,
pub dimension: YogStr,
}
#[repr(C)]
pub struct YogUseItemEvent {
pub player: YogStr,
pub item: YogStr,
pub sneaking: bool,
pub dimension: YogStr,
}
#[repr(C)]
pub struct YogUseBlockEvent {
pub player: YogStr,
pub block: YogStr,
pub pos: YogBlockPos,
pub dimension: YogStr,
}
#[repr(C)]
pub struct YogAttackEntityEvent {
pub player: YogStr,
pub target_type: YogStr,
pub target_uuid: YogStr,
pub dimension: YogStr,
}
#[repr(C)]
pub struct YogEntityDamageEvent {
pub entity_type: YogStr,
pub uuid: YogStr,
pub amount: f32,
pub source: YogStr,
pub dimension: YogStr,
}
#[repr(C)]
pub struct YogEntityDeathEvent {
pub entity_type: YogStr,
pub uuid: YogStr,
pub source: YogStr,
pub dimension: YogStr,
}
#[repr(C)]
pub struct YogEntitySpawnEvent {
pub entity_type: YogStr,
pub uuid: YogStr,
pub dimension: YogStr,
}
#[repr(C)]
pub struct YogPlayerDeathEvent {
pub player: YogStr,
pub uuid: YogStr,
pub source: YogStr,
pub dimension: YogStr,
}
#[repr(C)]
pub struct YogPlayerRespawnEvent {
pub player: YogStr,
pub uuid: YogStr,
pub at_anchor: bool,
pub dimension: YogStr,
}
#[repr(C)]
pub struct YogAdvancementEvent {
pub player: YogStr,
pub uuid: YogStr,
pub advancement: YogStr,
pub dimension: YogStr,
}
#[repr(C)]
pub struct YogEntityInteractEvent {
pub player: YogStr,
pub player_uuid: YogStr,
pub entity_type: YogStr,
pub entity_uuid: YogStr,
pub hand: YogStr,
pub dimension: YogStr,
}
#[repr(C)]
pub struct YogCraftEvent {
pub player: YogStr,
pub player_uuid: YogStr,
pub result_item: YogStr,
pub result_count: u32,
pub dimension: YogStr,
}
#[repr(C)]
pub struct YogExplosionEvent {
pub dimension: YogStr,
pub x: f64,
pub y: f64,
pub z: f64,
pub power: f32,
pub cause_uuid: YogStr,
}
#[repr(C)]
pub struct YogItemPickupEvent {
pub player: YogStr,
pub player_uuid: YogStr,
pub item_id: YogStr,
pub item_count: u32,
pub entity_uuid: YogStr,
pub dimension: YogStr,
}
#[repr(C)]
pub struct YogPlayerMoveEvent {
pub player: YogStr,
pub player_uuid: YogStr,
pub x: f64,
pub y: f64,
pub z: f64,
pub yaw: f32,
pub pitch: f32,
pub dimension: YogStr,
}
#[repr(C)]
pub struct YogContainerOpenEvent {
pub player: YogStr,
pub player_uuid: YogStr,
pub container_type: YogStr,
pub dimension: YogStr,
}
#[repr(C)]
pub struct YogContainerCloseEvent {
pub player: YogStr,
pub player_uuid: YogStr,
pub dimension: YogStr,
}
#[repr(C)]
pub struct YogProjectileHitEvent {
pub projectile_type: YogStr,
pub projectile_uuid: YogStr,
pub shooter_uuid: YogStr,
pub hit_type: YogStr,
pub hit_entity_uuid: YogStr,
pub x: f64,
pub y: f64,
pub z: f64,
pub dimension: YogStr,
}
#[repr(C)]
pub struct YogPlaceBlockEvent {
pub player: YogStr,
pub block: YogStr,
pub pos: YogBlockPos,
pub dimension: YogStr,
}
#[repr(C)]
pub struct YogPacketEvent {
pub channel: YogStr,
pub player: YogStr, pub payload: *const u8,
pub payload_len: u32,
}
#[repr(C)]
pub struct YogCommandEvent {
pub name: YogStr,
pub args: YogStr,
pub source: YogStr,
pub uuid: YogStr,
pub dimension: YogStr,
}
#[repr(C)]
pub struct YogStartupGrantDef {
pub id: YogStr,
pub items: YogStr, pub book: YogStr, pub command: YogStr, }
#[repr(C)]
pub struct YogItemDef {
pub id: YogStr,
pub max_stack: u32,
pub name: YogStr, pub tooltip: YogStr, pub max_damage: u32,
pub fire_resistant: bool,
pub fuel_ticks: u32,
pub food_nutrition: u32, pub food_saturation: f32,
pub food_always_eat: bool,
}
#[repr(C)]
pub struct YogBlockDef {
pub id: YogStr,
pub hardness: f32,
pub resistance: f32,
pub name: YogStr,
pub light_level: u8,
pub sound: YogStr, pub requires_tool: bool,
pub no_collision: bool,
pub slipperiness: f32,
pub shape: [f32; 6],
pub connects: bool,
pub connect_groups: YogStr,
pub inventory_id: YogStr,
pub redstone_source: bool,
}
#[repr(C)]
pub struct YogInventoryDef {
pub id: YogStr,
pub slot_count: u32,
pub layout: YogStr,
pub include_player_inventory: bool,
pub player_inv_x: f32,
pub player_inv_y: f32,
pub background_texture: YogStr,
pub title: YogStr,
pub background_w: f32,
pub background_h: f32,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct YogKeyPressEvent {
pub key_code: i32,
pub scan_code: i32,
pub action: i32,
pub modifiers: i32,
}
pub type YogBlockBreakFn =
unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogBlockBreakEvent, u8) -> bool;
pub type YogChatFn =
unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogChatEvent, u8) -> bool;
pub type YogPlayerFn =
unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerEvent, u8) -> bool;
pub type YogUseItemFn =
unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogUseItemEvent, u8) -> bool;
pub type YogUseBlockFn =
unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogUseBlockEvent, u8) -> bool;
pub type YogAttackEntityFn =
unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogAttackEntityEvent, u8) -> bool;
pub type YogEntityDamageFn =
unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntityDamageEvent, u8) -> bool;
pub type YogEntityDeathFn =
unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntityDeathEvent, u8) -> bool;
pub type YogEntitySpawnFn =
unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntitySpawnEvent, u8) -> bool;
pub type YogPlaceBlockFn =
unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlaceBlockEvent, u8) -> bool;
pub type YogPlayerDeathFn =
unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerDeathEvent, u8) -> bool;
pub type YogPlayerRespawnFn =
unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerRespawnEvent, u8) -> bool;
pub type YogAdvancementFn =
unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogAdvancementEvent, u8) -> bool;
pub type YogEntityInteractFn =
unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntityInteractEvent, u8) -> bool;
pub type YogCraftFn =
unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogCraftEvent, u8) -> bool;
pub type YogExplosionFn =
unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogExplosionEvent, u8) -> bool;
pub type YogItemPickupFn =
unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogItemPickupEvent, u8) -> bool;
pub type YogPlayerMoveFn =
unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerMoveEvent, u8) -> bool;
pub type YogContainerOpenFn =
unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogContainerOpenEvent, u8) -> bool;
pub type YogContainerCloseFn =
unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogContainerCloseEvent, u8) -> bool;
pub type YogProjectileHitFn =
unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogProjectileHitEvent, u8) -> bool;
pub type YogPacketFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPacketEvent);
pub type YogServerFn = unsafe extern "C" fn(*mut c_void, *const YogServer);
pub type YogCommandFn = unsafe extern "C" fn(
ud: *mut c_void,
srv: *const YogServer,
ev: *const YogCommandEvent,
reply_buf: *mut u8,
reply_cap: u32,
reply_len: *mut u32,
);
pub type YogScheduledFn = unsafe extern "C" fn(*mut c_void, *const YogServer);
pub type YogClientFn = unsafe extern "C" fn(ud: *mut c_void);
pub type YogUIEventFn = unsafe extern "C" fn(ud: *mut c_void, ui_id: YogStr, event_id: YogStr);
pub type YogHudRenderFn = unsafe extern "C" fn(ud: *mut c_void, gfx: *const YogGfxApi);
pub type YogWorldRenderFn = unsafe extern "C" fn(ud: *mut c_void, gfx: *const YogGfxApi);
pub type YogKeyPressFn = unsafe extern "C" fn(ud: *mut c_void, ev: *const YogKeyPressEvent) -> bool;
pub type YogScreenFn = unsafe extern "C" fn(ud: *mut c_void, screen_class: YogStr) -> bool;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct YogGfxApi {
pub screen_w: i32,
pub screen_h: i32,
pub delta_tick: f32,
pub scale_factor: f32,
pub view_proj: [f32; 16],
pub camera_pos: [f32; 3],
pub player_pos: [f32; 3],
pub _pad1: f32,
pub buf_create: unsafe extern "C" fn() -> u32,
pub buf_delete: unsafe extern "C" fn(handle: u32),
pub buf_data: unsafe extern "C" fn(handle: u32, bytes: *const u8, len: u32, dynamic: bool),
pub buf_subdata: unsafe extern "C" fn(handle: u32, offset: u32, bytes: *const u8, len: u32),
pub vao_create: unsafe extern "C" fn() -> u32,
pub vao_delete: unsafe extern "C" fn(handle: u32),
pub vao_attrib: unsafe extern "C" fn(
vao: u32,
vbo: u32,
index: u32,
components: u8,
dtype: u8,
normalized: bool,
stride: u32,
offset: u32,
),
pub vao_set_ebo: unsafe extern "C" fn(vao: u32, ebo: u32),
pub prog_create: unsafe extern "C" fn(vert: YogStr, frag: YogStr, out: *mut u32) -> bool,
pub prog_delete: unsafe extern "C" fn(handle: u32),
pub prog_uniform_1i: unsafe extern "C" fn(prog: u32, name: YogStr, v: i32),
pub prog_uniform_1f: unsafe extern "C" fn(prog: u32, name: YogStr, v: f32),
pub prog_uniform_2f: unsafe extern "C" fn(prog: u32, name: YogStr, x: f32, y: f32),
pub prog_uniform_3f: unsafe extern "C" fn(prog: u32, name: YogStr, x: f32, y: f32, z: f32),
pub prog_uniform_4f:
unsafe extern "C" fn(prog: u32, name: YogStr, x: f32, y: f32, z: f32, w: f32),
pub prog_uniform_mat4: unsafe extern "C" fn(prog: u32, name: YogStr, col_major: *const f32),
pub tex_create: unsafe extern "C" fn(w: u32, h: u32, rgba: *const u8, linear: bool) -> u32,
pub tex_delete: unsafe extern "C" fn(handle: u32),
pub tex_bind: unsafe extern "C" fn(unit: u32, handle: u32),
pub tex_from_mc: unsafe extern "C" fn(id: YogStr) -> u32,
pub draw_arrays: unsafe extern "C" fn(vao: u32, prog: u32, mode: u8, first: u32, count: u32),
pub draw_elements:
unsafe extern "C" fn(vao: u32, ebo: u32, prog: u32, mode: u8, count: u32, u32_idx: bool),
pub set_blend: unsafe extern "C" fn(enabled: bool, src: u32, dst: u32),
pub set_depth: unsafe extern "C" fn(test: bool, write: bool),
pub set_scissor: unsafe extern "C" fn(x: i32, y: i32, w: i32, h: i32),
pub clear_scissor: unsafe extern "C" fn(),
pub set_viewport: unsafe extern "C" fn(x: i32, y: i32, w: i32, h: i32),
pub draw2d_rect: unsafe extern "C" fn(x1: f32, y1: f32, x2: f32, y2: f32, color: u32),
pub draw2d_gradient:
unsafe extern "C" fn(x1: f32, y1: f32, x2: f32, y2: f32, top: u32, bottom: u32),
pub draw2d_text: unsafe extern "C" fn(text: YogStr, x: f32, y: f32, color: u32, shadow: bool),
pub draw2d_item: unsafe extern "C" fn(id: YogStr, x: f32, y: f32, size: f32),
pub draw2d_text_font:
unsafe extern "C" fn(text: YogStr, font: YogStr, x: f32, y: f32, color: u32, shadow: bool),
pub text_width: unsafe extern "C" fn(text: YogStr, font: YogStr) -> f32,
pub draw2d_image: unsafe extern "C" fn(
source: YogStr,
x: f32,
y: f32,
w: f32,
h: f32,
u: f32,
v: f32,
uw: f32,
vh: f32,
tint: u32,
),
pub image_size: unsafe extern "C" fn(source: YogStr, w: *mut f32, h: *mut f32) -> bool,
}
unsafe impl Send for YogGfxApi {}
unsafe impl Sync for YogGfxApi {}
#[repr(C)]
pub struct YogServer {
pub ctx: *mut c_void,
pub abi_version: u32,
pub size: u32,
pub free_str: unsafe extern "C" fn(ptr: *mut u8, len: u32),
pub broadcast: unsafe extern "C" fn(ctx: *mut c_void, msg: YogStr),
pub get_block:
unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos) -> YogOwnedStr,
pub set_block: unsafe extern "C" fn(
ctx: *mut c_void,
dim: YogStr,
pos: YogBlockPos,
block: YogStr,
) -> bool,
pub world_time: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, out: *mut i64) -> bool,
pub set_time: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, time: i64) -> bool,
pub is_raining: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr) -> bool,
pub set_weather:
unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, raining: bool, dur: i32) -> bool,
pub give_item:
unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, item: YogStr, count: u32) -> bool,
pub player_teleport:
unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, pos: YogVec3) -> bool,
pub send_to_player: unsafe extern "C" fn(
ctx: *mut c_void,
player: YogStr,
channel: YogStr,
data: *const u8,
len: u32,
) -> bool,
pub send_to_server:
unsafe extern "C" fn(ctx: *mut c_void, channel: YogStr, data: *const u8, len: u32) -> bool,
pub kick_player: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, reason: YogStr) -> bool,
pub set_gamemode: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, mode: YogStr) -> bool,
pub send_title: unsafe extern "C" fn(
ctx: *mut c_void,
player: YogStr,
title: YogStr,
sub: YogStr,
fi: i32,
stay: i32,
fo: i32,
) -> bool,
pub send_actionbar: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, msg: YogStr) -> bool,
pub play_sound: unsafe extern "C" fn(
ctx: *mut c_void,
dim: YogStr,
pos: YogVec3,
sound: YogStr,
vol: f32,
pitch: f32,
) -> bool,
pub play_sound_player: unsafe extern "C" fn(
ctx: *mut c_void,
player: YogStr,
sound: YogStr,
vol: f32,
pitch: f32,
) -> bool,
pub entity_teleport: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, pos: YogVec3) -> bool,
pub entity_position:
unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut YogVec3) -> bool,
pub entity_health: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut f32) -> bool,
pub entity_set_health: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, hp: f32) -> bool,
pub entity_kill: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> bool,
pub spawn_entity: unsafe extern "C" fn(
ctx: *mut c_void,
type_id: YogStr,
dim: YogStr,
pos: YogVec3,
) -> YogOwnedStr,
pub entity_add_effect: unsafe extern "C" fn(
ctx: *mut c_void,
uuid: YogStr,
fx: YogStr,
dur: i32,
amp: u8,
particles: bool,
) -> bool,
pub entity_remove_effect:
unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, fx: YogStr) -> bool,
pub entity_clear_effects: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> bool,
pub entity_velocity:
unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut YogVec3) -> bool,
pub entity_set_velocity:
unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, vel: YogVec3) -> bool,
pub entity_add_velocity:
unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, vel: YogVec3) -> bool,
pub has_item_tag: unsafe extern "C" fn(ctx: *mut c_void, item: YogStr, tag: YogStr) -> bool,
pub has_block_tag: unsafe extern "C" fn(ctx: *mut c_void, block: YogStr, tag: YogStr) -> bool,
pub drop_loot:
unsafe extern "C" fn(ctx: *mut c_void, table: YogStr, dim: YogStr, pos: YogVec3) -> bool,
pub scoreboard_get:
unsafe extern "C" fn(ctx: *mut c_void, obj: YogStr, player: YogStr, out: *mut i32) -> bool,
pub scoreboard_set:
unsafe extern "C" fn(ctx: *mut c_void, obj: YogStr, player: YogStr, score: i32) -> bool,
pub scoreboard_add: unsafe extern "C" fn(
ctx: *mut c_void,
obj: YogStr,
player: YogStr,
delta: i32,
out: *mut i32,
) -> bool,
pub bossbar_create: unsafe extern "C" fn(
ctx: *mut c_void,
id: YogStr,
title: YogStr,
color: YogStr,
style: YogStr,
) -> bool,
pub bossbar_remove: unsafe extern "C" fn(ctx: *mut c_void, id: YogStr) -> bool,
pub bossbar_set_title:
unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, title: YogStr) -> bool,
pub bossbar_set_progress:
unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, progress: f32) -> bool,
pub bossbar_set_color:
unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, color: YogStr) -> bool,
pub bossbar_add_player:
unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, player: YogStr) -> bool,
pub bossbar_remove_player:
unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, player: YogStr) -> bool,
pub bossbar_set_visible:
unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, visible: bool) -> bool,
pub game_dir: unsafe extern "C" fn(ctx: *mut c_void) -> YogOwnedStr,
pub online_players: unsafe extern "C" fn(ctx: *mut c_void) -> YogOwnedStr,
pub get_block_nbt:
unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos) -> YogOwnedStr,
pub set_block_nbt:
unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos, snbt: YogStr) -> bool,
pub player_inventory: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr) -> YogOwnedStr,
pub player_set_slot: unsafe extern "C" fn(
ctx: *mut c_void,
player: YogStr,
slot: u32,
item_id: YogStr,
count: u32,
) -> bool,
pub get_inventory_slot: unsafe extern "C" fn(
ctx: *mut c_void,
dim: YogStr,
pos: YogBlockPos,
slot: u32,
) -> YogOwnedStr,
pub set_inventory_slot: unsafe extern "C" fn(
ctx: *mut c_void,
dim: YogStr,
pos: YogBlockPos,
slot: u32,
item_id: YogStr,
count: u32,
) -> bool,
pub player_teleport_dim:
unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, dim: YogStr, pos: YogVec3) -> bool,
pub entity_teleport_dim:
unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, dim: YogStr, pos: YogVec3) -> bool,
pub world_entity_count:
unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, entity_type: YogStr) -> i32,
pub entity_get_nbt: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> YogOwnedStr,
pub entity_set_nbt: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, snbt: YogStr) -> bool,
pub spawn_particles: unsafe extern "C" fn(
ctx: *mut c_void,
dim: YogStr,
pos: YogVec3,
particle_type: YogStr,
count: i32,
dx: f64,
dy: f64,
dz: f64,
speed: f64,
) -> bool,
pub entity_attribute_get:
unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, attribute_id: YogStr) -> f64,
pub entity_attribute_set: unsafe extern "C" fn(
ctx: *mut c_void,
uuid: YogStr,
attribute_id: YogStr,
value: f64,
) -> bool,
pub get_held_item_nbt: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr) -> YogOwnedStr,
pub set_held_item_nbt:
unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, snbt: YogStr) -> bool,
pub get_offhand_item_nbt: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr) -> YogOwnedStr,
pub set_offhand_item_nbt:
unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, snbt: YogStr) -> bool,
pub get_slot_item:
unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, slot: u32) -> YogOwnedStr,
pub set_slot_item: unsafe extern "C" fn(
ctx: *mut c_void,
player: YogStr,
slot: u32,
item_id: YogStr,
count: u32,
snbt: YogStr,
) -> bool,
pub entity_rotation:
unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut YogVec3) -> bool,
pub entity_info: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> YogOwnedStr,
pub entities_in_box: unsafe extern "C" fn(
ctx: *mut c_void,
dim: YogStr,
min: YogVec3,
max: YogVec3,
) -> YogOwnedStr,
pub raycast_block: unsafe extern "C" fn(
ctx: *mut c_void,
dim: YogStr,
from: YogVec3,
to: YogVec3,
) -> YogOwnedStr,
pub raycast_entity: unsafe extern "C" fn(
ctx: *mut c_void,
dim: YogStr,
from: YogVec3,
to: YogVec3,
exclude: YogStr,
) -> YogOwnedStr,
pub block_info:
unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos) -> YogOwnedStr,
pub break_block: unsafe extern "C" fn(
ctx: *mut c_void,
dim: YogStr,
pos: YogBlockPos,
drop: bool,
breaker: YogStr,
) -> bool,
pub place_block_from_slot: unsafe extern "C" fn(
ctx: *mut c_void,
player: YogStr,
slot: u32,
dim: YogStr,
pos: YogBlockPos,
) -> bool,
pub bonemeal: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos) -> bool,
pub explode: unsafe extern "C" fn(
ctx: *mut c_void,
dim: YogStr,
pos: YogVec3,
power: f32,
fire: bool,
source: YogStr,
) -> bool,
pub tellraw: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, json: YogStr) -> bool,
pub entity_damage: unsafe extern "C" fn(
ctx: *mut c_void,
uuid: YogStr,
amount: f32,
damage_type: YogStr,
attacker: YogStr,
) -> bool,
pub entity_set_fire_ticks:
unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, ticks: i32) -> bool,
pub player_add_xp: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, amount: i32) -> bool,
pub player_set_may_fly:
unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, may_fly: bool) -> bool,
pub player_info: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr) -> YogOwnedStr,
pub spawn_item: unsafe extern "C" fn(
ctx: *mut c_void,
dim: YogStr,
pos: YogVec3,
vel: YogVec3,
item_id: YogStr,
count: u32,
snbt: YogStr,
) -> YogOwnedStr,
pub item_entity_stack: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> YogOwnedStr,
pub item_entity_set_stack: unsafe extern "C" fn(
ctx: *mut c_void,
uuid: YogStr,
item_id: YogStr,
count: u32,
snbt: YogStr,
) -> bool,
pub actionbar_json:
unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, json: YogStr) -> bool,
pub use_item_on_block: unsafe extern "C" fn(
ctx: *mut c_void,
dim: YogStr,
pos: YogBlockPos,
face: u8,
item_id: YogStr,
player: YogStr,
) -> bool,
pub pour_fluid: unsafe extern "C" fn(
ctx: *mut c_void,
dim: YogStr,
pos: YogBlockPos,
bucket_item_id: YogStr,
) -> bool,
pub has_entity_tag:
unsafe extern "C" fn(ctx: *mut c_void, entity_type: YogStr, tag_id: YogStr) -> bool,
pub item_block: unsafe extern "C" fn(ctx: *mut c_void, item_id: YogStr) -> YogOwnedStr,
pub place_feature: unsafe extern "C" fn(
ctx: *mut c_void,
dim: YogStr,
pos: YogBlockPos,
feature_id: YogStr,
) -> bool,
pub set_item_cooldown:
unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, item_id: YogStr, ticks: i32) -> bool,
pub entity_teleport_with_passengers:
unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, dim: YogStr, pos: YogVec3) -> bool,
pub redstone_power: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos) -> i32,
pub set_redstone_output:
unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos, level: i32) -> bool,
pub get_block_state: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos) -> YogOwnedStr,
pub set_block_state:
unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos, state: YogStr) -> bool,
pub world_is_thundering: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr) -> bool,
pub world_set_thunder:
unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, thundering: bool, duration_ticks: i32) -> bool,
pub fill_region: unsafe extern "C" fn(
ctx: *mut c_void,
dim: YogStr,
from: YogBlockPos,
to: YogBlockPos,
state: YogStr,
) -> i32,
pub scan_region:
unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, from: YogBlockPos, to: YogBlockPos) -> YogOwnedStr,
}
unsafe impl Send for YogServer {}
unsafe impl Sync for YogServer {}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct YogChunkWriterApi {
pub chunk_x: i32,
pub chunk_z: i32,
pub min_y: i32,
pub height: i32,
pub ctx: *mut c_void,
pub set_block:
unsafe extern "C" fn(ctx: *mut c_void, x: i32, y: i32, z: i32, block_id: YogStr) -> bool,
}
unsafe impl Send for YogChunkWriterApi {}
unsafe impl Sync for YogChunkWriterApi {}
pub type YogChunkGeneratorFn =
unsafe extern "C" fn(ud: *mut c_void, writer: *const YogChunkWriterApi);
#[repr(C)]
pub struct YogApi {
pub abi_version: u32,
pub size: u32,
pub ctx: *mut c_void,
pub server: *const YogServer,
pub on_block_break: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogBlockBreakFn),
pub on_chat: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogChatFn),
pub on_player_join: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerFn),
pub on_player_leave: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerFn),
pub on_use_item: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogUseItemFn),
pub on_use_block: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogUseBlockFn),
pub on_attack_entity:
unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogAttackEntityFn),
pub on_entity_damage:
unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntityDamageFn),
pub on_entity_death:
unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntityDeathFn),
pub on_entity_spawn:
unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntitySpawnFn),
pub on_player_place_block:
unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlaceBlockFn),
pub on_player_death:
unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerDeathFn),
pub on_player_respawn:
unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerRespawnFn),
pub on_advancement:
unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogAdvancementFn),
pub on_entity_interact:
unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntityInteractFn),
pub on_item_craft: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogCraftFn),
pub on_explosion: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogExplosionFn),
pub on_item_pickup: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogItemPickupFn),
pub on_player_move: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerMoveFn),
pub on_container_open:
unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogContainerOpenFn),
pub on_container_close:
unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogContainerCloseFn),
pub on_projectile_hit:
unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogProjectileHitFn),
pub on_server_tick: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogServerFn),
pub on_server_started: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogServerFn),
pub on_server_stopping: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogServerFn),
pub on_packet:
unsafe extern "C" fn(ctx: *mut c_void, channel: YogStr, ud: *mut c_void, h: YogPacketFn),
pub on_client_packet:
unsafe extern "C" fn(ctx: *mut c_void, channel: YogStr, ud: *mut c_void, h: YogPacketFn),
pub register_command:
unsafe extern "C" fn(ctx: *mut c_void, name: YogStr, ud: *mut c_void, h: YogCommandFn),
pub register_typed_command: unsafe extern "C" fn(
ctx: *mut c_void,
name: YogStr,
schema: YogStr,
ud: *mut c_void,
h: YogCommandFn,
),
pub register_recipe_json:
unsafe extern "C" fn(ctx: *mut c_void, namespace: YogStr, name: YogStr, json: YogStr),
pub register_item: unsafe extern "C" fn(ctx: *mut c_void, def: *const YogItemDef),
pub register_block: unsafe extern "C" fn(ctx: *mut c_void, def: *const YogBlockDef),
pub schedule_once: unsafe extern "C" fn(
ctx: *mut c_void,
delay_ticks: u64,
ud: *mut c_void,
h: YogScheduledFn,
),
pub schedule_repeating: unsafe extern "C" fn(
ctx: *mut c_void,
period_ticks: u64,
ud: *mut c_void,
h: YogScheduledFn,
),
pub on_client_tick: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogClientFn),
pub on_hud_render: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogHudRenderFn),
pub on_key_press: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogKeyPressFn),
pub on_screen_open: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogScreenFn),
pub on_screen_close: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogScreenFn),
pub on_world_render:
unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogWorldRenderFn),
pub register_startup_grant:
unsafe extern "C" fn(ctx: *mut c_void, grant: *const YogStartupGrantDef),
pub register_book: unsafe extern "C" fn(ctx: *mut c_void, book_id: YogStr, book_json: YogStr),
pub register_ui: unsafe extern "C" fn(
ctx: *mut c_void,
ui_id: YogStr,
layout_json: YogStr,
ud: *mut c_void,
h: YogUIEventFn,
),
pub on_ui_render:
unsafe extern "C" fn(ctx: *mut c_void, ui_id: YogStr, ud: *mut c_void, h: YogHudRenderFn),
pub register_menu_entry: unsafe extern "C" fn(ctx: *mut c_void, label: YogStr, ui_id: YogStr),
pub mods_list: unsafe extern "C" fn(ctx: *mut c_void) -> YogOwnedStr,
pub free_str: unsafe extern "C" fn(ptr: *mut u8, len: u32),
pub ui_open: unsafe extern "C" fn(ctx: *mut c_void, ui_id: YogStr, modal: bool, pause: bool),
pub register_inventory: unsafe extern "C" fn(ctx: *mut c_void, def: *const YogInventoryDef),
pub interop_export:
unsafe extern "C" fn(ctx: *mut c_void, mod_id: YogStr, symbol: YogStr, ptr: *const c_void),
pub interop_import:
unsafe extern "C" fn(ctx: *mut c_void, mod_id: YogStr, symbol: YogStr) -> *const c_void,
pub register_dimension_json: unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, json: YogStr),
pub register_chunk_generator:
unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, ud: *mut c_void, h: YogChunkGeneratorFn),
pub ui_close: unsafe extern "C" fn(ctx: *mut c_void, ui_id: YogStr),
pub ui_consume_event: unsafe extern "C" fn(ctx: *mut c_void),
pub translate: unsafe extern "C" fn(ctx: *mut c_void, key: YogStr) -> YogOwnedStr,
pub ui_open_flags: unsafe extern "C" fn(ctx: *mut c_void, ui_id: YogStr, flags: u32),
pub client_play_sound: unsafe extern "C" fn(
ctx: *mut c_void,
sound_id: YogStr,
volume: f32,
pitch: f32,
looping: bool,
) -> u32,
pub client_stop_sound: unsafe extern "C" fn(ctx: *mut c_void, handle: u32),
pub client_held_item: unsafe extern "C" fn(ctx: *mut c_void, off_hand: bool) -> YogOwnedStr,
pub client_key_down: unsafe extern "C" fn(ctx: *mut c_void, key: i32) -> bool,
}
pub mod ui_flags {
pub const MODAL: u32 = 1;
pub const PAUSE: u32 = 1 << 1;
pub const NO_BACKGROUND: u32 = 1 << 2;
}
unsafe impl Send for YogApi {}
unsafe impl Sync for YogApi {}