Skip to content

Zig: Registries

Functions

registry.blocks

Zig
pub fn blocks(allocator: Allocator) core.Error!types.Owned(BlockType)

Every block type.

  • Parameters:
    • allocator : Allocator
  • Return type: core.Error!types.Owned(BlockType)
  • Slots: registry_list

registry.items

Zig
pub fn items(allocator: Allocator) core.Error!types.Owned(ItemType)

Every item, each once under its own full name.

  • Parameters:
    • allocator : Allocator
  • Return type: core.Error!types.Owned(ItemType)
  • Slots: registry_list

registry.entities

Zig
pub fn entities(allocator: Allocator) core.Error!types.Owned(EntityType)

Every entity the level knows.

  • Parameters:
    • allocator : Allocator
  • Return type: core.Error!types.Owned(EntityType)
  • Slots: registry_list

registry.commands

Zig
pub fn commands(allocator: Allocator) core.Error!types.Owned(CommandType)

Every command the engine's registry holds, whichever mod registered it.

  • Parameters:
    • allocator : Allocator
  • Return type: core.Error!types.Owned(CommandType)
  • Slots: registry_list

Declarations

registry.EntityType.json_keys

Zig
pub const json_keys = .{ .type_id = "type" };

registry.EntityType

Zig
1
2
3
4
5
6
7
8
pub const EntityType = struct {
    name: []const u8 = "",
    spawn_egg: bool = false,
    summonable: bool = false,
    experimental: bool = false,
    type_id: i64 = 0,
    // ...
};

One entity the level knows.

registry.EntityType.isMob

Zig
pub fn isMob(self: EntityType) bool
  • Return type: bool

registry.EntityType.isMonster

Zig
pub fn isMonster(self: EntityType) bool
  • Return type: bool

registry.EntityType.isAnimal

Zig
pub fn isAnimal(self: EntityType) bool

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

  • Return type: bool

registry.EntityType.isWaterAnimal

Zig
pub fn isWaterAnimal(self: EntityType) bool
  • Return type: bool

registry.BlockType

Zig
pub const BlockType = struct {
    name: []const u8 = "",
    category: i32 = 0,
    solid: bool = false,
    vanilla: bool = false,
    container: bool = false,
    signal: bool = false,
    fence: bool = false,
    rail: bool = false,
    slab: bool = false,
    wall: bool = false,
    crop: bool = false,
    entity: bool = false,
    destroy: f64 = 0,
    resistance: f64 = 0,
    light: i32 = 0,
    description: []const u8 = "",
    // ...
};

One block type, read from its default state.

registry.ItemType

Zig
1
2
3
4
5
6
7
8
pub const ItemType = struct {
    name: []const u8 = "",
    rarity: i32 = 0,
    stack: i32 = 0,
    category: i32 = 0,
    hidden: bool = false,
    // ...
};

One item.

registry.CommandType

Zig
1
2
3
4
5
6
7
8
9
pub const CommandType = struct {
    name: []const u8 = "",
    description: []const u8 = "",
    permission: i32 = 0,
    flags: i32 = 0,
    hidden: bool = false,
    aliases: []const []const u8 = &.{},
    // ...
};

One command the engine's registry holds.