1use std::os::raw::c_void;
13
14pub const ABI_MAJOR: u32 = 0;
17pub const ABI_MINOR: u32 = 25;
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 pub sneaking: bool,
124}
125
126#[repr(C)]
127pub struct YogUseBlockEvent {
128 pub player: YogStr,
129 pub block: YogStr,
130 pub pos: YogBlockPos,
131}
132
133#[repr(C)]
134pub struct YogAttackEntityEvent {
135 pub player: YogStr,
136 pub target_type: YogStr,
137 pub target_uuid: YogStr,
138}
139
140#[repr(C)]
141pub struct YogEntityDamageEvent {
142 pub entity_type: YogStr,
143 pub uuid: YogStr,
144 pub amount: f32,
145 pub source: YogStr,
146}
147
148#[repr(C)]
149pub struct YogEntityDeathEvent {
150 pub entity_type: YogStr,
151 pub uuid: YogStr,
152 pub source: YogStr,
153}
154
155#[repr(C)]
156pub struct YogEntitySpawnEvent {
157 pub entity_type: YogStr,
158 pub uuid: YogStr,
159 pub dimension: YogStr,
160}
161
162#[repr(C)]
165pub struct YogPlayerDeathEvent {
166 pub player: YogStr,
167 pub uuid: YogStr,
168 pub source: YogStr,
170}
171
172#[repr(C)]
174pub struct YogPlayerRespawnEvent {
175 pub player: YogStr,
176 pub uuid: YogStr,
177 pub at_anchor: bool,
179}
180
181#[repr(C)]
183pub struct YogAdvancementEvent {
184 pub player: YogStr,
185 pub uuid: YogStr,
186 pub advancement: YogStr,
188}
189
190#[repr(C)]
193pub struct YogEntityInteractEvent {
194 pub player: YogStr,
195 pub player_uuid: YogStr,
196 pub entity_type: YogStr,
197 pub entity_uuid: YogStr,
198 pub hand: YogStr,
200}
201
202#[repr(C)]
204pub struct YogCraftEvent {
205 pub player: YogStr,
206 pub player_uuid: YogStr,
207 pub result_item: YogStr,
208 pub result_count: u32,
209}
210
211#[repr(C)]
214pub struct YogExplosionEvent {
215 pub dimension: YogStr,
216 pub x: f64,
217 pub y: f64,
218 pub z: f64,
219 pub power: f32,
220 pub cause_uuid: YogStr,
222}
223
224#[repr(C)]
228pub struct YogItemPickupEvent {
229 pub player: YogStr,
230 pub player_uuid: YogStr,
231 pub item_id: YogStr,
233 pub item_count: u32,
234 pub entity_uuid: YogStr,
236}
237
238#[repr(C)]
240pub struct YogPlayerMoveEvent {
241 pub player: YogStr,
242 pub player_uuid: YogStr,
243 pub x: f64,
244 pub y: f64,
245 pub z: f64,
246 pub yaw: f32,
247 pub pitch: f32,
248}
249
250#[repr(C)]
254pub struct YogContainerOpenEvent {
255 pub player: YogStr,
256 pub player_uuid: YogStr,
257 pub container_type: YogStr,
258}
259
260#[repr(C)]
262pub struct YogContainerCloseEvent {
263 pub player: YogStr,
264 pub player_uuid: YogStr,
265}
266
267#[repr(C)]
270pub struct YogProjectileHitEvent {
271 pub projectile_type: YogStr,
273 pub projectile_uuid: YogStr,
274 pub shooter_uuid: YogStr,
276 pub hit_type: YogStr,
278 pub hit_entity_uuid: YogStr,
280 pub x: f64,
281 pub y: f64,
282 pub z: f64,
283 pub dimension: YogStr,
284}
285
286#[repr(C)]
288pub struct YogPlaceBlockEvent {
289 pub player: YogStr,
290 pub block: YogStr,
291 pub pos: YogBlockPos,
292}
293
294#[repr(C)]
295pub struct YogPacketEvent {
296 pub channel: YogStr,
297 pub player: YogStr, pub payload: *const u8,
299 pub payload_len: u32,
300}
301
302#[repr(C)]
303pub struct YogCommandEvent {
304 pub name: YogStr,
305 pub args: YogStr,
306 pub source: YogStr,
307 pub uuid: YogStr,
308}
309
310#[repr(C)]
312pub struct YogStartupGrantDef {
313 pub id: YogStr,
314 pub items: YogStr, pub book: YogStr, pub command: YogStr, }
318
319#[repr(C)]
322pub struct YogItemDef {
323 pub id: YogStr,
324 pub max_stack: u32,
325 pub name: YogStr, pub tooltip: YogStr, pub max_damage: u32,
328 pub fire_resistant: bool,
329 pub fuel_ticks: u32,
330 pub food_nutrition: u32, pub food_saturation: f32,
332 pub food_always_eat: bool,
333}
334
335#[repr(C)]
336pub struct YogBlockDef {
337 pub id: YogStr,
338 pub hardness: f32,
339 pub resistance: f32,
340 pub name: YogStr,
341 pub light_level: u8,
342 pub sound: YogStr, pub requires_tool: bool,
344 pub no_collision: bool,
345 pub slipperiness: f32,
346 pub shape: [f32; 6],
348}
349
350#[repr(C)]
354#[derive(Copy, Clone)]
355pub struct YogKeyPressEvent {
356 pub key_code: i32,
358 pub scan_code: i32,
359 pub action: i32,
361 pub modifiers: i32,
363}
364
365pub type YogBlockBreakFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogBlockBreakEvent, u8) -> bool;
377pub type YogChatFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogChatEvent, u8) -> bool;
378pub type YogPlayerFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerEvent, u8) -> bool;
379pub type YogUseItemFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogUseItemEvent, u8) -> bool;
380pub type YogUseBlockFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogUseBlockEvent, u8) -> bool;
381pub type YogAttackEntityFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogAttackEntityEvent, u8) -> bool;
382pub type YogEntityDamageFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntityDamageEvent, u8) -> bool;
383pub type YogEntityDeathFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntityDeathEvent, u8) -> bool;
384pub type YogEntitySpawnFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntitySpawnEvent, u8) -> bool;
385pub type YogPlaceBlockFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlaceBlockEvent, u8) -> bool;
386pub type YogPlayerDeathFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerDeathEvent, u8) -> bool;
387pub type YogPlayerRespawnFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerRespawnEvent, u8) -> bool;
388pub type YogAdvancementFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogAdvancementEvent, u8) -> bool;
389pub type YogEntityInteractFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntityInteractEvent, u8) -> bool;
390pub type YogCraftFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogCraftEvent, u8) -> bool;
391pub type YogExplosionFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogExplosionEvent, u8) -> bool;
392pub type YogItemPickupFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogItemPickupEvent, u8) -> bool;
393pub type YogPlayerMoveFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerMoveEvent, u8) -> bool;
394pub type YogContainerOpenFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogContainerOpenEvent, u8) -> bool;
395pub type YogContainerCloseFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogContainerCloseEvent, u8) -> bool;
396pub type YogProjectileHitFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogProjectileHitEvent, u8) -> bool;
397
398pub type YogPacketFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPacketEvent);
400pub type YogServerFn = unsafe extern "C" fn(*mut c_void, *const YogServer);
402pub type YogCommandFn = unsafe extern "C" fn(
404 ud: *mut c_void,
405 srv: *const YogServer,
406 ev: *const YogCommandEvent,
407 reply_buf: *mut u8,
408 reply_cap: u32,
409 reply_len: *mut u32,
410);
411pub type YogScheduledFn = unsafe extern "C" fn(*mut c_void, *const YogServer);
413
414pub type YogClientFn = unsafe extern "C" fn(ud: *mut c_void);
418pub type YogUIEventFn = unsafe extern "C" fn(ud: *mut c_void, ui_id: YogStr, event_id: YogStr);
421pub type YogHudRenderFn = unsafe extern "C" fn(ud: *mut c_void, gfx: *const YogGfxApi);
422pub type YogWorldRenderFn = unsafe extern "C" fn(ud: *mut c_void, gfx: *const YogGfxApi);
425pub type YogKeyPressFn = unsafe extern "C" fn(ud: *mut c_void, ev: *const YogKeyPressEvent) -> bool;
427pub type YogScreenFn = unsafe extern "C" fn(ud: *mut c_void, screen_class: YogStr) -> bool;
430
431#[repr(C)]
447#[derive(Copy, Clone)]
448pub struct YogGfxApi {
449 pub screen_w: i32,
452 pub screen_h: i32,
454 pub delta_tick: f32,
456 pub scale_factor: f32,
459 pub view_proj: [f32; 16],
462 pub camera_pos: [f32; 3],
464 pub player_pos: [f32; 3],
467 pub _pad1: f32,
468
469 pub buf_create: unsafe extern "C" fn() -> u32,
472 pub buf_delete: unsafe extern "C" fn(handle: u32),
474 pub buf_data: unsafe extern "C" fn(handle: u32, bytes: *const u8, len: u32, dynamic: bool),
477 pub buf_subdata: unsafe extern "C" fn(handle: u32, offset: u32, bytes: *const u8, len: u32),
479
480 pub vao_create: unsafe extern "C" fn() -> u32,
483 pub vao_delete: unsafe extern "C" fn(handle: u32),
485 pub vao_attrib: unsafe extern "C" fn(
488 vao: u32, vbo: u32, index: u32, components: u8,
489 dtype: u8, normalized: bool, stride: u32, offset: u32,
490 ),
491 pub vao_set_ebo: unsafe extern "C" fn(vao: u32, ebo: u32),
493
494 pub prog_create: unsafe extern "C" fn(vert: YogStr, frag: YogStr, out: *mut u32) -> bool,
498 pub prog_delete: unsafe extern "C" fn(handle: u32),
500 pub prog_uniform_1i: unsafe extern "C" fn(prog: u32, name: YogStr, v: i32),
501 pub prog_uniform_1f: unsafe extern "C" fn(prog: u32, name: YogStr, v: f32),
502 pub prog_uniform_2f: unsafe extern "C" fn(prog: u32, name: YogStr, x: f32, y: f32),
503 pub prog_uniform_3f: unsafe extern "C" fn(prog: u32, name: YogStr, x: f32, y: f32, z: f32),
504 pub prog_uniform_4f: unsafe extern "C" fn(prog: u32, name: YogStr, x: f32, y: f32, z: f32, w: f32),
505 pub prog_uniform_mat4: unsafe extern "C" fn(prog: u32, name: YogStr, col_major: *const f32),
507
508 pub tex_create: unsafe extern "C" fn(w: u32, h: u32, rgba: *const u8, linear: bool) -> u32,
512 pub tex_delete: unsafe extern "C" fn(handle: u32),
514 pub tex_bind: unsafe extern "C" fn(unit: u32, handle: u32),
516 pub tex_from_mc: unsafe extern "C" fn(id: YogStr) -> u32,
520
521 pub draw_arrays: unsafe extern "C" fn(vao: u32, prog: u32, mode: u8, first: u32, count: u32),
525 pub draw_elements: unsafe extern "C" fn(vao: u32, ebo: u32, prog: u32, mode: u8, count: u32, u32_idx: bool),
528
529 pub set_blend: unsafe extern "C" fn(enabled: bool, src: u32, dst: u32),
532 pub set_depth: unsafe extern "C" fn(test: bool, write: bool),
534 pub set_scissor: unsafe extern "C" fn(x: i32, y: i32, w: i32, h: i32),
536 pub clear_scissor: unsafe extern "C" fn(),
538 pub set_viewport: unsafe extern "C" fn(x: i32, y: i32, w: i32, h: i32),
540
541 pub draw2d_rect: unsafe extern "C" fn(x1: f32, y1: f32, x2: f32, y2: f32, color: u32),
544 pub draw2d_gradient: unsafe extern "C" fn(x1: f32, y1: f32, x2: f32, y2: f32, top: u32, bottom: u32),
546 pub draw2d_text: unsafe extern "C" fn(text: YogStr, x: f32, y: f32, color: u32, shadow: bool),
548 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),
551
552 pub draw2d_item: unsafe extern "C" fn(id: YogStr, x: f32, y: f32, size: f32),
558}
559
560unsafe impl Send for YogGfxApi {}
561unsafe impl Sync for YogGfxApi {}
562
563#[repr(C)]
573pub struct YogServer {
574 pub ctx: *mut c_void,
575 pub abi_version: u32,
576 pub size: u32,
579
580 pub free_str: unsafe extern "C" fn(ptr: *mut u8, len: u32),
582
583 pub broadcast: unsafe extern "C" fn(ctx: *mut c_void, msg: YogStr),
585
586 pub get_block: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos) -> YogOwnedStr,
588 pub set_block: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos, block: YogStr) -> bool,
589 pub world_time: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, out: *mut i64) -> bool,
590 pub set_time: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, time: i64) -> bool,
591 pub is_raining: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr) -> bool,
592 pub set_weather: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, raining: bool, dur: i32) -> bool,
593
594 pub give_item: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, item: YogStr, count: u32) -> bool,
596 pub player_teleport: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, pos: YogVec3) -> bool,
597 pub send_to_player: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, channel: YogStr, data: *const u8, len: u32) -> bool,
598 pub send_to_server: unsafe extern "C" fn(ctx: *mut c_void, channel: YogStr, data: *const u8, len: u32) -> bool,
599 pub kick_player: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, reason: YogStr) -> bool,
600 pub set_gamemode: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, mode: YogStr) -> bool,
601 pub send_title: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, title: YogStr, sub: YogStr, fi: i32, stay: i32, fo: i32) -> bool,
602 pub send_actionbar: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, msg: YogStr) -> bool,
603 pub play_sound: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogVec3, sound: YogStr, vol: f32, pitch: f32) -> bool,
604 pub play_sound_player: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, sound: YogStr, vol: f32, pitch: f32) -> bool,
605
606 pub entity_teleport: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, pos: YogVec3) -> bool,
608 pub entity_position: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut YogVec3) -> bool,
609 pub entity_health: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut f32) -> bool,
610 pub entity_set_health: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, hp: f32) -> bool,
611 pub entity_kill: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> bool,
612 pub spawn_entity: unsafe extern "C" fn(ctx: *mut c_void, type_id: YogStr, dim: YogStr, pos: YogVec3) -> YogOwnedStr,
613 pub entity_add_effect: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, fx: YogStr, dur: i32, amp: u8, particles: bool) -> bool,
614 pub entity_remove_effect: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, fx: YogStr) -> bool,
615 pub entity_clear_effects: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> bool,
616 pub entity_velocity: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut YogVec3) -> bool,
617 pub entity_set_velocity: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, vel: YogVec3) -> bool,
618 pub entity_add_velocity: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, vel: YogVec3) -> bool,
619
620 pub has_item_tag: unsafe extern "C" fn(ctx: *mut c_void, item: YogStr, tag: YogStr) -> bool,
622 pub has_block_tag: unsafe extern "C" fn(ctx: *mut c_void, block: YogStr, tag: YogStr) -> bool,
623 pub drop_loot: unsafe extern "C" fn(ctx: *mut c_void, table: YogStr, dim: YogStr, pos: YogVec3) -> bool,
624
625 pub scoreboard_get: unsafe extern "C" fn(ctx: *mut c_void, obj: YogStr, player: YogStr, out: *mut i32) -> bool,
627 pub scoreboard_set: unsafe extern "C" fn(ctx: *mut c_void, obj: YogStr, player: YogStr, score: i32) -> bool,
628 pub scoreboard_add: unsafe extern "C" fn(ctx: *mut c_void, obj: YogStr, player: YogStr, delta: i32, out: *mut i32) -> bool,
629
630 pub bossbar_create: unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, title: YogStr, color: YogStr, style: YogStr) -> bool,
632 pub bossbar_remove: unsafe extern "C" fn(ctx: *mut c_void, id: YogStr) -> bool,
633 pub bossbar_set_title: unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, title: YogStr) -> bool,
634 pub bossbar_set_progress: unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, progress: f32) -> bool,
635 pub bossbar_set_color: unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, color: YogStr) -> bool,
636 pub bossbar_add_player: unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, player: YogStr) -> bool,
637 pub bossbar_remove_player: unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, player: YogStr) -> bool,
638 pub bossbar_set_visible: unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, visible: bool) -> bool,
639
640 pub game_dir: unsafe extern "C" fn(ctx: *mut c_void) -> YogOwnedStr,
642
643 pub online_players: unsafe extern "C" fn(ctx: *mut c_void) -> YogOwnedStr,
646
647 pub get_block_nbt: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos) -> YogOwnedStr,
650 pub set_block_nbt: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos, snbt: YogStr) -> bool,
652
653 pub player_inventory: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr) -> YogOwnedStr,
656 pub player_set_slot: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, slot: u32, item_id: YogStr, count: u32) -> bool,
658
659 pub player_teleport_dim: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, dim: YogStr, pos: YogVec3) -> bool,
661 pub entity_teleport_dim: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, dim: YogStr, pos: YogVec3) -> bool,
662
663 pub world_entity_count: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, entity_type: YogStr) -> i32,
666
667 pub entity_get_nbt: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> YogOwnedStr,
670 pub entity_set_nbt: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, snbt: YogStr) -> bool,
672
673 pub spawn_particles: unsafe extern "C" fn(
678 ctx: *mut c_void,
679 dim: YogStr,
680 pos: YogVec3,
681 particle_type: YogStr,
682 count: i32,
683 dx: f64, dy: f64, dz: f64,
684 speed: f64,
685 ) -> bool,
686
687 pub entity_attribute_get: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, attribute_id: YogStr) -> f64,
692 pub entity_attribute_set: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, attribute_id: YogStr, value: f64) -> bool,
694
695 pub get_held_item_nbt: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr) -> YogOwnedStr,
699 pub set_held_item_nbt: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, snbt: YogStr) -> bool,
702
703 pub get_offhand_item_nbt: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr) -> YogOwnedStr,
706 pub set_offhand_item_nbt: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, snbt: YogStr) -> bool,
709 pub get_slot_item: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, slot: u32) -> YogOwnedStr,
712 pub set_slot_item: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, slot: u32, item_id: YogStr, count: u32, snbt: YogStr) -> bool,
715
716 pub entity_rotation: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut YogVec3) -> bool,
720}
721
722unsafe impl Send for YogServer {}
724unsafe impl Sync for YogServer {}
725
726#[repr(C)]
735pub struct YogApi {
736 pub abi_version: u32,
737 pub size: u32,
739 pub ctx: *mut c_void,
741 pub server: *const YogServer,
743
744 pub on_block_break: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogBlockBreakFn),
747 pub on_chat: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogChatFn),
748 pub on_player_join: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerFn),
749 pub on_player_leave: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerFn),
750 pub on_use_item: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogUseItemFn),
751 pub on_use_block: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogUseBlockFn),
752 pub on_attack_entity: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogAttackEntityFn),
753 pub on_entity_damage: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntityDamageFn),
754 pub on_entity_death: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntityDeathFn),
755 pub on_entity_spawn: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntitySpawnFn),
756 pub on_player_place_block: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlaceBlockFn),
757 pub on_player_death: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerDeathFn),
758 pub on_player_respawn: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerRespawnFn),
759 pub on_advancement: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogAdvancementFn),
760 pub on_entity_interact: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntityInteractFn),
762 pub on_item_craft: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogCraftFn),
763 pub on_explosion: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogExplosionFn),
764 pub on_item_pickup: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogItemPickupFn),
766 pub on_player_move: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerMoveFn),
767 pub on_container_open: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogContainerOpenFn),
768 pub on_container_close: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogContainerCloseFn),
769 pub on_projectile_hit: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogProjectileHitFn),
770 pub on_server_tick: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogServerFn),
771 pub on_server_started: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogServerFn),
772 pub on_server_stopping: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogServerFn),
773
774 pub on_packet: unsafe extern "C" fn(ctx: *mut c_void, channel: YogStr, ud: *mut c_void, h: YogPacketFn),
776 pub on_client_packet: unsafe extern "C" fn(ctx: *mut c_void, channel: YogStr, ud: *mut c_void, h: YogPacketFn),
777
778 pub register_command: unsafe extern "C" fn(ctx: *mut c_void, name: YogStr, ud: *mut c_void, h: YogCommandFn),
780 pub register_typed_command: unsafe extern "C" fn(ctx: *mut c_void, name: YogStr, schema: YogStr, ud: *mut c_void, h: YogCommandFn),
781
782 pub register_recipe_json: unsafe extern "C" fn(ctx: *mut c_void, namespace: YogStr, name: YogStr, json: YogStr),
786
787 pub register_item: unsafe extern "C" fn(ctx: *mut c_void, def: *const YogItemDef),
789 pub register_block: unsafe extern "C" fn(ctx: *mut c_void, def: *const YogBlockDef),
790
791 pub schedule_once: unsafe extern "C" fn(ctx: *mut c_void, delay_ticks: u64, ud: *mut c_void, h: YogScheduledFn),
793 pub schedule_repeating: unsafe extern "C" fn(ctx: *mut c_void, period_ticks: u64, ud: *mut c_void, h: YogScheduledFn),
794
795 pub on_client_tick: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogClientFn),
797 pub on_hud_render: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogHudRenderFn),
798 pub on_key_press: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogKeyPressFn),
799 pub on_screen_open: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogScreenFn),
800 pub on_screen_close: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogScreenFn),
801
802 pub on_world_render: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogWorldRenderFn),
807
808 pub register_startup_grant: unsafe extern "C" fn(ctx: *mut c_void, grant: *const YogStartupGrantDef),
810
811 pub register_book: unsafe extern "C" fn(ctx: *mut c_void, book_id: YogStr, book_json: YogStr),
813
814 pub register_ui: unsafe extern "C" fn(ctx: *mut c_void, ui_id: YogStr, layout_json: YogStr, ud: *mut c_void, h: YogUIEventFn),
819
820 pub on_ui_render: unsafe extern "C" fn(ctx: *mut c_void, ui_id: YogStr, ud: *mut c_void, h: YogHudRenderFn),
827
828 pub register_menu_entry: unsafe extern "C" fn(ctx: *mut c_void, label: YogStr, ui_id: YogStr),
834
835 pub mods_list: unsafe extern "C" fn(ctx: *mut c_void) -> YogOwnedStr,
842 pub free_str: unsafe extern "C" fn(ptr: *mut u8, len: u32),
845
846 pub ui_open: unsafe extern "C" fn(ctx: *mut c_void, ui_id: YogStr, modal: bool, pause: bool),
851}
852
853unsafe impl Send for YogApi {}
854unsafe impl Sync for YogApi {}