1mod interop;
9mod registry;
10
11pub use interop::Interop;
12pub use registry::{installed_mods, open_ui, server, CServer, Mod, ModInfo, Registry};
13pub use yog_gfx::{GfxContext, core as gfx_core, gl as gfx_gl, draw2d as gfx_draw2d};
14
15pub use yog_abi::{ABI_VERSION, YogApi};
17
18#[doc(hidden)]
19pub use std::os::raw::c_void as __c_void;
20
21#[macro_export]
34macro_rules! export_mod {
35 ($mod_ty:ty) => {
36 #[no_mangle]
37 pub extern "C" fn yog_abi_version() -> u32 {
38 $crate::ABI_VERSION
39 }
40
41 #[no_mangle]
42 pub unsafe extern "C" fn yog_mod_register(
43 api: *const $crate::YogApi,
44 mod_id_ptr: *const ::std::os::raw::c_char,
45 ) {
46 let mod_id: &str = if mod_id_ptr.is_null() {
48 "unknown"
49 } else {
50 match ::std::ffi::CStr::from_ptr(mod_id_ptr).to_str() {
51 Ok(s) => s,
52 Err(_) => "unknown",
53 }
54 };
55 $crate::__set_current_mod_id(mod_id);
57
58 let outcome = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| {
61 let mut registry = unsafe { $crate::Registry::from_raw(api) };
64 <$mod_ty as $crate::Mod>::register(&mut registry);
65 }));
66 if outcome.is_err() {
67 $crate::error!("mod {} panicked during register", ::core::stringify!($mod_ty));
68 }
69 }
70 };
71}
72
73#[doc(hidden)]
77pub fn __set_current_mod_id(id: &str) {
78 CURRENT_MOD_ID.with(|cell| cell.replace(Some(id.to_string())));
79}
80
81#[doc(hidden)]
83pub fn __current_mod_id() -> Option<String> {
84 CURRENT_MOD_ID.with(|cell| cell.borrow().clone())
85}
86
87std::thread_local! {
88 static CURRENT_MOD_ID: std::cell::RefCell<Option<String>> = std::cell::RefCell::new(None);
89}
90
91pub use yog_command::CommandContext;
92pub use yog_core::{BlockPos, Server};
93pub use yog_event::{
94 AdvancementEvent, AttackEntityEvent, BlockBreakEvent, ChatEvent, ClientTickEvent,
95 ContainerCloseEvent, ContainerOpenEvent, CraftEvent, EntityDamageEvent, EntityDeathEvent,
96 EntityInteractEvent, EntitySpawnEvent, EventPhase, ExplosionEvent,
97 ItemPickupEvent, KeyPressEvent, PlaceBlockEvent, PlayerDeathEvent, PlayerJoinEvent,
98 PlayerLeaveEvent, PlayerMoveEvent, PlayerRespawnEvent, ProjectileHitEvent, ScreenEvent,
99 UseBlockEvent, UseItemEvent,
100};
101pub use yog_entity::Entity;
102pub use yog_network::{Packet, PacketEvent, PacketField};
103#[doc(inline)]
104pub use yog_network::packet;
105pub use yog_player::Player;
106pub use yog_registry::{BlockDef, FoodDef, FurnaceRecipe, ItemDef, ShapedRecipe, ShapelessRecipe, BookRecipe, ItemModifier, AdvancementReward, StartupGrant};
107pub use yog_config::Config;
108pub use yog_storage::{Storage, StorageScope, Value};
109pub use yog_world::World;
110pub use yog_book::{Book, BookCategory, BookEntry, BookPage, BookMacro, BookRegistry};
111pub use yog_book::{BookRenderer, BookFontRegistry};
112pub use yog_book::{text_page, text_page_titled, spotlight_page, crafting_page, smelting_page, image_page, entity_page, relations_page, pattern_page};
113pub use yog_ui::{UiRoot, LayoutNode, Rect, widget, Align, FlexDir, Dock, FocusStyle};
114pub use yog_inventory::{InventoryDef, SlotLayout};
115
116pub use yog_logging::{error, info, warn};
118
119pub mod core {
121 pub use yog_core::*;
122}
123
124pub mod event {
126 pub use yog_event::*;
127}
128
129pub mod world {
131 pub use yog_world::*;
132}
133
134pub mod entity {
136 pub use yog_entity::*;
137}
138
139pub mod player {
141 pub use yog_player::*;
142}
143
144pub mod content {
146 pub use yog_registry::*;
147}
148
149pub mod network {
151 pub use yog_network::*;
152}
153
154pub mod command {
156 pub use yog_command::*;
157}
158
159pub mod storage {
161 pub use yog_storage::*;
162}
163
164pub mod config {
166 pub use yog_config::*;
167}
168
169pub mod book {
171 pub use yog_book::*;
172}
173
174pub mod ui {
176 pub use yog_ui::*;
177}
178
179pub mod inventory {
182 pub use yog_inventory::*;
183}