1use std::os::raw::c_void;
13
14pub const ABI_MAJOR: u32 = 1;
17pub const ABI_MINOR: u32 = 2;
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
658 pub draw2d_item: unsafe extern "C" fn(id: YogStr, x: f32, y: f32, size: f32),
664
665 pub draw2d_text_font:
671 unsafe extern "C" fn(text: YogStr, font: YogStr, x: f32, y: f32, color: u32, shadow: bool),
672 pub text_width: unsafe extern "C" fn(text: YogStr, font: YogStr) -> f32,
677
678 pub draw2d_image: unsafe extern "C" fn(
689 source: YogStr,
690 x: f32,
691 y: f32,
692 w: f32,
693 h: f32,
694 u: f32,
695 v: f32,
696 uw: f32,
697 vh: f32,
698 tint: u32,
699 ),
700 pub image_size: unsafe extern "C" fn(source: YogStr, w: *mut f32, h: *mut f32) -> bool,
705}
706
707unsafe impl Send for YogGfxApi {}
708unsafe impl Sync for YogGfxApi {}
709
710#[repr(C)]
720pub struct YogServer {
721 pub ctx: *mut c_void,
722 pub abi_version: u32,
723 pub size: u32,
726
727 pub free_str: unsafe extern "C" fn(ptr: *mut u8, len: u32),
729
730 pub broadcast: unsafe extern "C" fn(ctx: *mut c_void, msg: YogStr),
732
733 pub get_block:
735 unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos) -> YogOwnedStr,
736 pub set_block: unsafe extern "C" fn(
737 ctx: *mut c_void,
738 dim: YogStr,
739 pos: YogBlockPos,
740 block: YogStr,
741 ) -> bool,
742 pub world_time: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, out: *mut i64) -> bool,
743 pub set_time: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, time: i64) -> bool,
744 pub is_raining: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr) -> bool,
745 pub set_weather:
746 unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, raining: bool, dur: i32) -> bool,
747
748 pub give_item:
750 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, item: YogStr, count: u32) -> bool,
751 pub player_teleport:
752 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, pos: YogVec3) -> bool,
753 pub send_to_player: unsafe extern "C" fn(
754 ctx: *mut c_void,
755 player: YogStr,
756 channel: YogStr,
757 data: *const u8,
758 len: u32,
759 ) -> bool,
760 pub send_to_server:
761 unsafe extern "C" fn(ctx: *mut c_void, channel: YogStr, data: *const u8, len: u32) -> bool,
762 pub kick_player: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, reason: YogStr) -> bool,
763 pub set_gamemode: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, mode: YogStr) -> bool,
764 pub send_title: unsafe extern "C" fn(
765 ctx: *mut c_void,
766 player: YogStr,
767 title: YogStr,
768 sub: YogStr,
769 fi: i32,
770 stay: i32,
771 fo: i32,
772 ) -> bool,
773 pub send_actionbar: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, msg: YogStr) -> bool,
774 pub play_sound: unsafe extern "C" fn(
775 ctx: *mut c_void,
776 dim: YogStr,
777 pos: YogVec3,
778 sound: YogStr,
779 vol: f32,
780 pitch: f32,
781 ) -> bool,
782 pub play_sound_player: unsafe extern "C" fn(
783 ctx: *mut c_void,
784 player: YogStr,
785 sound: YogStr,
786 vol: f32,
787 pitch: f32,
788 ) -> bool,
789
790 pub entity_teleport: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, pos: YogVec3) -> bool,
792 pub entity_position:
793 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut YogVec3) -> bool,
794 pub entity_health: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut f32) -> bool,
795 pub entity_set_health: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, hp: f32) -> bool,
796 pub entity_kill: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> bool,
797 pub spawn_entity: unsafe extern "C" fn(
798 ctx: *mut c_void,
799 type_id: YogStr,
800 dim: YogStr,
801 pos: YogVec3,
802 ) -> YogOwnedStr,
803 pub entity_add_effect: unsafe extern "C" fn(
804 ctx: *mut c_void,
805 uuid: YogStr,
806 fx: YogStr,
807 dur: i32,
808 amp: u8,
809 particles: bool,
810 ) -> bool,
811 pub entity_remove_effect:
812 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, fx: YogStr) -> bool,
813 pub entity_clear_effects: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> bool,
814 pub entity_velocity:
815 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut YogVec3) -> bool,
816 pub entity_set_velocity:
817 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, vel: YogVec3) -> bool,
818 pub entity_add_velocity:
819 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, vel: YogVec3) -> bool,
820
821 pub has_item_tag: unsafe extern "C" fn(ctx: *mut c_void, item: YogStr, tag: YogStr) -> bool,
823 pub has_block_tag: unsafe extern "C" fn(ctx: *mut c_void, block: YogStr, tag: YogStr) -> bool,
824 pub drop_loot:
825 unsafe extern "C" fn(ctx: *mut c_void, table: YogStr, dim: YogStr, pos: YogVec3) -> bool,
826
827 pub scoreboard_get:
829 unsafe extern "C" fn(ctx: *mut c_void, obj: YogStr, player: YogStr, out: *mut i32) -> bool,
830 pub scoreboard_set:
831 unsafe extern "C" fn(ctx: *mut c_void, obj: YogStr, player: YogStr, score: i32) -> bool,
832 pub scoreboard_add: unsafe extern "C" fn(
833 ctx: *mut c_void,
834 obj: YogStr,
835 player: YogStr,
836 delta: i32,
837 out: *mut i32,
838 ) -> bool,
839
840 pub bossbar_create: unsafe extern "C" fn(
842 ctx: *mut c_void,
843 id: YogStr,
844 title: YogStr,
845 color: YogStr,
846 style: YogStr,
847 ) -> bool,
848 pub bossbar_remove: unsafe extern "C" fn(ctx: *mut c_void, id: YogStr) -> bool,
849 pub bossbar_set_title:
850 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, title: YogStr) -> bool,
851 pub bossbar_set_progress:
852 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, progress: f32) -> bool,
853 pub bossbar_set_color:
854 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, color: YogStr) -> bool,
855 pub bossbar_add_player:
856 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, player: YogStr) -> bool,
857 pub bossbar_remove_player:
858 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, player: YogStr) -> bool,
859 pub bossbar_set_visible:
860 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, visible: bool) -> bool,
861
862 pub game_dir: unsafe extern "C" fn(ctx: *mut c_void) -> YogOwnedStr,
864
865 pub online_players: unsafe extern "C" fn(ctx: *mut c_void) -> YogOwnedStr,
868
869 pub get_block_nbt:
872 unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos) -> YogOwnedStr,
873 pub set_block_nbt:
875 unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos, snbt: YogStr) -> bool,
876
877 pub player_inventory: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr) -> YogOwnedStr,
880 pub player_set_slot: unsafe extern "C" fn(
882 ctx: *mut c_void,
883 player: YogStr,
884 slot: u32,
885 item_id: YogStr,
886 count: u32,
887 ) -> bool,
888
889 pub get_inventory_slot: unsafe extern "C" fn(
893 ctx: *mut c_void,
894 dim: YogStr,
895 pos: YogBlockPos,
896 slot: u32,
897 ) -> YogOwnedStr,
898 pub set_inventory_slot: unsafe extern "C" fn(
901 ctx: *mut c_void,
902 dim: YogStr,
903 pos: YogBlockPos,
904 slot: u32,
905 item_id: YogStr,
906 count: u32,
907 ) -> bool,
908
909 pub player_teleport_dim:
911 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, dim: YogStr, pos: YogVec3) -> bool,
912 pub entity_teleport_dim:
913 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, dim: YogStr, pos: YogVec3) -> bool,
914
915 pub world_entity_count:
918 unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, entity_type: YogStr) -> i32,
919
920 pub entity_get_nbt: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> YogOwnedStr,
923 pub entity_set_nbt: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, snbt: YogStr) -> bool,
925
926 pub spawn_particles: unsafe extern "C" fn(
931 ctx: *mut c_void,
932 dim: YogStr,
933 pos: YogVec3,
934 particle_type: YogStr,
935 count: i32,
936 dx: f64,
937 dy: f64,
938 dz: f64,
939 speed: f64,
940 ) -> bool,
941
942 pub entity_attribute_get:
947 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, attribute_id: YogStr) -> f64,
948 pub entity_attribute_set: unsafe extern "C" fn(
950 ctx: *mut c_void,
951 uuid: YogStr,
952 attribute_id: YogStr,
953 value: f64,
954 ) -> bool,
955
956 pub get_held_item_nbt: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr) -> YogOwnedStr,
960 pub set_held_item_nbt:
963 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, snbt: YogStr) -> bool,
964
965 pub get_offhand_item_nbt: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr) -> YogOwnedStr,
968 pub set_offhand_item_nbt:
971 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, snbt: YogStr) -> bool,
972 pub get_slot_item:
975 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, slot: u32) -> YogOwnedStr,
976 pub set_slot_item: unsafe extern "C" fn(
979 ctx: *mut c_void,
980 player: YogStr,
981 slot: u32,
982 item_id: YogStr,
983 count: u32,
984 snbt: YogStr,
985 ) -> bool,
986
987 pub entity_rotation:
991 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut YogVec3) -> bool,
992
993 pub entity_info: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> YogOwnedStr,
998 pub entities_in_box: unsafe extern "C" fn(
1000 ctx: *mut c_void,
1001 dim: YogStr,
1002 min: YogVec3,
1003 max: YogVec3,
1004 ) -> YogOwnedStr,
1005 pub raycast_block: unsafe extern "C" fn(
1007 ctx: *mut c_void,
1008 dim: YogStr,
1009 from: YogVec3,
1010 to: YogVec3,
1011 ) -> YogOwnedStr,
1012 pub raycast_entity: unsafe extern "C" fn(
1014 ctx: *mut c_void,
1015 dim: YogStr,
1016 from: YogVec3,
1017 to: YogVec3,
1018 exclude: YogStr,
1019 ) -> YogOwnedStr,
1020 pub block_info:
1022 unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos) -> YogOwnedStr,
1023 pub break_block: unsafe extern "C" fn(
1024 ctx: *mut c_void,
1025 dim: YogStr,
1026 pos: YogBlockPos,
1027 drop: bool,
1028 breaker: YogStr,
1029 ) -> bool,
1030 pub place_block_from_slot: unsafe extern "C" fn(
1031 ctx: *mut c_void,
1032 player: YogStr,
1033 slot: u32,
1034 dim: YogStr,
1035 pos: YogBlockPos,
1036 ) -> bool,
1037 pub bonemeal: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos) -> bool,
1038 pub explode: unsafe extern "C" fn(
1039 ctx: *mut c_void,
1040 dim: YogStr,
1041 pos: YogVec3,
1042 power: f32,
1043 fire: bool,
1044 source: YogStr,
1045 ) -> bool,
1046 pub tellraw: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, json: YogStr) -> bool,
1048 pub entity_damage: unsafe extern "C" fn(
1049 ctx: *mut c_void,
1050 uuid: YogStr,
1051 amount: f32,
1052 damage_type: YogStr,
1053 attacker: YogStr,
1054 ) -> bool,
1055 pub entity_set_fire_ticks:
1056 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, ticks: i32) -> bool,
1057 pub player_add_xp: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, amount: i32) -> bool,
1058 pub player_set_may_fly:
1059 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, may_fly: bool) -> bool,
1060 pub player_info: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr) -> YogOwnedStr,
1062 pub spawn_item: unsafe extern "C" fn(
1064 ctx: *mut c_void,
1065 dim: YogStr,
1066 pos: YogVec3,
1067 vel: YogVec3,
1068 item_id: YogStr,
1069 count: u32,
1070 snbt: YogStr,
1071 ) -> YogOwnedStr,
1072 pub item_entity_stack: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> YogOwnedStr,
1074 pub item_entity_set_stack: unsafe extern "C" fn(
1075 ctx: *mut c_void,
1076 uuid: YogStr,
1077 item_id: YogStr,
1078 count: u32,
1079 snbt: YogStr,
1080 ) -> bool,
1081 pub actionbar_json:
1084 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, json: YogStr) -> bool,
1085 pub use_item_on_block: unsafe extern "C" fn(
1087 ctx: *mut c_void,
1088 dim: YogStr,
1089 pos: YogBlockPos,
1090 face: u8,
1091 item_id: YogStr,
1092 player: YogStr,
1093 ) -> bool,
1094 pub pour_fluid: unsafe extern "C" fn(
1095 ctx: *mut c_void,
1096 dim: YogStr,
1097 pos: YogBlockPos,
1098 bucket_item_id: YogStr,
1099 ) -> bool,
1100 pub has_entity_tag:
1101 unsafe extern "C" fn(ctx: *mut c_void, entity_type: YogStr, tag_id: YogStr) -> bool,
1102 pub item_block: unsafe extern "C" fn(ctx: *mut c_void, item_id: YogStr) -> YogOwnedStr,
1104 pub place_feature: unsafe extern "C" fn(
1105 ctx: *mut c_void,
1106 dim: YogStr,
1107 pos: YogBlockPos,
1108 feature_id: YogStr,
1109 ) -> bool,
1110}
1111
1112unsafe impl Send for YogServer {}
1114unsafe impl Sync for YogServer {}
1115
1116#[repr(C)]
1123#[derive(Copy, Clone)]
1124pub struct YogChunkWriterApi {
1125 pub chunk_x: i32,
1127 pub chunk_z: i32,
1129 pub min_y: i32,
1131 pub height: i32,
1133 pub ctx: *mut c_void,
1135 pub set_block:
1138 unsafe extern "C" fn(ctx: *mut c_void, x: i32, y: i32, z: i32, block_id: YogStr) -> bool,
1139}
1140
1141unsafe impl Send for YogChunkWriterApi {}
1142unsafe impl Sync for YogChunkWriterApi {}
1143
1144pub type YogChunkGeneratorFn =
1147 unsafe extern "C" fn(ud: *mut c_void, writer: *const YogChunkWriterApi);
1148
1149#[repr(C)]
1158pub struct YogApi {
1159 pub abi_version: u32,
1160 pub size: u32,
1162 pub ctx: *mut c_void,
1164 pub server: *const YogServer,
1166
1167 pub on_block_break: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogBlockBreakFn),
1170 pub on_chat: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogChatFn),
1171 pub on_player_join: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerFn),
1172 pub on_player_leave: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerFn),
1173 pub on_use_item: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogUseItemFn),
1174 pub on_use_block: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogUseBlockFn),
1175 pub on_attack_entity:
1176 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogAttackEntityFn),
1177 pub on_entity_damage:
1178 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntityDamageFn),
1179 pub on_entity_death:
1180 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntityDeathFn),
1181 pub on_entity_spawn:
1182 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntitySpawnFn),
1183 pub on_player_place_block:
1184 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlaceBlockFn),
1185 pub on_player_death:
1186 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerDeathFn),
1187 pub on_player_respawn:
1188 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerRespawnFn),
1189 pub on_advancement:
1190 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogAdvancementFn),
1191 pub on_entity_interact:
1193 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntityInteractFn),
1194 pub on_item_craft: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogCraftFn),
1195 pub on_explosion: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogExplosionFn),
1196 pub on_item_pickup: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogItemPickupFn),
1198 pub on_player_move: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerMoveFn),
1199 pub on_container_open:
1200 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogContainerOpenFn),
1201 pub on_container_close:
1202 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogContainerCloseFn),
1203 pub on_projectile_hit:
1204 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogProjectileHitFn),
1205 pub on_server_tick: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogServerFn),
1206 pub on_server_started: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogServerFn),
1207 pub on_server_stopping: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogServerFn),
1208
1209 pub on_packet:
1211 unsafe extern "C" fn(ctx: *mut c_void, channel: YogStr, ud: *mut c_void, h: YogPacketFn),
1212 pub on_client_packet:
1213 unsafe extern "C" fn(ctx: *mut c_void, channel: YogStr, ud: *mut c_void, h: YogPacketFn),
1214
1215 pub register_command:
1217 unsafe extern "C" fn(ctx: *mut c_void, name: YogStr, ud: *mut c_void, h: YogCommandFn),
1218 pub register_typed_command: unsafe extern "C" fn(
1219 ctx: *mut c_void,
1220 name: YogStr,
1221 schema: YogStr,
1222 ud: *mut c_void,
1223 h: YogCommandFn,
1224 ),
1225
1226 pub register_recipe_json:
1230 unsafe extern "C" fn(ctx: *mut c_void, namespace: YogStr, name: YogStr, json: YogStr),
1231
1232 pub register_item: unsafe extern "C" fn(ctx: *mut c_void, def: *const YogItemDef),
1234 pub register_block: unsafe extern "C" fn(ctx: *mut c_void, def: *const YogBlockDef),
1235
1236 pub schedule_once: unsafe extern "C" fn(
1238 ctx: *mut c_void,
1239 delay_ticks: u64,
1240 ud: *mut c_void,
1241 h: YogScheduledFn,
1242 ),
1243 pub schedule_repeating: unsafe extern "C" fn(
1244 ctx: *mut c_void,
1245 period_ticks: u64,
1246 ud: *mut c_void,
1247 h: YogScheduledFn,
1248 ),
1249
1250 pub on_client_tick: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogClientFn),
1252 pub on_hud_render: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogHudRenderFn),
1253 pub on_key_press: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogKeyPressFn),
1254 pub on_screen_open: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogScreenFn),
1255 pub on_screen_close: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogScreenFn),
1256
1257 pub on_world_render:
1262 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogWorldRenderFn),
1263
1264 pub register_startup_grant:
1266 unsafe extern "C" fn(ctx: *mut c_void, grant: *const YogStartupGrantDef),
1267
1268 pub register_book: unsafe extern "C" fn(ctx: *mut c_void, book_id: YogStr, book_json: YogStr),
1270
1271 pub register_ui: unsafe extern "C" fn(
1276 ctx: *mut c_void,
1277 ui_id: YogStr,
1278 layout_json: YogStr,
1279 ud: *mut c_void,
1280 h: YogUIEventFn,
1281 ),
1282
1283 pub on_ui_render:
1290 unsafe extern "C" fn(ctx: *mut c_void, ui_id: YogStr, ud: *mut c_void, h: YogHudRenderFn),
1291
1292 pub register_menu_entry: unsafe extern "C" fn(ctx: *mut c_void, label: YogStr, ui_id: YogStr),
1298
1299 pub mods_list: unsafe extern "C" fn(ctx: *mut c_void) -> YogOwnedStr,
1306 pub free_str: unsafe extern "C" fn(ptr: *mut u8, len: u32),
1309
1310 pub ui_open: unsafe extern "C" fn(ctx: *mut c_void, ui_id: YogStr, modal: bool, pause: bool),
1315
1316 pub register_inventory: unsafe extern "C" fn(ctx: *mut c_void, def: *const YogInventoryDef),
1319
1320 pub interop_export:
1324 unsafe extern "C" fn(ctx: *mut c_void, mod_id: YogStr, symbol: YogStr, ptr: *const c_void),
1325 pub interop_import:
1328 unsafe extern "C" fn(ctx: *mut c_void, mod_id: YogStr, symbol: YogStr) -> *const c_void,
1329
1330 pub register_dimension_json: unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, json: YogStr),
1336 pub register_chunk_generator:
1340 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, ud: *mut c_void, h: YogChunkGeneratorFn),
1341
1342 pub ui_close: unsafe extern "C" fn(ctx: *mut c_void, ui_id: YogStr),
1347 pub ui_consume_event: unsafe extern "C" fn(ctx: *mut c_void),
1351
1352 pub translate: unsafe extern "C" fn(ctx: *mut c_void, key: YogStr) -> YogOwnedStr,
1360
1361 pub ui_open_flags: unsafe extern "C" fn(ctx: *mut c_void, ui_id: YogStr, flags: u32),
1366 pub client_play_sound: unsafe extern "C" fn(
1370 ctx: *mut c_void,
1371 sound_id: YogStr,
1372 volume: f32,
1373 pitch: f32,
1374 looping: bool,
1375 ) -> u32,
1376 pub client_stop_sound: unsafe extern "C" fn(ctx: *mut c_void, handle: u32),
1378 pub client_held_item: unsafe extern "C" fn(ctx: *mut c_void, off_hand: bool) -> YogOwnedStr,
1381 pub client_key_down: unsafe extern "C" fn(ctx: *mut c_void, key: i32) -> bool,
1383}
1384
1385pub mod ui_flags {
1387 pub const MODAL: u32 = 1;
1389 pub const PAUSE: u32 = 1 << 1;
1391 pub const NO_BACKGROUND: u32 = 1 << 2;
1393}
1394
1395unsafe impl Send for YogApi {}
1396unsafe impl Sync for YogApi {}