Skip to main content

steel_core/
bootstrap.rs

1//! Global registry and behavior initialization.
2
3use std::sync::Once;
4use std::time::Instant;
5
6use steel_registry::init_vanilla_registry;
7
8use crate::behavior::init_behaviors;
9use crate::block_entity::init_block_entities;
10use crate::entity::init_entities;
11
12fn fill_behavior_registries() {
13    init_behaviors();
14    init_block_entities();
15    init_entities();
16    log::info!("Behavior registries initialized");
17}
18
19/// Initializes the vanilla registry and the behavior registries.
20///
21/// Idempotent, so an embedder loading several worlds in one process bootstraps once.
22pub fn init_globals() {
23    static INIT: Once = Once::new();
24
25    INIT.call_once(|| {
26        let start = Instant::now();
27        init_vanilla_registry();
28        log::info!("Vanilla registry loaded in {:?}", start.elapsed());
29        fill_behavior_registries();
30    });
31}