pub mod advancements;
pub mod body;
mod bus;
pub mod client;
mod draw;
pub mod entities;
pub mod java;
pub mod loot;
pub mod mirror;
extern crate self as yog_api;
pub mod vanilla;
pub use bus::{EventCx, Flow, IntoFlow, emit};
pub use service::call;
mod interop;
mod lang;
mod registry;
mod scheduler;
mod service;
#[doc(hidden)]
pub use interop::{__yog_export_registry, __yog_serve, YogExportEntry};
pub use interop::{call_export, export_address};
pub use lang::{format_translation, tag_name, tr, tr_args, translation};
pub use registry::{Mod, ModInfo, Registry, UiHandled, close_ui, installed_mods, open_ui};
pub use yog_gfx::{
GfxContext, core as gfx_core, draw2d as gfx_draw2d, gl as gfx_gl, image as gfx_image,
};
pub use yog_abi::{ABI_VERSION, YogApi};
#[doc(hidden)]
pub use yog_abi::{YogBytes, YogReply, YogStatus};
pub use yog_data;
pub use yog_data::Schema;
pub use yog_ids;
pub use yog_sync as sync;
pub use java::mod_loaded;
pub use yog_interop::{bench, import, yog_export, yog_mirror};
pub use ctor;
#[doc(hidden)]
pub use std::os::raw::c_void as __c_void;
#[doc(hidden)]
pub use yog_abi::{YogGfxApi as __YogGfxApi, YogStr as __YogStr};
#[macro_export]
macro_rules! export_mod {
($mod_ty:ty) => {
#[unsafe(no_mangle)]
pub extern "C" fn yog_abi_version() -> u32 {
$crate::ABI_VERSION
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn yog_mod_register(
api: *const $crate::YogApi,
mod_id_ptr: *const ::std::os::raw::c_char,
) {
let mod_id: &str = if mod_id_ptr.is_null() {
"unknown"
} else {
match unsafe { ::std::ffi::CStr::from_ptr(mod_id_ptr) }.to_str() {
Ok(s) => s,
Err(_) => "unknown",
}
};
$crate::__set_current_mod_id(mod_id);
$crate::__set_current_api_ptr(api as usize);
let outcome = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| {
let mut registry = unsafe { $crate::Registry::from_raw(api) };
$crate::storage::__know_world(&mut registry);
<$mod_ty as $crate::Mod>::register(&mut registry);
let content: ::std::vec::Vec<fn(&mut $crate::Registry)> =
$crate::__yog_content_registrars().lock().clone();
for register in content {
register(&mut registry);
}
for entry in $crate::__yog_export_registry().lock().iter() {
registry.provide_export(mod_id, entry);
}
$crate::storage::__save_with_world(&mut registry);
}));
if outcome.is_err() {
$crate::error!(
"mod {} panicked during register",
::core::stringify!($mod_ty)
);
}
}
#[unsafe(no_mangle)]
pub extern "C" fn yog_ui_designer_abi() -> u32 {
$crate::ui::component::designer::ABI
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn yog_ui_designer(
request: $crate::YogBytes,
gfx: *const $crate::__YogGfxApi,
user_data: *mut $crate::__c_void,
write: $crate::ui::component::designer::WriteFn,
) -> bool {
unsafe { $crate::ui::component::designer::call(request, gfx, user_data, write) }
}
};
}
#[macro_export]
macro_rules! ui_component {
($($ty:ty),+ $(,)?) => {
const _: () = {
#[$crate::ctor::ctor(unsafe, crate_path = $crate::ctor)]
fn __yog_register_ui_components() {
$( $crate::ui::component::register::<$ty>(); )+
}
};
};
}
#[macro_export]
macro_rules! ui_components {
() => {
include!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/generated/components.g.rs"
));
};
}
#[doc(hidden)]
pub fn __set_current_mod_id(id: &str) {
CURRENT_MOD_ID.with(|cell| cell.replace(Some(id.to_string())));
let _ = MOD_ID.set(id.to_owned());
}
pub fn mod_id() -> &'static str {
MOD_ID.get().map_or("", String::as_str)
}
static MOD_ID: yog_sync::OnceLock<String> = yog_sync::OnceLock::new();
#[doc(hidden)]
pub fn __current_mod_id() -> Option<String> {
CURRENT_MOD_ID.with(|cell| cell.borrow().clone())
}
#[doc(hidden)]
pub fn __set_current_api_ptr(ptr: usize) {
API_PTR.store(ptr, yog_sync::atomic::Ordering::Release);
}
#[doc(hidden)]
pub fn __yog_content_registrars() -> &'static yog_sync::Mutex<Vec<fn(&mut Registry)>> {
static REG: yog_sync::Mutex<Vec<fn(&mut Registry)>> = yog_sync::Mutex::new(Vec::new());
®
}
#[doc(hidden)]
pub fn __current_api_ptr() -> usize {
API_PTR.load(yog_sync::atomic::Ordering::Acquire)
}
static API_PTR: yog_sync::atomic::AtomicUsize = yog_sync::atomic::AtomicUsize::new(0);
std::thread_local! {
static CURRENT_MOD_ID: std::cell::RefCell<Option<String>> = const { std::cell::RefCell::new(None) };
}
pub use yog_book::BookRenderer;
pub use yog_command::CommandContext;
pub use yog_config::Config;
pub use yog_core::{
BlockHit, BlockInfo, BlockPos, EntityInfo, Face, PlacedBlock, PlayerInfo, Point, Rotation,
ScreenSlot, SlotStack, Stack, entity_flags, split_state,
};
pub use yog_dimensions::{GeneratedChunk, YogDimensionDef, YogDimensionTypeDef};
pub use yog_event::{Entity, Event, EventPhase, Message, Player, Service, World};
pub use yog_event::{client::net::Packet as ClientPacketEvent, server::net::Packet as PacketEvent};
pub use yog_formats::book::{Book, BookCategory, BookEntry, BookPage};
pub use yog_inventory::{InventoryDef, SlotLayout};
pub use yog_network::Packet;
pub use yog_registry::{
ArmorDefense, ArmorMaterial, ArmorPiece, ArmorSlot, BlockDef, BlockProperty, Cooking,
EntityDef, EntityKind, Facing, FoodDef, ItemDef, Placement, Recipe, RecipeKind, SoundGroup,
StartupGrant, ToolItem, ToolMaterial,
};
pub use yog_ui::{
Align, Dock, FlexDir, FocusStyle, LayoutNode, Rect, Stretch, UiRoot, Units, widget,
};
pub use yog_logging::{error, info, warn};
pub mod core {
pub use yog_core::*;
}
pub mod event {
pub use yog_event::*;
}
pub use yog_event::{
block, bossbar, chat, entity, game, item, net, particle, player, scoreboard, sound, tag, world,
};
pub mod content {
pub use yog_registry::*;
}
pub mod network {
pub use yog_network::*;
}
pub mod command {
pub use yog_command::*;
}
pub mod dimension {
pub use yog_dimensions::*;
}
pub mod storage;
pub mod config {
pub use yog_config::*;
}
pub mod book {
pub use yog_book::*;
pub use yog_formats::book::*;
}
pub mod ui {
pub use yog_ui::*;
}
#[macro_export]
macro_rules! ui_include {
($name:literal) => {
include!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/generated/",
$name,
".g.rs"
));
};
}
#[macro_export]
macro_rules! resources {
() => {
pub mod res {
include!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/generated/resources.g.rs"
));
}
};
}
#[macro_export]
macro_rules! content {
() => {
pub mod content {
include!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/generated/yog-content.g.rs"
));
}
};
}
pub mod inventory {
pub use yog_inventory::*;
}