steel_registry/
world_clock.rs1use rustc_hash::FxHashMap;
2use simdnbt::ToNbtTag;
3use simdnbt::owned::{NbtCompound, NbtTag};
4use steel_utils::Identifier;
5
6use crate::RegistryTags;
7
8#[derive(Debug)]
10pub struct WorldClock {
11 pub key: Identifier,
12}
13
14impl ToNbtTag for &WorldClock {
15 fn to_nbt_tag(self) -> NbtTag {
16 NbtTag::Compound(NbtCompound::new())
17 }
18}
19
20pub type WorldClockRef = &'static WorldClock;
21
22pub struct WorldClockRegistry {
23 world_clocks_by_id: Vec<WorldClockRef>,
24 world_clocks_by_key: FxHashMap<Identifier, usize>,
25 tags: RegistryTags,
26 allows_registering: bool,
27}
28
29impl WorldClockRegistry {
30 #[must_use]
31 pub fn new() -> Self {
32 Self {
33 world_clocks_by_id: Vec::new(),
34 world_clocks_by_key: FxHashMap::default(),
35 tags: RegistryTags::default(),
36 allows_registering: true,
37 }
38 }
39}
40
41crate::impl_standard_methods!(
42 WorldClockRegistry,
43 WorldClockRef,
44 world_clocks_by_id,
45 world_clocks_by_key,
46 allows_registering
47);
48
49crate::impl_registry!(
50 WorldClockRegistry,
51 WorldClock,
52 world_clocks_by_id,
53 world_clocks_by_key,
54 world_clocks
55);
56
57crate::impl_tagged_registry!(WorldClockRegistry, world_clocks_by_key, "World Clock");