Skip to content

server.internal.gamedata

fn block_network_id_from_nbt #

fn block_network_id_from_nbt(data []u8) !int

fn encode_biome_definitions #

fn encode_biome_definitions(document []u8) ![]u8

encode_biome_definitions turns Mojang's biome_definitions.nbt into the BiomeDefinitionListPacket payload the client expects.

fn load #

fn load(data_dir string) !GameData

fn load_biome_definitions #

fn load_biome_definitions(path string) ![]u8

load_biome_definitions reads Mojang's biome registry from path and returns the packet payload for it.

fn load_block_definitions #

fn load_block_definitions(path string) ![]BlockDefinition

load_block_definitions reads the data driven block registry. A client that never receives one of these falls back to the raw identifier, draws no icon and refuses to place the block.

fn load_entity_identifiers #

fn load_entity_identifiers(path string) ![]nbt.Tag

load_entity_identifiers reads Mojang's actor registry, the list the client resolves every actor type against, its own player included.

fn load_voxel_shapes #

fn load_voxel_shapes(path string) !VoxelShapes

load_voxel_shapes reads the vanilla shape list. Shapes without an identifier are still loaded, because the named ones are found by their position.

fn parse_be_nbt #

fn parse_be_nbt(data []u8) !nbt.RootTag

parse_be_nbt decodes a big endian NBT document into the same tag tree the network codec uses, so callers can walk both forms with one set of helpers.

fn parse_block_palette #

fn parse_block_palette(data []u8) ![]BlockPaletteEntry

struct BlockDefinition #

struct BlockDefinition {
pub:
	name       string
	properties nbt.RootTag
}

BlockDefinition is one of the blocks the game drives from data rather than implementing natively: the identifier the client resolves and the property NBT it builds render, collision and menu state from.

struct BlockPaletteEntry #

struct BlockPaletteEntry {
pub:
	name       string
	network_id int
}

BlockPaletteEntry is one block state from the wire palette, in file order. network_id is the exact FNV1a-32 state hash the client expects, read from the palette rather than recomputed, so it can never disagree with vanilla.

struct CreativeGroup #

struct CreativeGroup {
pub:
	category              int
	name                  string
	icon_numeric_id       int
	icon_block_runtime_id int
}

struct CreativeItem #

struct CreativeItem {
pub:
	numeric_id       int
	block_runtime_id int
	meta             int
	group_index      int
}

struct GameData #

struct GameData {
pub:
	item_entries      []ItemEntry
	creative_groups   []CreativeGroup
	creative_items    []CreativeItem
	block_palette     []BlockPaletteEntry
	block_definitions []BlockDefinition
	voxel_shapes      VoxelShapes
pub mut:
	item_id_by_name  map[string]int
	item_id_by_block map[int]int
}

fn (GameData) item_for_block #

fn (d &GameData) item_for_block(block_runtime_id int) int

fn (GameData) item_name #

fn (d &GameData) item_name(id int) string

fn (GameData) item_id #

fn (d &GameData) item_id(name string) int

struct ItemEntry #

struct ItemEntry {
pub:
	name            string
	runtime_id      int
	version         int
	component_based bool
}

struct VoxelShape #

struct VoxelShape {
pub:
	x_size        u8
	y_size        u8
	z_size        u8
	storage       []u8
	x_coordinates []f32
	y_coordinates []f32
	z_coordinates []f32
}

VoxelShape is one block shape in the form the client reads it: a grid of filled cells plus the cutting planes on each axis that bound them.

struct VoxelShapeName #

struct VoxelShapeName {
pub:
	name string
	id   u16
}

VoxelShapeName ties an identifier to a shape's position in the list. The client keeps its own copy of the vanilla shapes but only finds one by the name the server gives it, so the names have to travel with the shapes.

struct VoxelShapes #

struct VoxelShapes {
pub:
	shapes []VoxelShape
	names  []VoxelShapeName
}