Skip to content

levilamina::registry

The engine's own registries: every block type, every item, every entity and every command the running game has, with the facts a rule needs to pick from them.

A mod that hands out "a random block" or "a random rare item" should not keep a list of names of its own: the game has more than any such list, and the list goes stale with every version. It reads these instead and decides by rules (solid, not technical, of this rarity). A host older than the registry_list slot answers with an error, never with an empty list that would look like a game without content.

Functions

registry::blocks

Rust
pub fn blocks() -> Result<Vec<BlockType>>

Every block type.

registry::items

Rust
pub fn items() -> Result<Vec<ItemType>>

Every item, each once under its own full name.

registry::entities

Rust
pub fn entities() -> Result<Vec<EntityType>>

Every entity the level knows.

registry::commands

Rust
pub fn commands() -> Result<Vec<CommandType>>

Every command the engine's registry holds, whichever mod registered it. The registry does not exist before the server has built it, and the call then answers with an error.

EntityType

Rust
pub struct EntityType {
    pub name: String,
    #[serde(default)]
    pub spawn_egg: bool,
    #[serde(default)]
    pub summonable: bool,
    /// An experiment has to be on for it to exist.
    #[serde(default)]
    pub experimental: bool,
    /// The engine's actor type number; see [`EntityType::is_monster`] and the others.
    #[serde(default, rename = "type", deserialize_with = "whole")]
    pub type_id: i64,
}

One entity the level knows.

  • Implements: Debug, Clone, PartialEq, serde::Deserialize

EntityType::is_mob

Rust
pub fn is_mob(&self) -> bool
  • Return type: bool

EntityType::is_monster

Rust
pub fn is_monster(&self) -> bool
  • Return type: bool

EntityType::is_animal

Rust
pub fn is_animal(&self) -> bool

A land animal: the animal bit without the water-animal one.

  • Return type: bool

EntityType::is_water_animal

Rust
pub fn is_water_animal(&self) -> bool
  • Return type: bool

BlockType

Rust
pub struct BlockType {
    pub name: String,
    /// A [`category`] value.
    #[serde(default, deserialize_with = "whole")]
    pub category: i32,
    #[serde(default)]
    pub solid: bool,
    #[serde(default)]
    pub vanilla: bool,
    #[serde(default)]
    pub container: bool,
    /// Gives a redstone signal of its own, as a lever or a button does.
    #[serde(default)]
    pub signal: bool,
    #[serde(default)]
    pub fence: bool,
    #[serde(default)]
    pub rail: bool,
    #[serde(default)]
    pub slab: bool,
    #[serde(default)]
    pub wall: bool,
    #[serde(default)]
    pub crop: bool,
    /// Holds a block entity: a chest, a sign, a spawner, a bed.
    #[serde(default)]
    pub entity: bool,
    /// Bare-hand destroy speed; negative for a block nothing breaks.
    #[serde(default)]
    pub destroy: f64,
    #[serde(default)]
    pub resistance: f64,
    /// The light it emits, 0 to 15.
    #[serde(default, deserialize_with = "whole")]
    pub light: i32,
    /// The localization key.
    #[serde(default)]
    pub description: String,
}

One block type, read from its default state.

  • Implements: Debug, Clone, PartialEq, serde::Deserialize

ItemType

Rust
pub struct ItemType {
    pub name: String,
    /// 0 common, 1 uncommon, 2 rare, 3 epic.
    #[serde(default, deserialize_with = "whole")]
    pub rarity: i32,
    #[serde(default, deserialize_with = "whole")]
    pub stack: i32,
    /// A [`category`] value.
    #[serde(default, deserialize_with = "whole")]
    pub category: i32,
    /// Commands do not offer it.
    #[serde(default)]
    pub hidden: bool,
}

One item.

  • Implements: Debug, Clone, PartialEq, serde::Deserialize

CommandType

Rust
pub struct CommandType {
    /// The canonical name, without the slash.
    pub name: String,
    /// The localization key of the description.
    #[serde(default)]
    pub description: String,
    /// The permission level as the engine numbers it: 0 any, 1 game directors, 2 admin, 3 host,
    /// 4 owner, 5 internal.
    #[serde(default, deserialize_with = "whole")]
    pub permission: i32,
    /// The raw flag bits of the command.
    #[serde(default, deserialize_with = "whole")]
    pub flags: i32,
    /// Hidden from players: the command is not in the list a player's client shows.
    #[serde(default)]
    pub hidden: bool,
    /// The other names that run this command.
    #[serde(default)]
    pub aliases: Vec<String>,
}

One command the engine's registry holds.

  • Implements: Debug, Clone, PartialEq, serde::Deserialize

Constants

Name Value Description
ALL 0
CONSTRUCTION 1
NATURE 2
EQUIPMENT 3
ITEMS 4
COMMAND_ONLY 5 Reachable by commands only: barriers, command blocks, structure blocks and the like.
UNDEFINED 6