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
18pub use yog_interop::{yog_export, import};
20
21#[doc(hidden)]
22pub use std::os::raw::c_void as __c_void;
23
24#[macro_export]
37macro_rules! export_mod {
38 ($mod_ty:ty) => {
39 #[no_mangle]
40 pub extern "C" fn yog_abi_version() -> u32 {
41 $crate::ABI_VERSION
42 }
43
44 #[no_mangle]
45 pub unsafe extern "C" fn yog_mod_register(
46 api: *const $crate::YogApi,
47 mod_id_ptr: *const ::std::os::raw::c_char,
48 ) {
49 let mod_id: &str = if mod_id_ptr.is_null() {
51 "unknown"
52 } else {
53 match ::std::ffi::CStr::from_ptr(mod_id_ptr).to_str() {
54 Ok(s) => s,
55 Err(_) => "unknown",
56 }
57 };
58 $crate::__set_current_mod_id(mod_id);
60
61 let outcome = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| {
64 let mut registry = unsafe { $crate::Registry::from_raw(api) };
67 <$mod_ty as $crate::Mod>::register(&mut registry);
68 }));
69 if outcome.is_err() {
70 $crate::error!("mod {} panicked during register", ::core::stringify!($mod_ty));
71 }
72 }
73 };
74}
75
76#[doc(hidden)]
80pub fn __set_current_mod_id(id: &str) {
81 CURRENT_MOD_ID.with(|cell| cell.replace(Some(id.to_string())));
82}
83
84#[doc(hidden)]
86pub fn __current_mod_id() -> Option<String> {
87 CURRENT_MOD_ID.with(|cell| cell.borrow().clone())
88}
89
90std::thread_local! {
91 static CURRENT_MOD_ID: std::cell::RefCell<Option<String>> = std::cell::RefCell::new(None);
92}
93
94pub use yog_command::CommandContext;
95pub use yog_core::{BlockPos, Server};
96pub use yog_event::{
97 AdvancementEvent, AttackEntityEvent, BlockBreakEvent, ChatEvent, ClientTickEvent,
98 ContainerCloseEvent, ContainerOpenEvent, CraftEvent, EntityDamageEvent, EntityDeathEvent,
99 EntityInteractEvent, EntitySpawnEvent, EventPhase, ExplosionEvent,
100 ItemPickupEvent, KeyPressEvent, PlaceBlockEvent, PlayerDeathEvent, PlayerJoinEvent,
101 PlayerLeaveEvent, PlayerMoveEvent, PlayerRespawnEvent, ProjectileHitEvent, ScreenEvent,
102 UseBlockEvent, UseItemEvent,
103};
104pub use yog_entity::Entity;
105pub use yog_network::{Packet, PacketEvent, PacketField};
106#[doc(inline)]
107pub use yog_network::packet;
108pub use yog_player::Player;
109pub use yog_registry::{BlockDef, FoodDef, FurnaceRecipe, ItemDef, ShapedRecipe, ShapelessRecipe, BookRecipe, ItemModifier, AdvancementReward, StartupGrant};
110pub use yog_config::Config;
111pub use yog_storage::{Storage, StorageScope, Value};
112pub use yog_world::World;
113pub use yog_book::{Book, BookCategory, BookEntry, BookPage, BookMacro, BookRegistry};
114pub use yog_book::{BookRenderer, BookFontRegistry};
115pub use yog_book::{text_page, text_page_titled, spotlight_page, crafting_page, smelting_page, image_page, entity_page, relations_page, pattern_page};
116pub use yog_ui::{UiRoot, LayoutNode, Rect, widget, Align, FlexDir, Dock, FocusStyle};
117pub use yog_inventory::{InventoryDef, SlotLayout};
118
119pub use yog_logging::{error, info, warn};
121
122pub mod core {
124 pub use yog_core::*;
125}
126
127pub mod event {
129 pub use yog_event::*;
130}
131
132pub mod world {
134 pub use yog_world::*;
135}
136
137pub mod entity {
139 pub use yog_entity::*;
140}
141
142pub mod player {
144 pub use yog_player::*;
145}
146
147pub mod content {
149 pub use yog_registry::*;
150}
151
152pub mod network {
154 pub use yog_network::*;
155}
156
157pub mod command {
159 pub use yog_command::*;
160}
161
162pub mod storage {
164 pub use yog_storage::*;
165}
166
167pub mod config {
169 pub use yog_config::*;
170}
171
172pub mod book {
174 pub use yog_book::*;
175}
176
177pub mod ui {
179 pub use yog_ui::*;
180}
181
182pub mod inventory {
185 pub use yog_inventory::*;
186}