1use std::os::raw::c_void;
13
14pub const ABI_MAJOR: u32 = 0;
17pub const ABI_MINOR: u32 = 33;
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 #[allow(clippy::should_implement_trait)]
40 #[inline]
41 pub fn from_str(s: &str) -> Self {
42 Self {
43 ptr: s.as_ptr(),
44 len: s.len() as u32,
45 }
46 }
47
48 #[inline]
49 pub fn is_empty(self) -> bool {
50 self.len == 0 || self.ptr.is_null()
51 }
52
53 #[inline]
58 pub unsafe fn as_str<'a>(self) -> &'a str {
59 if self.ptr.is_null() || self.len == 0 {
60 return "";
61 }
62 std::str::from_utf8_unchecked(std::slice::from_raw_parts(self.ptr, self.len as usize))
63 }
64}
65
66#[repr(C)]
70#[derive(Copy, Clone)]
71pub struct YogOwnedStr {
72 pub ptr: *mut u8,
73 pub len: u32,
74}
75
76impl YogOwnedStr {
77 pub const NONE: Self = Self {
78 ptr: std::ptr::null_mut(),
79 len: 0,
80 };
81
82 pub fn from_string(s: String) -> Self {
84 let len = s.len() as u32;
85 let ptr = Box::into_raw(s.into_bytes().into_boxed_slice()) as *mut u8;
86 Self { ptr, len }
87 }
88
89 #[inline]
90 pub fn is_none(self) -> bool {
91 self.ptr.is_null()
92 }
93}
94
95#[repr(C)]
97#[derive(Copy, Clone)]
98pub struct YogBlockPos {
99 pub x: i32,
100 pub y: i32,
101 pub z: i32,
102}
103
104#[repr(C)]
106#[derive(Copy, Clone)]
107pub struct YogVec3 {
108 pub x: f64,
109 pub y: f64,
110 pub z: f64,
111}
112
113#[repr(C)]
116pub struct YogBlockBreakEvent {
117 pub player: YogStr,
118 pub block: YogStr,
119 pub pos: YogBlockPos,
120 pub dimension: YogStr,
122}
123
124#[repr(C)]
125pub struct YogChatEvent {
126 pub player: YogStr,
127 pub message: YogStr,
128 pub dimension: YogStr,
129}
130
131#[repr(C)]
133pub struct YogPlayerEvent {
134 pub player: YogStr,
135 pub uuid: YogStr,
136 pub dimension: YogStr,
137}
138
139#[repr(C)]
140pub struct YogUseItemEvent {
141 pub player: YogStr,
142 pub item: YogStr,
143 pub sneaking: bool,
145 pub dimension: YogStr,
146}
147
148#[repr(C)]
149pub struct YogUseBlockEvent {
150 pub player: YogStr,
151 pub block: YogStr,
152 pub pos: YogBlockPos,
153 pub dimension: YogStr,
154}
155
156#[repr(C)]
157pub struct YogAttackEntityEvent {
158 pub player: YogStr,
159 pub target_type: YogStr,
160 pub target_uuid: YogStr,
161 pub dimension: YogStr,
162}
163
164#[repr(C)]
165pub struct YogEntityDamageEvent {
166 pub entity_type: YogStr,
167 pub uuid: YogStr,
168 pub amount: f32,
169 pub source: YogStr,
170 pub dimension: YogStr,
171}
172
173#[repr(C)]
174pub struct YogEntityDeathEvent {
175 pub entity_type: YogStr,
176 pub uuid: YogStr,
177 pub source: YogStr,
178 pub dimension: YogStr,
179}
180
181#[repr(C)]
182pub struct YogEntitySpawnEvent {
183 pub entity_type: YogStr,
184 pub uuid: YogStr,
185 pub dimension: YogStr,
186}
187
188#[repr(C)]
191pub struct YogPlayerDeathEvent {
192 pub player: YogStr,
193 pub uuid: YogStr,
194 pub source: YogStr,
196 pub dimension: YogStr,
197}
198
199#[repr(C)]
201pub struct YogPlayerRespawnEvent {
202 pub player: YogStr,
203 pub uuid: YogStr,
204 pub at_anchor: bool,
206 pub dimension: YogStr,
208}
209
210#[repr(C)]
212pub struct YogAdvancementEvent {
213 pub player: YogStr,
214 pub uuid: YogStr,
215 pub advancement: YogStr,
217 pub dimension: YogStr,
218}
219
220#[repr(C)]
223pub struct YogEntityInteractEvent {
224 pub player: YogStr,
225 pub player_uuid: YogStr,
226 pub entity_type: YogStr,
227 pub entity_uuid: YogStr,
228 pub hand: YogStr,
230 pub dimension: YogStr,
231}
232
233#[repr(C)]
235pub struct YogCraftEvent {
236 pub player: YogStr,
237 pub player_uuid: YogStr,
238 pub result_item: YogStr,
239 pub result_count: u32,
240 pub dimension: YogStr,
241}
242
243#[repr(C)]
246pub struct YogExplosionEvent {
247 pub dimension: YogStr,
248 pub x: f64,
249 pub y: f64,
250 pub z: f64,
251 pub power: f32,
252 pub cause_uuid: YogStr,
254}
255
256#[repr(C)]
260pub struct YogItemPickupEvent {
261 pub player: YogStr,
262 pub player_uuid: YogStr,
263 pub item_id: YogStr,
265 pub item_count: u32,
266 pub entity_uuid: YogStr,
268 pub dimension: YogStr,
269}
270
271#[repr(C)]
273pub struct YogPlayerMoveEvent {
274 pub player: YogStr,
275 pub player_uuid: YogStr,
276 pub x: f64,
277 pub y: f64,
278 pub z: f64,
279 pub yaw: f32,
280 pub pitch: f32,
281 pub dimension: YogStr,
282}
283
284#[repr(C)]
288pub struct YogContainerOpenEvent {
289 pub player: YogStr,
290 pub player_uuid: YogStr,
291 pub container_type: YogStr,
292 pub dimension: YogStr,
293}
294
295#[repr(C)]
297pub struct YogContainerCloseEvent {
298 pub player: YogStr,
299 pub player_uuid: YogStr,
300 pub dimension: YogStr,
301}
302
303#[repr(C)]
306pub struct YogProjectileHitEvent {
307 pub projectile_type: YogStr,
309 pub projectile_uuid: YogStr,
310 pub shooter_uuid: YogStr,
312 pub hit_type: YogStr,
314 pub hit_entity_uuid: YogStr,
316 pub x: f64,
317 pub y: f64,
318 pub z: f64,
319 pub dimension: YogStr,
320}
321
322#[repr(C)]
324pub struct YogPlaceBlockEvent {
325 pub player: YogStr,
326 pub block: YogStr,
327 pub pos: YogBlockPos,
328 pub dimension: YogStr,
329}
330
331#[repr(C)]
332pub struct YogPacketEvent {
333 pub channel: YogStr,
334 pub player: YogStr, pub payload: *const u8,
336 pub payload_len: u32,
337}
338
339#[repr(C)]
340pub struct YogCommandEvent {
341 pub name: YogStr,
342 pub args: YogStr,
343 pub source: YogStr,
344 pub uuid: YogStr,
345 pub dimension: YogStr,
347}
348
349#[repr(C)]
351pub struct YogStartupGrantDef {
352 pub id: YogStr,
353 pub items: YogStr, pub book: YogStr, pub command: YogStr, }
357
358#[repr(C)]
361pub struct YogItemDef {
362 pub id: YogStr,
363 pub max_stack: u32,
364 pub name: YogStr, pub tooltip: YogStr, pub max_damage: u32,
367 pub fire_resistant: bool,
368 pub fuel_ticks: u32,
369 pub food_nutrition: u32, pub food_saturation: f32,
371 pub food_always_eat: bool,
372}
373
374#[repr(C)]
375pub struct YogBlockDef {
376 pub id: YogStr,
377 pub hardness: f32,
378 pub resistance: f32,
379 pub name: YogStr,
380 pub light_level: u8,
381 pub sound: YogStr, pub requires_tool: bool,
383 pub no_collision: bool,
384 pub slipperiness: f32,
385 pub shape: [f32; 6],
387 pub connects: bool,
390 pub connect_groups: YogStr,
393 pub inventory_id: YogStr,
397}
398
399#[repr(C)]
401pub struct YogInventoryDef {
402 pub id: YogStr,
403 pub slot_count: u32,
404 pub layout: YogStr,
407 pub include_player_inventory: bool,
408 pub player_inv_x: f32,
409 pub player_inv_y: f32,
410 pub background_texture: YogStr,
412 pub title: YogStr,
413 pub background_w: f32,
420 pub background_h: f32,
421}
422
423#[repr(C)]
427#[derive(Copy, Clone)]
428pub struct YogKeyPressEvent {
429 pub key_code: i32,
431 pub scan_code: i32,
432 pub action: i32,
434 pub modifiers: i32,
436}
437
438pub type YogBlockBreakFn =
450 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogBlockBreakEvent, u8) -> bool;
451pub type YogChatFn =
452 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogChatEvent, u8) -> bool;
453pub type YogPlayerFn =
454 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerEvent, u8) -> bool;
455pub type YogUseItemFn =
456 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogUseItemEvent, u8) -> bool;
457pub type YogUseBlockFn =
458 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogUseBlockEvent, u8) -> bool;
459pub type YogAttackEntityFn =
460 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogAttackEntityEvent, u8) -> bool;
461pub type YogEntityDamageFn =
462 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntityDamageEvent, u8) -> bool;
463pub type YogEntityDeathFn =
464 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntityDeathEvent, u8) -> bool;
465pub type YogEntitySpawnFn =
466 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntitySpawnEvent, u8) -> bool;
467pub type YogPlaceBlockFn =
468 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlaceBlockEvent, u8) -> bool;
469pub type YogPlayerDeathFn =
470 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerDeathEvent, u8) -> bool;
471pub type YogPlayerRespawnFn =
472 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerRespawnEvent, u8) -> bool;
473pub type YogAdvancementFn =
474 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogAdvancementEvent, u8) -> bool;
475pub type YogEntityInteractFn =
476 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntityInteractEvent, u8) -> bool;
477pub type YogCraftFn =
478 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogCraftEvent, u8) -> bool;
479pub type YogExplosionFn =
480 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogExplosionEvent, u8) -> bool;
481pub type YogItemPickupFn =
482 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogItemPickupEvent, u8) -> bool;
483pub type YogPlayerMoveFn =
484 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerMoveEvent, u8) -> bool;
485pub type YogContainerOpenFn =
486 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogContainerOpenEvent, u8) -> bool;
487pub type YogContainerCloseFn =
488 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogContainerCloseEvent, u8) -> bool;
489pub type YogProjectileHitFn =
490 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogProjectileHitEvent, u8) -> bool;
491
492pub type YogPacketFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPacketEvent);
494pub type YogServerFn = unsafe extern "C" fn(*mut c_void, *const YogServer);
496pub type YogCommandFn = unsafe extern "C" fn(
498 ud: *mut c_void,
499 srv: *const YogServer,
500 ev: *const YogCommandEvent,
501 reply_buf: *mut u8,
502 reply_cap: u32,
503 reply_len: *mut u32,
504);
505pub type YogScheduledFn = unsafe extern "C" fn(*mut c_void, *const YogServer);
507
508pub type YogClientFn = unsafe extern "C" fn(ud: *mut c_void);
512pub type YogUIEventFn = unsafe extern "C" fn(ud: *mut c_void, ui_id: YogStr, event_id: YogStr);
519pub type YogHudRenderFn = unsafe extern "C" fn(ud: *mut c_void, gfx: *const YogGfxApi);
522pub type YogWorldRenderFn = unsafe extern "C" fn(ud: *mut c_void, gfx: *const YogGfxApi);
525pub type YogKeyPressFn = unsafe extern "C" fn(ud: *mut c_void, ev: *const YogKeyPressEvent) -> bool;
527pub type YogScreenFn = unsafe extern "C" fn(ud: *mut c_void, screen_class: YogStr) -> bool;
530
531#[repr(C)]
547#[derive(Copy, Clone)]
548pub struct YogGfxApi {
549 pub screen_w: i32,
552 pub screen_h: i32,
554 pub delta_tick: f32,
556 pub scale_factor: f32,
559 pub view_proj: [f32; 16],
562 pub camera_pos: [f32; 3],
564 pub player_pos: [f32; 3],
567 pub _pad1: f32,
568
569 pub buf_create: unsafe extern "C" fn() -> u32,
572 pub buf_delete: unsafe extern "C" fn(handle: u32),
574 pub buf_data: unsafe extern "C" fn(handle: u32, bytes: *const u8, len: u32, dynamic: bool),
577 pub buf_subdata: unsafe extern "C" fn(handle: u32, offset: u32, bytes: *const u8, len: u32),
579
580 pub vao_create: unsafe extern "C" fn() -> u32,
583 pub vao_delete: unsafe extern "C" fn(handle: u32),
585 pub vao_attrib: unsafe extern "C" fn(
588 vao: u32,
589 vbo: u32,
590 index: u32,
591 components: u8,
592 dtype: u8,
593 normalized: bool,
594 stride: u32,
595 offset: u32,
596 ),
597 pub vao_set_ebo: unsafe extern "C" fn(vao: u32, ebo: u32),
599
600 pub prog_create: unsafe extern "C" fn(vert: YogStr, frag: YogStr, out: *mut u32) -> bool,
604 pub prog_delete: unsafe extern "C" fn(handle: u32),
606 pub prog_uniform_1i: unsafe extern "C" fn(prog: u32, name: YogStr, v: i32),
607 pub prog_uniform_1f: unsafe extern "C" fn(prog: u32, name: YogStr, v: f32),
608 pub prog_uniform_2f: unsafe extern "C" fn(prog: u32, name: YogStr, x: f32, y: f32),
609 pub prog_uniform_3f: unsafe extern "C" fn(prog: u32, name: YogStr, x: f32, y: f32, z: f32),
610 pub prog_uniform_4f:
611 unsafe extern "C" fn(prog: u32, name: YogStr, x: f32, y: f32, z: f32, w: f32),
612 pub prog_uniform_mat4: unsafe extern "C" fn(prog: u32, name: YogStr, col_major: *const f32),
614
615 pub tex_create: unsafe extern "C" fn(w: u32, h: u32, rgba: *const u8, linear: bool) -> u32,
619 pub tex_delete: unsafe extern "C" fn(handle: u32),
621 pub tex_bind: unsafe extern "C" fn(unit: u32, handle: u32),
623 pub tex_from_mc: unsafe extern "C" fn(id: YogStr) -> u32,
627
628 pub draw_arrays: unsafe extern "C" fn(vao: u32, prog: u32, mode: u8, first: u32, count: u32),
632 pub draw_elements:
635 unsafe extern "C" fn(vao: u32, ebo: u32, prog: u32, mode: u8, count: u32, u32_idx: bool),
636
637 pub set_blend: unsafe extern "C" fn(enabled: bool, src: u32, dst: u32),
640 pub set_depth: unsafe extern "C" fn(test: bool, write: bool),
642 pub set_scissor: unsafe extern "C" fn(x: i32, y: i32, w: i32, h: i32),
644 pub clear_scissor: unsafe extern "C" fn(),
646 pub set_viewport: unsafe extern "C" fn(x: i32, y: i32, w: i32, h: i32),
648
649 pub draw2d_rect: unsafe extern "C" fn(x1: f32, y1: f32, x2: f32, y2: f32, color: u32),
652 pub draw2d_gradient:
654 unsafe extern "C" fn(x1: f32, y1: f32, x2: f32, y2: f32, top: u32, bottom: u32),
655 pub draw2d_text: unsafe extern "C" fn(text: YogStr, x: f32, y: f32, color: u32, shadow: bool),
657 pub draw2d_mc_tex: unsafe extern "C" fn(
660 id: YogStr,
661 x: f32,
662 y: f32,
663 u0: f32,
664 v0: f32,
665 w: f32,
666 h: f32,
667 tw: f32,
668 th: f32,
669 ),
670
671 pub draw2d_item: unsafe extern "C" fn(id: YogStr, x: f32, y: f32, size: f32),
677
678 pub draw2d_text_font: unsafe extern "C" fn(
684 text: YogStr,
685 font: YogStr,
686 x: f32,
687 y: f32,
688 color: u32,
689 shadow: bool,
690 ),
691 pub text_width: unsafe extern "C" fn(text: YogStr, font: YogStr) -> f32,
696}
697
698unsafe impl Send for YogGfxApi {}
699unsafe impl Sync for YogGfxApi {}
700
701#[repr(C)]
711pub struct YogServer {
712 pub ctx: *mut c_void,
713 pub abi_version: u32,
714 pub size: u32,
717
718 pub free_str: unsafe extern "C" fn(ptr: *mut u8, len: u32),
720
721 pub broadcast: unsafe extern "C" fn(ctx: *mut c_void, msg: YogStr),
723
724 pub get_block:
726 unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos) -> YogOwnedStr,
727 pub set_block: unsafe extern "C" fn(
728 ctx: *mut c_void,
729 dim: YogStr,
730 pos: YogBlockPos,
731 block: YogStr,
732 ) -> bool,
733 pub world_time: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, out: *mut i64) -> bool,
734 pub set_time: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, time: i64) -> bool,
735 pub is_raining: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr) -> bool,
736 pub set_weather:
737 unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, raining: bool, dur: i32) -> bool,
738
739 pub give_item:
741 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, item: YogStr, count: u32) -> bool,
742 pub player_teleport:
743 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, pos: YogVec3) -> bool,
744 pub send_to_player: unsafe extern "C" fn(
745 ctx: *mut c_void,
746 player: YogStr,
747 channel: YogStr,
748 data: *const u8,
749 len: u32,
750 ) -> bool,
751 pub send_to_server:
752 unsafe extern "C" fn(ctx: *mut c_void, channel: YogStr, data: *const u8, len: u32) -> bool,
753 pub kick_player: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, reason: YogStr) -> bool,
754 pub set_gamemode: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, mode: YogStr) -> bool,
755 pub send_title: unsafe extern "C" fn(
756 ctx: *mut c_void,
757 player: YogStr,
758 title: YogStr,
759 sub: YogStr,
760 fi: i32,
761 stay: i32,
762 fo: i32,
763 ) -> bool,
764 pub send_actionbar: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, msg: YogStr) -> bool,
765 pub play_sound: unsafe extern "C" fn(
766 ctx: *mut c_void,
767 dim: YogStr,
768 pos: YogVec3,
769 sound: YogStr,
770 vol: f32,
771 pitch: f32,
772 ) -> bool,
773 pub play_sound_player: unsafe extern "C" fn(
774 ctx: *mut c_void,
775 player: YogStr,
776 sound: YogStr,
777 vol: f32,
778 pitch: f32,
779 ) -> bool,
780
781 pub entity_teleport: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, pos: YogVec3) -> bool,
783 pub entity_position:
784 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut YogVec3) -> bool,
785 pub entity_health: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut f32) -> bool,
786 pub entity_set_health: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, hp: f32) -> bool,
787 pub entity_kill: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> bool,
788 pub spawn_entity: unsafe extern "C" fn(
789 ctx: *mut c_void,
790 type_id: YogStr,
791 dim: YogStr,
792 pos: YogVec3,
793 ) -> YogOwnedStr,
794 pub entity_add_effect: unsafe extern "C" fn(
795 ctx: *mut c_void,
796 uuid: YogStr,
797 fx: YogStr,
798 dur: i32,
799 amp: u8,
800 particles: bool,
801 ) -> bool,
802 pub entity_remove_effect:
803 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, fx: YogStr) -> bool,
804 pub entity_clear_effects: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> bool,
805 pub entity_velocity:
806 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut YogVec3) -> bool,
807 pub entity_set_velocity:
808 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, vel: YogVec3) -> bool,
809 pub entity_add_velocity:
810 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, vel: YogVec3) -> bool,
811
812 pub has_item_tag: unsafe extern "C" fn(ctx: *mut c_void, item: YogStr, tag: YogStr) -> bool,
814 pub has_block_tag: unsafe extern "C" fn(ctx: *mut c_void, block: YogStr, tag: YogStr) -> bool,
815 pub drop_loot:
816 unsafe extern "C" fn(ctx: *mut c_void, table: YogStr, dim: YogStr, pos: YogVec3) -> bool,
817
818 pub scoreboard_get:
820 unsafe extern "C" fn(ctx: *mut c_void, obj: YogStr, player: YogStr, out: *mut i32) -> bool,
821 pub scoreboard_set:
822 unsafe extern "C" fn(ctx: *mut c_void, obj: YogStr, player: YogStr, score: i32) -> bool,
823 pub scoreboard_add: unsafe extern "C" fn(
824 ctx: *mut c_void,
825 obj: YogStr,
826 player: YogStr,
827 delta: i32,
828 out: *mut i32,
829 ) -> bool,
830
831 pub bossbar_create: unsafe extern "C" fn(
833 ctx: *mut c_void,
834 id: YogStr,
835 title: YogStr,
836 color: YogStr,
837 style: YogStr,
838 ) -> bool,
839 pub bossbar_remove: unsafe extern "C" fn(ctx: *mut c_void, id: YogStr) -> bool,
840 pub bossbar_set_title:
841 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, title: YogStr) -> bool,
842 pub bossbar_set_progress:
843 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, progress: f32) -> bool,
844 pub bossbar_set_color:
845 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, color: YogStr) -> bool,
846 pub bossbar_add_player:
847 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, player: YogStr) -> bool,
848 pub bossbar_remove_player:
849 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, player: YogStr) -> bool,
850 pub bossbar_set_visible:
851 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, visible: bool) -> bool,
852
853 pub game_dir: unsafe extern "C" fn(ctx: *mut c_void) -> YogOwnedStr,
855
856 pub online_players: unsafe extern "C" fn(ctx: *mut c_void) -> YogOwnedStr,
859
860 pub get_block_nbt:
863 unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos) -> YogOwnedStr,
864 pub set_block_nbt:
866 unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos, snbt: YogStr) -> bool,
867
868 pub player_inventory: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr) -> YogOwnedStr,
871 pub player_set_slot: unsafe extern "C" fn(
873 ctx: *mut c_void,
874 player: YogStr,
875 slot: u32,
876 item_id: YogStr,
877 count: u32,
878 ) -> bool,
879
880 pub get_inventory_slot: unsafe extern "C" fn(
884 ctx: *mut c_void,
885 dim: YogStr,
886 pos: YogBlockPos,
887 slot: u32,
888 ) -> YogOwnedStr,
889 pub set_inventory_slot: unsafe extern "C" fn(
892 ctx: *mut c_void,
893 dim: YogStr,
894 pos: YogBlockPos,
895 slot: u32,
896 item_id: YogStr,
897 count: u32,
898 ) -> bool,
899
900 pub player_teleport_dim:
902 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, dim: YogStr, pos: YogVec3) -> bool,
903 pub entity_teleport_dim:
904 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, dim: YogStr, pos: YogVec3) -> bool,
905
906 pub world_entity_count:
909 unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, entity_type: YogStr) -> i32,
910
911 pub entity_get_nbt: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> YogOwnedStr,
914 pub entity_set_nbt: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, snbt: YogStr) -> bool,
916
917 pub spawn_particles: unsafe extern "C" fn(
922 ctx: *mut c_void,
923 dim: YogStr,
924 pos: YogVec3,
925 particle_type: YogStr,
926 count: i32,
927 dx: f64,
928 dy: f64,
929 dz: f64,
930 speed: f64,
931 ) -> bool,
932
933 pub entity_attribute_get:
938 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, attribute_id: YogStr) -> f64,
939 pub entity_attribute_set: unsafe extern "C" fn(
941 ctx: *mut c_void,
942 uuid: YogStr,
943 attribute_id: YogStr,
944 value: f64,
945 ) -> bool,
946
947 pub get_held_item_nbt: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr) -> YogOwnedStr,
951 pub set_held_item_nbt:
954 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, snbt: YogStr) -> bool,
955
956 pub get_offhand_item_nbt: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr) -> YogOwnedStr,
959 pub set_offhand_item_nbt:
962 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, snbt: YogStr) -> bool,
963 pub get_slot_item:
966 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, slot: u32) -> YogOwnedStr,
967 pub set_slot_item: unsafe extern "C" fn(
970 ctx: *mut c_void,
971 player: YogStr,
972 slot: u32,
973 item_id: YogStr,
974 count: u32,
975 snbt: YogStr,
976 ) -> bool,
977
978 pub entity_rotation:
982 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut YogVec3) -> bool,
983}
984
985unsafe impl Send for YogServer {}
987unsafe impl Sync for YogServer {}
988
989#[repr(C)]
996#[derive(Copy, Clone)]
997pub struct YogChunkWriterApi {
998 pub chunk_x: i32,
1000 pub chunk_z: i32,
1002 pub min_y: i32,
1004 pub height: i32,
1006 pub ctx: *mut c_void,
1008 pub set_block:
1011 unsafe extern "C" fn(ctx: *mut c_void, x: i32, y: i32, z: i32, block_id: YogStr) -> bool,
1012}
1013
1014unsafe impl Send for YogChunkWriterApi {}
1015unsafe impl Sync for YogChunkWriterApi {}
1016
1017pub type YogChunkGeneratorFn =
1020 unsafe extern "C" fn(ud: *mut c_void, writer: *const YogChunkWriterApi);
1021
1022#[repr(C)]
1031pub struct YogApi {
1032 pub abi_version: u32,
1033 pub size: u32,
1035 pub ctx: *mut c_void,
1037 pub server: *const YogServer,
1039
1040 pub on_block_break: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogBlockBreakFn),
1043 pub on_chat: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogChatFn),
1044 pub on_player_join: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerFn),
1045 pub on_player_leave: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerFn),
1046 pub on_use_item: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogUseItemFn),
1047 pub on_use_block: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogUseBlockFn),
1048 pub on_attack_entity:
1049 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogAttackEntityFn),
1050 pub on_entity_damage:
1051 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntityDamageFn),
1052 pub on_entity_death:
1053 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntityDeathFn),
1054 pub on_entity_spawn:
1055 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntitySpawnFn),
1056 pub on_player_place_block:
1057 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlaceBlockFn),
1058 pub on_player_death:
1059 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerDeathFn),
1060 pub on_player_respawn:
1061 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerRespawnFn),
1062 pub on_advancement:
1063 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogAdvancementFn),
1064 pub on_entity_interact:
1066 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntityInteractFn),
1067 pub on_item_craft: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogCraftFn),
1068 pub on_explosion: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogExplosionFn),
1069 pub on_item_pickup: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogItemPickupFn),
1071 pub on_player_move: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerMoveFn),
1072 pub on_container_open:
1073 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogContainerOpenFn),
1074 pub on_container_close:
1075 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogContainerCloseFn),
1076 pub on_projectile_hit:
1077 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogProjectileHitFn),
1078 pub on_server_tick: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogServerFn),
1079 pub on_server_started: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogServerFn),
1080 pub on_server_stopping: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogServerFn),
1081
1082 pub on_packet:
1084 unsafe extern "C" fn(ctx: *mut c_void, channel: YogStr, ud: *mut c_void, h: YogPacketFn),
1085 pub on_client_packet:
1086 unsafe extern "C" fn(ctx: *mut c_void, channel: YogStr, ud: *mut c_void, h: YogPacketFn),
1087
1088 pub register_command:
1090 unsafe extern "C" fn(ctx: *mut c_void, name: YogStr, ud: *mut c_void, h: YogCommandFn),
1091 pub register_typed_command: unsafe extern "C" fn(
1092 ctx: *mut c_void,
1093 name: YogStr,
1094 schema: YogStr,
1095 ud: *mut c_void,
1096 h: YogCommandFn,
1097 ),
1098
1099 pub register_recipe_json:
1103 unsafe extern "C" fn(ctx: *mut c_void, namespace: YogStr, name: YogStr, json: YogStr),
1104
1105 pub register_item: unsafe extern "C" fn(ctx: *mut c_void, def: *const YogItemDef),
1107 pub register_block: unsafe extern "C" fn(ctx: *mut c_void, def: *const YogBlockDef),
1108
1109 pub schedule_once: unsafe extern "C" fn(
1111 ctx: *mut c_void,
1112 delay_ticks: u64,
1113 ud: *mut c_void,
1114 h: YogScheduledFn,
1115 ),
1116 pub schedule_repeating: unsafe extern "C" fn(
1117 ctx: *mut c_void,
1118 period_ticks: u64,
1119 ud: *mut c_void,
1120 h: YogScheduledFn,
1121 ),
1122
1123 pub on_client_tick: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogClientFn),
1125 pub on_hud_render: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogHudRenderFn),
1126 pub on_key_press: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogKeyPressFn),
1127 pub on_screen_open: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogScreenFn),
1128 pub on_screen_close: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogScreenFn),
1129
1130 pub on_world_render:
1135 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogWorldRenderFn),
1136
1137 pub register_startup_grant:
1139 unsafe extern "C" fn(ctx: *mut c_void, grant: *const YogStartupGrantDef),
1140
1141 pub register_book: unsafe extern "C" fn(ctx: *mut c_void, book_id: YogStr, book_json: YogStr),
1143
1144 pub register_ui: unsafe extern "C" fn(
1149 ctx: *mut c_void,
1150 ui_id: YogStr,
1151 layout_json: YogStr,
1152 ud: *mut c_void,
1153 h: YogUIEventFn,
1154 ),
1155
1156 pub on_ui_render:
1163 unsafe extern "C" fn(ctx: *mut c_void, ui_id: YogStr, ud: *mut c_void, h: YogHudRenderFn),
1164
1165 pub register_menu_entry: unsafe extern "C" fn(ctx: *mut c_void, label: YogStr, ui_id: YogStr),
1171
1172 pub mods_list: unsafe extern "C" fn(ctx: *mut c_void) -> YogOwnedStr,
1179 pub free_str: unsafe extern "C" fn(ptr: *mut u8, len: u32),
1182
1183 pub ui_open: unsafe extern "C" fn(ctx: *mut c_void, ui_id: YogStr, modal: bool, pause: bool),
1188
1189 pub register_inventory: unsafe extern "C" fn(ctx: *mut c_void, def: *const YogInventoryDef),
1192
1193 pub interop_export:
1197 unsafe extern "C" fn(ctx: *mut c_void, mod_id: YogStr, symbol: YogStr, ptr: *const c_void),
1198 pub interop_import:
1201 unsafe extern "C" fn(ctx: *mut c_void, mod_id: YogStr, symbol: YogStr) -> *const c_void,
1202
1203 pub register_dimension_json: unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, json: YogStr),
1209 pub register_chunk_generator:
1213 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, ud: *mut c_void, h: YogChunkGeneratorFn),
1214
1215 pub ui_close: unsafe extern "C" fn(ctx: *mut c_void, ui_id: YogStr),
1220 pub ui_consume_event: unsafe extern "C" fn(ctx: *mut c_void),
1224
1225 pub translate: unsafe extern "C" fn(ctx: *mut c_void, key: YogStr) -> YogOwnedStr,
1233}
1234
1235unsafe impl Send for YogApi {}
1236unsafe impl Sync for YogApi {}