1use std::os::raw::c_void;
13
14pub const ABI_MAJOR: u32 = 0;
17pub const ABI_MINOR: u32 = 32;
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 {
34 ptr: std::ptr::null(),
35 len: 0,
36 };
37
38 #[inline]
39 pub fn from_str(s: &str) -> Self {
40 Self {
41 ptr: s.as_ptr(),
42 len: s.len() as u32,
43 }
44 }
45
46 #[inline]
47 pub fn is_empty(self) -> bool {
48 self.len == 0 || self.ptr.is_null()
49 }
50
51 #[inline]
54 pub unsafe fn as_str<'a>(self) -> &'a str {
55 if self.ptr.is_null() || self.len == 0 {
56 return "";
57 }
58 std::str::from_utf8_unchecked(std::slice::from_raw_parts(self.ptr, self.len as usize))
59 }
60}
61
62#[repr(C)]
66#[derive(Copy, Clone)]
67pub struct YogOwnedStr {
68 pub ptr: *mut u8,
69 pub len: u32,
70}
71
72impl YogOwnedStr {
73 pub const NONE: Self = Self {
74 ptr: std::ptr::null_mut(),
75 len: 0,
76 };
77
78 pub fn from_string(s: String) -> Self {
80 let len = s.len() as u32;
81 let ptr = Box::into_raw(s.into_bytes().into_boxed_slice()) as *mut u8;
82 Self { ptr, len }
83 }
84
85 #[inline]
86 pub fn is_none(self) -> bool {
87 self.ptr.is_null()
88 }
89}
90
91#[repr(C)]
93#[derive(Copy, Clone)]
94pub struct YogBlockPos {
95 pub x: i32,
96 pub y: i32,
97 pub z: i32,
98}
99
100#[repr(C)]
102#[derive(Copy, Clone)]
103pub struct YogVec3 {
104 pub x: f64,
105 pub y: f64,
106 pub z: f64,
107}
108
109#[repr(C)]
112pub struct YogBlockBreakEvent {
113 pub player: YogStr,
114 pub block: YogStr,
115 pub pos: YogBlockPos,
116 pub dimension: YogStr,
118}
119
120#[repr(C)]
121pub struct YogChatEvent {
122 pub player: YogStr,
123 pub message: YogStr,
124 pub dimension: YogStr,
125}
126
127#[repr(C)]
129pub struct YogPlayerEvent {
130 pub player: YogStr,
131 pub uuid: YogStr,
132 pub dimension: YogStr,
133}
134
135#[repr(C)]
136pub struct YogUseItemEvent {
137 pub player: YogStr,
138 pub item: YogStr,
139 pub sneaking: bool,
141 pub dimension: YogStr,
142}
143
144#[repr(C)]
145pub struct YogUseBlockEvent {
146 pub player: YogStr,
147 pub block: YogStr,
148 pub pos: YogBlockPos,
149 pub dimension: YogStr,
150}
151
152#[repr(C)]
153pub struct YogAttackEntityEvent {
154 pub player: YogStr,
155 pub target_type: YogStr,
156 pub target_uuid: YogStr,
157 pub dimension: YogStr,
158}
159
160#[repr(C)]
161pub struct YogEntityDamageEvent {
162 pub entity_type: YogStr,
163 pub uuid: YogStr,
164 pub amount: f32,
165 pub source: YogStr,
166 pub dimension: YogStr,
167}
168
169#[repr(C)]
170pub struct YogEntityDeathEvent {
171 pub entity_type: YogStr,
172 pub uuid: YogStr,
173 pub source: YogStr,
174 pub dimension: YogStr,
175}
176
177#[repr(C)]
178pub struct YogEntitySpawnEvent {
179 pub entity_type: YogStr,
180 pub uuid: YogStr,
181 pub dimension: YogStr,
182}
183
184#[repr(C)]
187pub struct YogPlayerDeathEvent {
188 pub player: YogStr,
189 pub uuid: YogStr,
190 pub source: YogStr,
192 pub dimension: YogStr,
193}
194
195#[repr(C)]
197pub struct YogPlayerRespawnEvent {
198 pub player: YogStr,
199 pub uuid: YogStr,
200 pub at_anchor: bool,
202 pub dimension: YogStr,
204}
205
206#[repr(C)]
208pub struct YogAdvancementEvent {
209 pub player: YogStr,
210 pub uuid: YogStr,
211 pub advancement: YogStr,
213 pub dimension: YogStr,
214}
215
216#[repr(C)]
219pub struct YogEntityInteractEvent {
220 pub player: YogStr,
221 pub player_uuid: YogStr,
222 pub entity_type: YogStr,
223 pub entity_uuid: YogStr,
224 pub hand: YogStr,
226 pub dimension: YogStr,
227}
228
229#[repr(C)]
231pub struct YogCraftEvent {
232 pub player: YogStr,
233 pub player_uuid: YogStr,
234 pub result_item: YogStr,
235 pub result_count: u32,
236 pub dimension: YogStr,
237}
238
239#[repr(C)]
242pub struct YogExplosionEvent {
243 pub dimension: YogStr,
244 pub x: f64,
245 pub y: f64,
246 pub z: f64,
247 pub power: f32,
248 pub cause_uuid: YogStr,
250}
251
252#[repr(C)]
256pub struct YogItemPickupEvent {
257 pub player: YogStr,
258 pub player_uuid: YogStr,
259 pub item_id: YogStr,
261 pub item_count: u32,
262 pub entity_uuid: YogStr,
264 pub dimension: YogStr,
265}
266
267#[repr(C)]
269pub struct YogPlayerMoveEvent {
270 pub player: YogStr,
271 pub player_uuid: YogStr,
272 pub x: f64,
273 pub y: f64,
274 pub z: f64,
275 pub yaw: f32,
276 pub pitch: f32,
277 pub dimension: YogStr,
278}
279
280#[repr(C)]
284pub struct YogContainerOpenEvent {
285 pub player: YogStr,
286 pub player_uuid: YogStr,
287 pub container_type: YogStr,
288 pub dimension: YogStr,
289}
290
291#[repr(C)]
293pub struct YogContainerCloseEvent {
294 pub player: YogStr,
295 pub player_uuid: YogStr,
296 pub dimension: YogStr,
297}
298
299#[repr(C)]
302pub struct YogProjectileHitEvent {
303 pub projectile_type: YogStr,
305 pub projectile_uuid: YogStr,
306 pub shooter_uuid: YogStr,
308 pub hit_type: YogStr,
310 pub hit_entity_uuid: YogStr,
312 pub x: f64,
313 pub y: f64,
314 pub z: f64,
315 pub dimension: YogStr,
316}
317
318#[repr(C)]
320pub struct YogPlaceBlockEvent {
321 pub player: YogStr,
322 pub block: YogStr,
323 pub pos: YogBlockPos,
324 pub dimension: YogStr,
325}
326
327#[repr(C)]
328pub struct YogPacketEvent {
329 pub channel: YogStr,
330 pub player: YogStr, pub payload: *const u8,
332 pub payload_len: u32,
333}
334
335#[repr(C)]
336pub struct YogCommandEvent {
337 pub name: YogStr,
338 pub args: YogStr,
339 pub source: YogStr,
340 pub uuid: YogStr,
341 pub dimension: YogStr,
343}
344
345#[repr(C)]
347pub struct YogStartupGrantDef {
348 pub id: YogStr,
349 pub items: YogStr, pub book: YogStr, pub command: YogStr, }
353
354#[repr(C)]
357pub struct YogItemDef {
358 pub id: YogStr,
359 pub max_stack: u32,
360 pub name: YogStr, pub tooltip: YogStr, pub max_damage: u32,
363 pub fire_resistant: bool,
364 pub fuel_ticks: u32,
365 pub food_nutrition: u32, pub food_saturation: f32,
367 pub food_always_eat: bool,
368}
369
370#[repr(C)]
371pub struct YogBlockDef {
372 pub id: YogStr,
373 pub hardness: f32,
374 pub resistance: f32,
375 pub name: YogStr,
376 pub light_level: u8,
377 pub sound: YogStr, pub requires_tool: bool,
379 pub no_collision: bool,
380 pub slipperiness: f32,
381 pub shape: [f32; 6],
383 pub connects: bool,
386 pub connect_groups: YogStr,
389 pub inventory_id: YogStr,
393}
394
395#[repr(C)]
397pub struct YogInventoryDef {
398 pub id: YogStr,
399 pub slot_count: u32,
400 pub layout: YogStr,
403 pub include_player_inventory: bool,
404 pub player_inv_x: f32,
405 pub player_inv_y: f32,
406 pub background_texture: YogStr,
408 pub title: YogStr,
409 pub background_w: f32,
416 pub background_h: f32,
417}
418
419#[repr(C)]
423#[derive(Copy, Clone)]
424pub struct YogKeyPressEvent {
425 pub key_code: i32,
427 pub scan_code: i32,
428 pub action: i32,
430 pub modifiers: i32,
432}
433
434pub type YogBlockBreakFn =
446 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogBlockBreakEvent, u8) -> bool;
447pub type YogChatFn =
448 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogChatEvent, u8) -> bool;
449pub type YogPlayerFn =
450 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerEvent, u8) -> bool;
451pub type YogUseItemFn =
452 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogUseItemEvent, u8) -> bool;
453pub type YogUseBlockFn =
454 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogUseBlockEvent, u8) -> bool;
455pub type YogAttackEntityFn =
456 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogAttackEntityEvent, u8) -> bool;
457pub type YogEntityDamageFn =
458 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntityDamageEvent, u8) -> bool;
459pub type YogEntityDeathFn =
460 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntityDeathEvent, u8) -> bool;
461pub type YogEntitySpawnFn =
462 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntitySpawnEvent, u8) -> bool;
463pub type YogPlaceBlockFn =
464 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlaceBlockEvent, u8) -> bool;
465pub type YogPlayerDeathFn =
466 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerDeathEvent, u8) -> bool;
467pub type YogPlayerRespawnFn =
468 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerRespawnEvent, u8) -> bool;
469pub type YogAdvancementFn =
470 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogAdvancementEvent, u8) -> bool;
471pub type YogEntityInteractFn =
472 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntityInteractEvent, u8) -> bool;
473pub type YogCraftFn =
474 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogCraftEvent, u8) -> bool;
475pub type YogExplosionFn =
476 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogExplosionEvent, u8) -> bool;
477pub type YogItemPickupFn =
478 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogItemPickupEvent, u8) -> bool;
479pub type YogPlayerMoveFn =
480 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerMoveEvent, u8) -> bool;
481pub type YogContainerOpenFn =
482 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogContainerOpenEvent, u8) -> bool;
483pub type YogContainerCloseFn =
484 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogContainerCloseEvent, u8) -> bool;
485pub type YogProjectileHitFn =
486 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogProjectileHitEvent, u8) -> bool;
487
488pub type YogPacketFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPacketEvent);
490pub type YogServerFn = unsafe extern "C" fn(*mut c_void, *const YogServer);
492pub type YogCommandFn = unsafe extern "C" fn(
494 ud: *mut c_void,
495 srv: *const YogServer,
496 ev: *const YogCommandEvent,
497 reply_buf: *mut u8,
498 reply_cap: u32,
499 reply_len: *mut u32,
500);
501pub type YogScheduledFn = unsafe extern "C" fn(*mut c_void, *const YogServer);
503
504pub type YogClientFn = unsafe extern "C" fn(ud: *mut c_void);
508pub type YogUIEventFn = unsafe extern "C" fn(ud: *mut c_void, ui_id: YogStr, event_id: YogStr);
511pub type YogHudRenderFn = unsafe extern "C" fn(ud: *mut c_void, gfx: *const YogGfxApi);
512pub type YogWorldRenderFn = unsafe extern "C" fn(ud: *mut c_void, gfx: *const YogGfxApi);
515pub type YogKeyPressFn = unsafe extern "C" fn(ud: *mut c_void, ev: *const YogKeyPressEvent) -> bool;
517pub type YogScreenFn = unsafe extern "C" fn(ud: *mut c_void, screen_class: YogStr) -> bool;
520
521#[repr(C)]
537#[derive(Copy, Clone)]
538pub struct YogGfxApi {
539 pub screen_w: i32,
542 pub screen_h: i32,
544 pub delta_tick: f32,
546 pub scale_factor: f32,
549 pub view_proj: [f32; 16],
552 pub camera_pos: [f32; 3],
554 pub player_pos: [f32; 3],
557 pub _pad1: f32,
558
559 pub buf_create: unsafe extern "C" fn() -> u32,
562 pub buf_delete: unsafe extern "C" fn(handle: u32),
564 pub buf_data: unsafe extern "C" fn(handle: u32, bytes: *const u8, len: u32, dynamic: bool),
567 pub buf_subdata: unsafe extern "C" fn(handle: u32, offset: u32, bytes: *const u8, len: u32),
569
570 pub vao_create: unsafe extern "C" fn() -> u32,
573 pub vao_delete: unsafe extern "C" fn(handle: u32),
575 pub vao_attrib: unsafe extern "C" fn(
578 vao: u32,
579 vbo: u32,
580 index: u32,
581 components: u8,
582 dtype: u8,
583 normalized: bool,
584 stride: u32,
585 offset: u32,
586 ),
587 pub vao_set_ebo: unsafe extern "C" fn(vao: u32, ebo: u32),
589
590 pub prog_create: unsafe extern "C" fn(vert: YogStr, frag: YogStr, out: *mut u32) -> bool,
594 pub prog_delete: unsafe extern "C" fn(handle: u32),
596 pub prog_uniform_1i: unsafe extern "C" fn(prog: u32, name: YogStr, v: i32),
597 pub prog_uniform_1f: unsafe extern "C" fn(prog: u32, name: YogStr, v: f32),
598 pub prog_uniform_2f: unsafe extern "C" fn(prog: u32, name: YogStr, x: f32, y: f32),
599 pub prog_uniform_3f: unsafe extern "C" fn(prog: u32, name: YogStr, x: f32, y: f32, z: f32),
600 pub prog_uniform_4f:
601 unsafe extern "C" fn(prog: u32, name: YogStr, x: f32, y: f32, z: f32, w: f32),
602 pub prog_uniform_mat4: unsafe extern "C" fn(prog: u32, name: YogStr, col_major: *const f32),
604
605 pub tex_create: unsafe extern "C" fn(w: u32, h: u32, rgba: *const u8, linear: bool) -> u32,
609 pub tex_delete: unsafe extern "C" fn(handle: u32),
611 pub tex_bind: unsafe extern "C" fn(unit: u32, handle: u32),
613 pub tex_from_mc: unsafe extern "C" fn(id: YogStr) -> u32,
617
618 pub draw_arrays: unsafe extern "C" fn(vao: u32, prog: u32, mode: u8, first: u32, count: u32),
622 pub draw_elements:
625 unsafe extern "C" fn(vao: u32, ebo: u32, prog: u32, mode: u8, count: u32, u32_idx: bool),
626
627 pub set_blend: unsafe extern "C" fn(enabled: bool, src: u32, dst: u32),
630 pub set_depth: unsafe extern "C" fn(test: bool, write: bool),
632 pub set_scissor: unsafe extern "C" fn(x: i32, y: i32, w: i32, h: i32),
634 pub clear_scissor: unsafe extern "C" fn(),
636 pub set_viewport: unsafe extern "C" fn(x: i32, y: i32, w: i32, h: i32),
638
639 pub draw2d_rect: unsafe extern "C" fn(x1: f32, y1: f32, x2: f32, y2: f32, color: u32),
642 pub draw2d_gradient:
644 unsafe extern "C" fn(x1: f32, y1: f32, x2: f32, y2: f32, top: u32, bottom: u32),
645 pub draw2d_text: unsafe extern "C" fn(text: YogStr, x: f32, y: f32, color: u32, shadow: bool),
647 pub draw2d_mc_tex: unsafe extern "C" fn(
650 id: YogStr,
651 x: f32,
652 y: f32,
653 u0: f32,
654 v0: f32,
655 w: f32,
656 h: f32,
657 tw: f32,
658 th: f32,
659 ),
660
661 pub draw2d_item: unsafe extern "C" fn(id: YogStr, x: f32, y: f32, size: f32),
667}
668
669unsafe impl Send for YogGfxApi {}
670unsafe impl Sync for YogGfxApi {}
671
672#[repr(C)]
682pub struct YogServer {
683 pub ctx: *mut c_void,
684 pub abi_version: u32,
685 pub size: u32,
688
689 pub free_str: unsafe extern "C" fn(ptr: *mut u8, len: u32),
691
692 pub broadcast: unsafe extern "C" fn(ctx: *mut c_void, msg: YogStr),
694
695 pub get_block:
697 unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos) -> YogOwnedStr,
698 pub set_block: unsafe extern "C" fn(
699 ctx: *mut c_void,
700 dim: YogStr,
701 pos: YogBlockPos,
702 block: YogStr,
703 ) -> bool,
704 pub world_time: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, out: *mut i64) -> bool,
705 pub set_time: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, time: i64) -> bool,
706 pub is_raining: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr) -> bool,
707 pub set_weather:
708 unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, raining: bool, dur: i32) -> bool,
709
710 pub give_item:
712 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, item: YogStr, count: u32) -> bool,
713 pub player_teleport:
714 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, pos: YogVec3) -> bool,
715 pub send_to_player: unsafe extern "C" fn(
716 ctx: *mut c_void,
717 player: YogStr,
718 channel: YogStr,
719 data: *const u8,
720 len: u32,
721 ) -> bool,
722 pub send_to_server:
723 unsafe extern "C" fn(ctx: *mut c_void, channel: YogStr, data: *const u8, len: u32) -> bool,
724 pub kick_player: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, reason: YogStr) -> bool,
725 pub set_gamemode: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, mode: YogStr) -> bool,
726 pub send_title: unsafe extern "C" fn(
727 ctx: *mut c_void,
728 player: YogStr,
729 title: YogStr,
730 sub: YogStr,
731 fi: i32,
732 stay: i32,
733 fo: i32,
734 ) -> bool,
735 pub send_actionbar: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, msg: YogStr) -> bool,
736 pub play_sound: unsafe extern "C" fn(
737 ctx: *mut c_void,
738 dim: YogStr,
739 pos: YogVec3,
740 sound: YogStr,
741 vol: f32,
742 pitch: f32,
743 ) -> bool,
744 pub play_sound_player: unsafe extern "C" fn(
745 ctx: *mut c_void,
746 player: YogStr,
747 sound: YogStr,
748 vol: f32,
749 pitch: f32,
750 ) -> bool,
751
752 pub entity_teleport: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, pos: YogVec3) -> bool,
754 pub entity_position:
755 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut YogVec3) -> bool,
756 pub entity_health: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut f32) -> bool,
757 pub entity_set_health: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, hp: f32) -> bool,
758 pub entity_kill: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> bool,
759 pub spawn_entity: unsafe extern "C" fn(
760 ctx: *mut c_void,
761 type_id: YogStr,
762 dim: YogStr,
763 pos: YogVec3,
764 ) -> YogOwnedStr,
765 pub entity_add_effect: unsafe extern "C" fn(
766 ctx: *mut c_void,
767 uuid: YogStr,
768 fx: YogStr,
769 dur: i32,
770 amp: u8,
771 particles: bool,
772 ) -> bool,
773 pub entity_remove_effect:
774 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, fx: YogStr) -> bool,
775 pub entity_clear_effects: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> bool,
776 pub entity_velocity:
777 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut YogVec3) -> bool,
778 pub entity_set_velocity:
779 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, vel: YogVec3) -> bool,
780 pub entity_add_velocity:
781 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, vel: YogVec3) -> bool,
782
783 pub has_item_tag: unsafe extern "C" fn(ctx: *mut c_void, item: YogStr, tag: YogStr) -> bool,
785 pub has_block_tag: unsafe extern "C" fn(ctx: *mut c_void, block: YogStr, tag: YogStr) -> bool,
786 pub drop_loot:
787 unsafe extern "C" fn(ctx: *mut c_void, table: YogStr, dim: YogStr, pos: YogVec3) -> bool,
788
789 pub scoreboard_get:
791 unsafe extern "C" fn(ctx: *mut c_void, obj: YogStr, player: YogStr, out: *mut i32) -> bool,
792 pub scoreboard_set:
793 unsafe extern "C" fn(ctx: *mut c_void, obj: YogStr, player: YogStr, score: i32) -> bool,
794 pub scoreboard_add: unsafe extern "C" fn(
795 ctx: *mut c_void,
796 obj: YogStr,
797 player: YogStr,
798 delta: i32,
799 out: *mut i32,
800 ) -> bool,
801
802 pub bossbar_create: unsafe extern "C" fn(
804 ctx: *mut c_void,
805 id: YogStr,
806 title: YogStr,
807 color: YogStr,
808 style: YogStr,
809 ) -> bool,
810 pub bossbar_remove: unsafe extern "C" fn(ctx: *mut c_void, id: YogStr) -> bool,
811 pub bossbar_set_title:
812 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, title: YogStr) -> bool,
813 pub bossbar_set_progress:
814 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, progress: f32) -> bool,
815 pub bossbar_set_color:
816 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, color: YogStr) -> bool,
817 pub bossbar_add_player:
818 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, player: YogStr) -> bool,
819 pub bossbar_remove_player:
820 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, player: YogStr) -> bool,
821 pub bossbar_set_visible:
822 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, visible: bool) -> bool,
823
824 pub game_dir: unsafe extern "C" fn(ctx: *mut c_void) -> YogOwnedStr,
826
827 pub online_players: unsafe extern "C" fn(ctx: *mut c_void) -> YogOwnedStr,
830
831 pub get_block_nbt:
834 unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos) -> YogOwnedStr,
835 pub set_block_nbt:
837 unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos, snbt: YogStr) -> bool,
838
839 pub player_inventory: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr) -> YogOwnedStr,
842 pub player_set_slot: unsafe extern "C" fn(
844 ctx: *mut c_void,
845 player: YogStr,
846 slot: u32,
847 item_id: YogStr,
848 count: u32,
849 ) -> bool,
850
851 pub get_inventory_slot: unsafe extern "C" fn(
855 ctx: *mut c_void,
856 dim: YogStr,
857 pos: YogBlockPos,
858 slot: u32,
859 ) -> YogOwnedStr,
860 pub set_inventory_slot: unsafe extern "C" fn(
863 ctx: *mut c_void,
864 dim: YogStr,
865 pos: YogBlockPos,
866 slot: u32,
867 item_id: YogStr,
868 count: u32,
869 ) -> bool,
870
871 pub player_teleport_dim:
873 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, dim: YogStr, pos: YogVec3) -> bool,
874 pub entity_teleport_dim:
875 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, dim: YogStr, pos: YogVec3) -> bool,
876
877 pub world_entity_count:
880 unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, entity_type: YogStr) -> i32,
881
882 pub entity_get_nbt: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> YogOwnedStr,
885 pub entity_set_nbt: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, snbt: YogStr) -> bool,
887
888 pub spawn_particles: unsafe extern "C" fn(
893 ctx: *mut c_void,
894 dim: YogStr,
895 pos: YogVec3,
896 particle_type: YogStr,
897 count: i32,
898 dx: f64,
899 dy: f64,
900 dz: f64,
901 speed: f64,
902 ) -> bool,
903
904 pub entity_attribute_get:
909 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, attribute_id: YogStr) -> f64,
910 pub entity_attribute_set: unsafe extern "C" fn(
912 ctx: *mut c_void,
913 uuid: YogStr,
914 attribute_id: YogStr,
915 value: f64,
916 ) -> bool,
917
918 pub get_held_item_nbt: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr) -> YogOwnedStr,
922 pub set_held_item_nbt:
925 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, snbt: YogStr) -> bool,
926
927 pub get_offhand_item_nbt: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr) -> YogOwnedStr,
930 pub set_offhand_item_nbt:
933 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, snbt: YogStr) -> bool,
934 pub get_slot_item:
937 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, slot: u32) -> YogOwnedStr,
938 pub set_slot_item: unsafe extern "C" fn(
941 ctx: *mut c_void,
942 player: YogStr,
943 slot: u32,
944 item_id: YogStr,
945 count: u32,
946 snbt: YogStr,
947 ) -> bool,
948
949 pub entity_rotation:
953 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut YogVec3) -> bool,
954}
955
956unsafe impl Send for YogServer {}
958unsafe impl Sync for YogServer {}
959
960#[repr(C)]
967#[derive(Copy, Clone)]
968pub struct YogChunkWriterApi {
969 pub chunk_x: i32,
971 pub chunk_z: i32,
973 pub min_y: i32,
975 pub height: i32,
977 pub ctx: *mut c_void,
979 pub set_block:
982 unsafe extern "C" fn(ctx: *mut c_void, x: i32, y: i32, z: i32, block_id: YogStr) -> bool,
983}
984
985unsafe impl Send for YogChunkWriterApi {}
986unsafe impl Sync for YogChunkWriterApi {}
987
988pub type YogChunkGeneratorFn =
991 unsafe extern "C" fn(ud: *mut c_void, writer: *const YogChunkWriterApi);
992
993#[repr(C)]
1002pub struct YogApi {
1003 pub abi_version: u32,
1004 pub size: u32,
1006 pub ctx: *mut c_void,
1008 pub server: *const YogServer,
1010
1011 pub on_block_break: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogBlockBreakFn),
1014 pub on_chat: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogChatFn),
1015 pub on_player_join: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerFn),
1016 pub on_player_leave: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerFn),
1017 pub on_use_item: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogUseItemFn),
1018 pub on_use_block: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogUseBlockFn),
1019 pub on_attack_entity:
1020 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogAttackEntityFn),
1021 pub on_entity_damage:
1022 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntityDamageFn),
1023 pub on_entity_death:
1024 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntityDeathFn),
1025 pub on_entity_spawn:
1026 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntitySpawnFn),
1027 pub on_player_place_block:
1028 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlaceBlockFn),
1029 pub on_player_death:
1030 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerDeathFn),
1031 pub on_player_respawn:
1032 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerRespawnFn),
1033 pub on_advancement:
1034 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogAdvancementFn),
1035 pub on_entity_interact:
1037 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntityInteractFn),
1038 pub on_item_craft: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogCraftFn),
1039 pub on_explosion: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogExplosionFn),
1040 pub on_item_pickup: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogItemPickupFn),
1042 pub on_player_move: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerMoveFn),
1043 pub on_container_open:
1044 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogContainerOpenFn),
1045 pub on_container_close:
1046 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogContainerCloseFn),
1047 pub on_projectile_hit:
1048 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogProjectileHitFn),
1049 pub on_server_tick: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogServerFn),
1050 pub on_server_started: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogServerFn),
1051 pub on_server_stopping: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogServerFn),
1052
1053 pub on_packet:
1055 unsafe extern "C" fn(ctx: *mut c_void, channel: YogStr, ud: *mut c_void, h: YogPacketFn),
1056 pub on_client_packet:
1057 unsafe extern "C" fn(ctx: *mut c_void, channel: YogStr, ud: *mut c_void, h: YogPacketFn),
1058
1059 pub register_command:
1061 unsafe extern "C" fn(ctx: *mut c_void, name: YogStr, ud: *mut c_void, h: YogCommandFn),
1062 pub register_typed_command: unsafe extern "C" fn(
1063 ctx: *mut c_void,
1064 name: YogStr,
1065 schema: YogStr,
1066 ud: *mut c_void,
1067 h: YogCommandFn,
1068 ),
1069
1070 pub register_recipe_json:
1074 unsafe extern "C" fn(ctx: *mut c_void, namespace: YogStr, name: YogStr, json: YogStr),
1075
1076 pub register_item: unsafe extern "C" fn(ctx: *mut c_void, def: *const YogItemDef),
1078 pub register_block: unsafe extern "C" fn(ctx: *mut c_void, def: *const YogBlockDef),
1079
1080 pub schedule_once: unsafe extern "C" fn(
1082 ctx: *mut c_void,
1083 delay_ticks: u64,
1084 ud: *mut c_void,
1085 h: YogScheduledFn,
1086 ),
1087 pub schedule_repeating: unsafe extern "C" fn(
1088 ctx: *mut c_void,
1089 period_ticks: u64,
1090 ud: *mut c_void,
1091 h: YogScheduledFn,
1092 ),
1093
1094 pub on_client_tick: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogClientFn),
1096 pub on_hud_render: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogHudRenderFn),
1097 pub on_key_press: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogKeyPressFn),
1098 pub on_screen_open: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogScreenFn),
1099 pub on_screen_close: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogScreenFn),
1100
1101 pub on_world_render:
1106 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogWorldRenderFn),
1107
1108 pub register_startup_grant:
1110 unsafe extern "C" fn(ctx: *mut c_void, grant: *const YogStartupGrantDef),
1111
1112 pub register_book: unsafe extern "C" fn(ctx: *mut c_void, book_id: YogStr, book_json: YogStr),
1114
1115 pub register_ui: unsafe extern "C" fn(
1120 ctx: *mut c_void,
1121 ui_id: YogStr,
1122 layout_json: YogStr,
1123 ud: *mut c_void,
1124 h: YogUIEventFn,
1125 ),
1126
1127 pub on_ui_render:
1134 unsafe extern "C" fn(ctx: *mut c_void, ui_id: YogStr, ud: *mut c_void, h: YogHudRenderFn),
1135
1136 pub register_menu_entry: unsafe extern "C" fn(ctx: *mut c_void, label: YogStr, ui_id: YogStr),
1142
1143 pub mods_list: unsafe extern "C" fn(ctx: *mut c_void) -> YogOwnedStr,
1150 pub free_str: unsafe extern "C" fn(ptr: *mut u8, len: u32),
1153
1154 pub ui_open: unsafe extern "C" fn(ctx: *mut c_void, ui_id: YogStr, modal: bool, pause: bool),
1159
1160 pub register_inventory: unsafe extern "C" fn(ctx: *mut c_void, def: *const YogInventoryDef),
1163
1164 pub interop_export:
1168 unsafe extern "C" fn(ctx: *mut c_void, mod_id: YogStr, symbol: YogStr, ptr: *const c_void),
1169 pub interop_import:
1172 unsafe extern "C" fn(ctx: *mut c_void, mod_id: YogStr, symbol: YogStr) -> *const c_void,
1173
1174 pub register_dimension_json: unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, json: YogStr),
1180 pub register_chunk_generator:
1184 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, ud: *mut c_void, h: YogChunkGeneratorFn),
1185}
1186
1187unsafe impl Send for YogApi {}
1188unsafe impl Sync for YogApi {}