1use std::os::raw::c_void;
13
14pub const ABI_MAJOR: u32 = 0;
17pub const ABI_MINOR: u32 = 15;
18pub const ABI_VERSION: u32 = ABI_MAJOR * 10_000 + ABI_MINOR;
20
21#[repr(C)]
26#[derive(Copy, Clone)]
27pub struct YogStr {
28 pub ptr: *const u8,
29 pub len: u32,
30}
31
32impl YogStr {
33 pub const EMPTY: Self = Self { ptr: std::ptr::null(), len: 0 };
34
35 #[inline]
36 pub fn from_str(s: &str) -> Self {
37 Self { ptr: s.as_ptr(), len: s.len() as u32 }
38 }
39
40 #[inline]
41 pub fn is_empty(self) -> bool { self.len == 0 || self.ptr.is_null() }
42
43 #[inline]
46 pub unsafe fn as_str<'a>(self) -> &'a str {
47 if self.ptr.is_null() || self.len == 0 {
48 return "";
49 }
50 std::str::from_utf8_unchecked(std::slice::from_raw_parts(self.ptr, self.len as usize))
51 }
52}
53
54#[repr(C)]
58#[derive(Copy, Clone)]
59pub struct YogOwnedStr {
60 pub ptr: *mut u8,
61 pub len: u32,
62}
63
64impl YogOwnedStr {
65 pub const NONE: Self = Self { ptr: std::ptr::null_mut(), len: 0 };
66
67 pub fn from_string(s: String) -> Self {
69 let len = s.len() as u32;
70 let ptr = Box::into_raw(s.into_bytes().into_boxed_slice()) as *mut u8;
71 Self { ptr, len }
72 }
73
74 #[inline]
75 pub fn is_none(self) -> bool { self.ptr.is_null() }
76}
77
78#[repr(C)]
80#[derive(Copy, Clone)]
81pub struct YogBlockPos {
82 pub x: i32,
83 pub y: i32,
84 pub z: i32,
85}
86
87#[repr(C)]
89#[derive(Copy, Clone)]
90pub struct YogVec3 {
91 pub x: f64,
92 pub y: f64,
93 pub z: f64,
94}
95
96#[repr(C)]
99pub struct YogBlockBreakEvent {
100 pub player: YogStr,
101 pub block: YogStr,
102 pub pos: YogBlockPos,
103}
104
105#[repr(C)]
106pub struct YogChatEvent {
107 pub player: YogStr,
108 pub message: YogStr,
109}
110
111#[repr(C)]
113pub struct YogPlayerEvent {
114 pub player: YogStr,
115 pub uuid: YogStr,
116}
117
118#[repr(C)]
119pub struct YogUseItemEvent {
120 pub player: YogStr,
121 pub item: YogStr,
122}
123
124#[repr(C)]
125pub struct YogUseBlockEvent {
126 pub player: YogStr,
127 pub block: YogStr,
128 pub pos: YogBlockPos,
129}
130
131#[repr(C)]
132pub struct YogAttackEntityEvent {
133 pub player: YogStr,
134 pub target_type: YogStr,
135 pub target_uuid: YogStr,
136}
137
138#[repr(C)]
139pub struct YogEntityDamageEvent {
140 pub entity_type: YogStr,
141 pub uuid: YogStr,
142 pub amount: f32,
143 pub source: YogStr,
144}
145
146#[repr(C)]
147pub struct YogEntityDeathEvent {
148 pub entity_type: YogStr,
149 pub uuid: YogStr,
150 pub source: YogStr,
151}
152
153#[repr(C)]
154pub struct YogEntitySpawnEvent {
155 pub entity_type: YogStr,
156 pub uuid: YogStr,
157 pub dimension: YogStr,
158}
159
160#[repr(C)]
163pub struct YogPlayerDeathEvent {
164 pub player: YogStr,
165 pub uuid: YogStr,
166 pub source: YogStr,
168}
169
170#[repr(C)]
172pub struct YogPlayerRespawnEvent {
173 pub player: YogStr,
174 pub uuid: YogStr,
175 pub at_anchor: bool,
177}
178
179#[repr(C)]
181pub struct YogAdvancementEvent {
182 pub player: YogStr,
183 pub uuid: YogStr,
184 pub advancement: YogStr,
186}
187
188#[repr(C)]
191pub struct YogEntityInteractEvent {
192 pub player: YogStr,
193 pub player_uuid: YogStr,
194 pub entity_type: YogStr,
195 pub entity_uuid: YogStr,
196 pub hand: YogStr,
198}
199
200#[repr(C)]
202pub struct YogCraftEvent {
203 pub player: YogStr,
204 pub player_uuid: YogStr,
205 pub result_item: YogStr,
206 pub result_count: u32,
207}
208
209#[repr(C)]
212pub struct YogExplosionEvent {
213 pub dimension: YogStr,
214 pub x: f64,
215 pub y: f64,
216 pub z: f64,
217 pub power: f32,
218 pub cause_uuid: YogStr,
220}
221
222#[repr(C)]
226pub struct YogItemPickupEvent {
227 pub player: YogStr,
228 pub player_uuid: YogStr,
229 pub item_id: YogStr,
231 pub item_count: u32,
232 pub entity_uuid: YogStr,
234}
235
236#[repr(C)]
238pub struct YogPlayerMoveEvent {
239 pub player: YogStr,
240 pub player_uuid: YogStr,
241 pub x: f64,
242 pub y: f64,
243 pub z: f64,
244 pub yaw: f32,
245 pub pitch: f32,
246}
247
248#[repr(C)]
252pub struct YogContainerOpenEvent {
253 pub player: YogStr,
254 pub player_uuid: YogStr,
255 pub container_type: YogStr,
256}
257
258#[repr(C)]
260pub struct YogContainerCloseEvent {
261 pub player: YogStr,
262 pub player_uuid: YogStr,
263}
264
265#[repr(C)]
268pub struct YogProjectileHitEvent {
269 pub projectile_type: YogStr,
271 pub projectile_uuid: YogStr,
272 pub shooter_uuid: YogStr,
274 pub hit_type: YogStr,
276 pub hit_entity_uuid: YogStr,
278 pub x: f64,
279 pub y: f64,
280 pub z: f64,
281 pub dimension: YogStr,
282}
283
284#[repr(C)]
286pub struct YogPlaceBlockEvent {
287 pub player: YogStr,
288 pub block: YogStr,
289 pub pos: YogBlockPos,
290}
291
292#[repr(C)]
293pub struct YogPacketEvent {
294 pub channel: YogStr,
295 pub player: YogStr, pub payload: *const u8,
297 pub payload_len: u32,
298}
299
300#[repr(C)]
301pub struct YogCommandEvent {
302 pub name: YogStr,
303 pub args: YogStr,
304 pub source: YogStr,
305 pub uuid: YogStr,
306}
307
308#[repr(C)]
311pub struct YogItemDef {
312 pub id: YogStr,
313 pub max_stack: u32,
314 pub name: YogStr, pub tooltip: YogStr, pub max_damage: u32,
317 pub fire_resistant: bool,
318 pub fuel_ticks: u32,
319 pub food_nutrition: u32, pub food_saturation: f32,
321 pub food_always_eat: bool,
322}
323
324#[repr(C)]
325pub struct YogBlockDef {
326 pub id: YogStr,
327 pub hardness: f32,
328 pub resistance: f32,
329 pub name: YogStr,
330 pub light_level: u8,
331 pub sound: YogStr, pub requires_tool: bool,
333 pub no_collision: bool,
334 pub slipperiness: f32,
335 pub shape: [f32; 6],
337}
338
339#[repr(C)]
343#[derive(Copy, Clone)]
344pub struct YogKeyPressEvent {
345 pub key_code: i32,
347 pub scan_code: i32,
348 pub action: i32,
350 pub modifiers: i32,
352}
353
354pub type YogBlockBreakFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogBlockBreakEvent, u8) -> bool;
366pub type YogChatFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogChatEvent, u8) -> bool;
367pub type YogPlayerFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerEvent, u8) -> bool;
368pub type YogUseItemFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogUseItemEvent, u8) -> bool;
369pub type YogUseBlockFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogUseBlockEvent, u8) -> bool;
370pub type YogAttackEntityFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogAttackEntityEvent, u8) -> bool;
371pub type YogEntityDamageFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntityDamageEvent, u8) -> bool;
372pub type YogEntityDeathFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntityDeathEvent, u8) -> bool;
373pub type YogEntitySpawnFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntitySpawnEvent, u8) -> bool;
374pub type YogPlaceBlockFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlaceBlockEvent, u8) -> bool;
375pub type YogPlayerDeathFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerDeathEvent, u8) -> bool;
376pub type YogPlayerRespawnFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerRespawnEvent, u8) -> bool;
377pub type YogAdvancementFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogAdvancementEvent, u8) -> bool;
378pub type YogEntityInteractFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntityInteractEvent, u8) -> bool;
379pub type YogCraftFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogCraftEvent, u8) -> bool;
380pub type YogExplosionFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogExplosionEvent, u8) -> bool;
381pub type YogItemPickupFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogItemPickupEvent, u8) -> bool;
382pub type YogPlayerMoveFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerMoveEvent, u8) -> bool;
383pub type YogContainerOpenFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogContainerOpenEvent, u8) -> bool;
384pub type YogContainerCloseFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogContainerCloseEvent, u8) -> bool;
385pub type YogProjectileHitFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogProjectileHitEvent, u8) -> bool;
386
387pub type YogPacketFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPacketEvent);
389pub type YogServerFn = unsafe extern "C" fn(*mut c_void, *const YogServer);
391pub type YogCommandFn = unsafe extern "C" fn(
393 ud: *mut c_void,
394 srv: *const YogServer,
395 ev: *const YogCommandEvent,
396 reply_buf: *mut u8,
397 reply_cap: u32,
398 reply_len: *mut u32,
399);
400pub type YogScheduledFn = unsafe extern "C" fn(*mut c_void, *const YogServer);
402
403pub type YogClientFn = unsafe extern "C" fn(ud: *mut c_void);
407pub type YogHudRenderFn = unsafe extern "C" fn(ud: *mut c_void, gfx: *const YogGfxApi);
410pub type YogWorldRenderFn = unsafe extern "C" fn(ud: *mut c_void, gfx: *const YogGfxApi);
413pub type YogKeyPressFn = unsafe extern "C" fn(ud: *mut c_void, ev: *const YogKeyPressEvent) -> bool;
415pub type YogScreenFn = unsafe extern "C" fn(ud: *mut c_void, screen_class: YogStr) -> bool;
418
419#[repr(C)]
435#[derive(Copy, Clone)]
436pub struct YogGfxApi {
437 pub screen_w: i32,
440 pub screen_h: i32,
442 pub delta_tick: f32,
444 pub scale_factor: f32,
447 pub view_proj: [f32; 16],
450 pub camera_pos: [f32; 3],
452 pub player_pos: [f32; 3],
455 pub _pad1: f32,
456
457 pub buf_create: unsafe extern "C" fn() -> u32,
460 pub buf_delete: unsafe extern "C" fn(handle: u32),
462 pub buf_data: unsafe extern "C" fn(handle: u32, bytes: *const u8, len: u32, dynamic: bool),
465 pub buf_subdata: unsafe extern "C" fn(handle: u32, offset: u32, bytes: *const u8, len: u32),
467
468 pub vao_create: unsafe extern "C" fn() -> u32,
471 pub vao_delete: unsafe extern "C" fn(handle: u32),
473 pub vao_attrib: unsafe extern "C" fn(
476 vao: u32, vbo: u32, index: u32, components: u8,
477 dtype: u8, normalized: bool, stride: u32, offset: u32,
478 ),
479 pub vao_set_ebo: unsafe extern "C" fn(vao: u32, ebo: u32),
481
482 pub prog_create: unsafe extern "C" fn(vert: YogStr, frag: YogStr, out: *mut u32) -> bool,
486 pub prog_delete: unsafe extern "C" fn(handle: u32),
488 pub prog_uniform_1i: unsafe extern "C" fn(prog: u32, name: YogStr, v: i32),
489 pub prog_uniform_1f: unsafe extern "C" fn(prog: u32, name: YogStr, v: f32),
490 pub prog_uniform_2f: unsafe extern "C" fn(prog: u32, name: YogStr, x: f32, y: f32),
491 pub prog_uniform_3f: unsafe extern "C" fn(prog: u32, name: YogStr, x: f32, y: f32, z: f32),
492 pub prog_uniform_4f: unsafe extern "C" fn(prog: u32, name: YogStr, x: f32, y: f32, z: f32, w: f32),
493 pub prog_uniform_mat4: unsafe extern "C" fn(prog: u32, name: YogStr, col_major: *const f32),
495
496 pub tex_create: unsafe extern "C" fn(w: u32, h: u32, rgba: *const u8, linear: bool) -> u32,
500 pub tex_delete: unsafe extern "C" fn(handle: u32),
502 pub tex_bind: unsafe extern "C" fn(unit: u32, handle: u32),
504 pub tex_from_mc: unsafe extern "C" fn(id: YogStr) -> u32,
508
509 pub draw_arrays: unsafe extern "C" fn(vao: u32, prog: u32, mode: u8, first: u32, count: u32),
513 pub draw_elements: unsafe extern "C" fn(vao: u32, ebo: u32, prog: u32, mode: u8, count: u32, u32_idx: bool),
516
517 pub set_blend: unsafe extern "C" fn(enabled: bool, src: u32, dst: u32),
520 pub set_depth: unsafe extern "C" fn(test: bool, write: bool),
522 pub set_scissor: unsafe extern "C" fn(x: i32, y: i32, w: i32, h: i32),
524 pub clear_scissor: unsafe extern "C" fn(),
526 pub set_viewport: unsafe extern "C" fn(x: i32, y: i32, w: i32, h: i32),
528
529 pub draw2d_rect: unsafe extern "C" fn(x1: f32, y1: f32, x2: f32, y2: f32, color: u32),
532 pub draw2d_gradient: unsafe extern "C" fn(x1: f32, y1: f32, x2: f32, y2: f32, top: u32, bottom: u32),
534 pub draw2d_text: unsafe extern "C" fn(text: YogStr, x: f32, y: f32, color: u32, shadow: bool),
536 pub draw2d_mc_tex: unsafe extern "C" fn(id: YogStr, x: f32, y: f32, u0: f32, v0: f32, w: f32, h: f32, tw: f32, th: f32),
539}
540
541unsafe impl Send for YogGfxApi {}
542unsafe impl Sync for YogGfxApi {}
543
544#[repr(C)]
554pub struct YogServer {
555 pub ctx: *mut c_void,
556 pub abi_version: u32,
557 pub size: u32,
560
561 pub free_str: unsafe extern "C" fn(ptr: *mut u8, len: u32),
563
564 pub broadcast: unsafe extern "C" fn(ctx: *mut c_void, msg: YogStr),
566
567 pub get_block: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos) -> YogOwnedStr,
569 pub set_block: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos, block: YogStr) -> bool,
570 pub world_time: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, out: *mut i64) -> bool,
571 pub set_time: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, time: i64) -> bool,
572 pub is_raining: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr) -> bool,
573 pub set_weather: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, raining: bool, dur: i32) -> bool,
574
575 pub give_item: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, item: YogStr, count: u32) -> bool,
577 pub player_teleport: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, pos: YogVec3) -> bool,
578 pub send_to_player: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, channel: YogStr, data: *const u8, len: u32) -> bool,
579 pub send_to_server: unsafe extern "C" fn(ctx: *mut c_void, channel: YogStr, data: *const u8, len: u32) -> bool,
580 pub kick_player: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, reason: YogStr) -> bool,
581 pub set_gamemode: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, mode: YogStr) -> bool,
582 pub send_title: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, title: YogStr, sub: YogStr, fi: i32, stay: i32, fo: i32) -> bool,
583 pub send_actionbar: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, msg: YogStr) -> bool,
584 pub play_sound: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogVec3, sound: YogStr, vol: f32, pitch: f32) -> bool,
585 pub play_sound_player: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, sound: YogStr, vol: f32, pitch: f32) -> bool,
586
587 pub entity_teleport: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, pos: YogVec3) -> bool,
589 pub entity_position: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut YogVec3) -> bool,
590 pub entity_health: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut f32) -> bool,
591 pub entity_set_health: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, hp: f32) -> bool,
592 pub entity_kill: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> bool,
593 pub spawn_entity: unsafe extern "C" fn(ctx: *mut c_void, type_id: YogStr, dim: YogStr, pos: YogVec3) -> YogOwnedStr,
594 pub entity_add_effect: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, fx: YogStr, dur: i32, amp: u8, particles: bool) -> bool,
595 pub entity_remove_effect: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, fx: YogStr) -> bool,
596 pub entity_clear_effects: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> bool,
597 pub entity_velocity: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut YogVec3) -> bool,
598 pub entity_set_velocity: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, vel: YogVec3) -> bool,
599 pub entity_add_velocity: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, vel: YogVec3) -> bool,
600
601 pub has_item_tag: unsafe extern "C" fn(ctx: *mut c_void, item: YogStr, tag: YogStr) -> bool,
603 pub has_block_tag: unsafe extern "C" fn(ctx: *mut c_void, block: YogStr, tag: YogStr) -> bool,
604 pub drop_loot: unsafe extern "C" fn(ctx: *mut c_void, table: YogStr, dim: YogStr, pos: YogVec3) -> bool,
605
606 pub scoreboard_get: unsafe extern "C" fn(ctx: *mut c_void, obj: YogStr, player: YogStr, out: *mut i32) -> bool,
608 pub scoreboard_set: unsafe extern "C" fn(ctx: *mut c_void, obj: YogStr, player: YogStr, score: i32) -> bool,
609 pub scoreboard_add: unsafe extern "C" fn(ctx: *mut c_void, obj: YogStr, player: YogStr, delta: i32, out: *mut i32) -> bool,
610
611 pub bossbar_create: unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, title: YogStr, color: YogStr, style: YogStr) -> bool,
613 pub bossbar_remove: unsafe extern "C" fn(ctx: *mut c_void, id: YogStr) -> bool,
614 pub bossbar_set_title: unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, title: YogStr) -> bool,
615 pub bossbar_set_progress: unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, progress: f32) -> bool,
616 pub bossbar_set_color: unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, color: YogStr) -> bool,
617 pub bossbar_add_player: unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, player: YogStr) -> bool,
618 pub bossbar_remove_player: unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, player: YogStr) -> bool,
619 pub bossbar_set_visible: unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, visible: bool) -> bool,
620
621 pub game_dir: unsafe extern "C" fn(ctx: *mut c_void) -> YogOwnedStr,
623
624 pub online_players: unsafe extern "C" fn(ctx: *mut c_void) -> YogOwnedStr,
627
628 pub get_block_nbt: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos) -> YogOwnedStr,
631 pub set_block_nbt: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos, snbt: YogStr) -> bool,
633
634 pub player_inventory: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr) -> YogOwnedStr,
637 pub player_set_slot: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, slot: u32, item_id: YogStr, count: u32) -> bool,
639
640 pub player_teleport_dim: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, dim: YogStr, pos: YogVec3) -> bool,
642 pub entity_teleport_dim: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, dim: YogStr, pos: YogVec3) -> bool,
643
644 pub world_entity_count: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, entity_type: YogStr) -> i32,
647
648 pub entity_get_nbt: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> YogOwnedStr,
651 pub entity_set_nbt: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, snbt: YogStr) -> bool,
653
654 pub spawn_particles: unsafe extern "C" fn(
659 ctx: *mut c_void,
660 dim: YogStr,
661 pos: YogVec3,
662 particle_type: YogStr,
663 count: i32,
664 dx: f64, dy: f64, dz: f64,
665 speed: f64,
666 ) -> bool,
667
668 pub entity_attribute_get: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, attribute_id: YogStr) -> f64,
673 pub entity_attribute_set: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, attribute_id: YogStr, value: f64) -> bool,
675
676 pub get_held_item_nbt: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr) -> YogOwnedStr,
680 pub set_held_item_nbt: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, snbt: YogStr) -> bool,
683
684 pub get_offhand_item_nbt: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr) -> YogOwnedStr,
687 pub set_offhand_item_nbt: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, snbt: YogStr) -> bool,
690 pub get_slot_item: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, slot: u32) -> YogOwnedStr,
693 pub set_slot_item: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, slot: u32, item_id: YogStr, count: u32, snbt: YogStr) -> bool,
696}
697
698unsafe impl Send for YogServer {}
700unsafe impl Sync for YogServer {}
701
702#[repr(C)]
711pub struct YogApi {
712 pub abi_version: u32,
713 pub size: u32,
715 pub ctx: *mut c_void,
717 pub server: *const YogServer,
719
720 pub on_block_break: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogBlockBreakFn),
723 pub on_chat: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogChatFn),
724 pub on_player_join: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerFn),
725 pub on_player_leave: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerFn),
726 pub on_use_item: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogUseItemFn),
727 pub on_use_block: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogUseBlockFn),
728 pub on_attack_entity: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogAttackEntityFn),
729 pub on_entity_damage: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntityDamageFn),
730 pub on_entity_death: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntityDeathFn),
731 pub on_entity_spawn: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntitySpawnFn),
732 pub on_player_place_block: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlaceBlockFn),
733 pub on_player_death: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerDeathFn),
734 pub on_player_respawn: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerRespawnFn),
735 pub on_advancement: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogAdvancementFn),
736 pub on_entity_interact: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntityInteractFn),
738 pub on_item_craft: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogCraftFn),
739 pub on_explosion: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogExplosionFn),
740 pub on_item_pickup: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogItemPickupFn),
742 pub on_player_move: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerMoveFn),
743 pub on_container_open: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogContainerOpenFn),
744 pub on_container_close: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogContainerCloseFn),
745 pub on_projectile_hit: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogProjectileHitFn),
746 pub on_server_tick: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogServerFn),
747 pub on_server_started: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogServerFn),
748 pub on_server_stopping: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogServerFn),
749
750 pub on_packet: unsafe extern "C" fn(ctx: *mut c_void, channel: YogStr, ud: *mut c_void, h: YogPacketFn),
752 pub on_client_packet: unsafe extern "C" fn(ctx: *mut c_void, channel: YogStr, ud: *mut c_void, h: YogPacketFn),
753
754 pub register_command: unsafe extern "C" fn(ctx: *mut c_void, name: YogStr, ud: *mut c_void, h: YogCommandFn),
756 pub register_typed_command: unsafe extern "C" fn(ctx: *mut c_void, name: YogStr, schema: YogStr, ud: *mut c_void, h: YogCommandFn),
757
758 pub register_recipe_json: unsafe extern "C" fn(ctx: *mut c_void, namespace: YogStr, name: YogStr, json: YogStr),
762
763 pub register_item: unsafe extern "C" fn(ctx: *mut c_void, def: *const YogItemDef),
765 pub register_block: unsafe extern "C" fn(ctx: *mut c_void, def: *const YogBlockDef),
766
767 pub schedule_once: unsafe extern "C" fn(ctx: *mut c_void, delay_ticks: u64, ud: *mut c_void, h: YogScheduledFn),
769 pub schedule_repeating: unsafe extern "C" fn(ctx: *mut c_void, period_ticks: u64, ud: *mut c_void, h: YogScheduledFn),
770
771 pub on_client_tick: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogClientFn),
773 pub on_hud_render: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogHudRenderFn),
774 pub on_key_press: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogKeyPressFn),
775 pub on_screen_open: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogScreenFn),
776 pub on_screen_close: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogScreenFn),
777
778 pub on_world_render: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogWorldRenderFn),
783}
784
785unsafe impl Send for YogApi {}
786unsafe impl Sync for YogApi {}