Loading data

Loading the database

DbRpItems

alias of Literal[‘geometries’, ‘client_entities’, ‘render_controllers’, ‘textures’, ‘particles’, ‘rp_animations’, ‘rp_animation_controllers’, ‘attachables’, ‘sound_definitions’, ‘sounds’, ‘rp_items’, ‘terrain_texture’]

DbBpItems

alias of Literal[‘entities’, ‘loot_tables’, ‘trade_tables’, ‘bp_animations’, ‘bp_animation_controllers’, ‘bp_items’, ‘bp_blocks’, ‘feature_rules’, ‘features’]

class Database(connection)[source]

A class that represents a database with resource packs and behavior packs.

Parameters

connection (Connection) –

close()[source]

Runs close() function on the database connection.

commit()[source]

Runs commit() function on the database connection.

connection: Connection

The SQLite database conncetion.

static create(db_path=':memory:')[source]

Creates a new database for storing resource packs and behavior packs in memory or in a file. The default value is ":memory:" which means that the database is created in memory (just like in sqlite3).

Parameters

db_path (Union[str, Path]) – The path to the database file or ":memory:".

Return type

Database

Creates a new dtabase in db_path. Runs all of the build scripts of the database components.

Parameters

db_path (Union[str, Path]) – The path to the database file. The argument is passed to sqlite3.connect() If the argument is ":memory:", the database is created in memory. ":memory:" is the default value.

Return type

Database

load_bp(bp_path, *, include=('entities', 'loot_tables', 'trade_tables', 'bp_animations', 'bp_animation_controllers', 'bp_items', 'bp_blocks', 'feature_rules', 'features'), exclude=())[source]

Loads behavior pack data into the database.

Parameters
  • db – The database connection.

  • bp_path (pathlib.Path | str) – The path to the resource pack.

  • include (Container[Literal['entities', 'loot_tables', 'trade_tables', 'bp_animations', 'bp_animation_controllers', 'bp_items', 'bp_blocks', 'feature_rules', 'features']]) – A list of items to include. By default, all items are included.

  • exclude (Container[Literal['entities', 'loot_tables', 'trade_tables', 'bp_animations', 'bp_animation_controllers', 'bp_items', 'bp_blocks', 'feature_rules', 'features']]) – A list of items to exclude. By default, no items are excluded.

Return type

None

If there is an item in both include and exclude, it is excluded. The include and exclude lists accept strings that are the names of the supported database components.

load_rp(rp_path, *, include=('geometries', 'client_entities', 'render_controllers', 'textures', 'particles', 'rp_animations', 'rp_animation_controllers', 'attachables', 'sound_definitions', 'sounds', 'rp_items', 'terrain_texture'), exclude=())[source]

Loads resource pack data into the database.

Parameters
  • db – The database connection.

  • rp_path (pathlib.Path | str) – The path to the resource pack.

  • include (Container[Literal['geometries', 'client_entities', 'render_controllers', 'textures', 'particles', 'rp_animations', 'rp_animation_controllers', 'attachables', 'sound_definitions', 'sounds', 'rp_items', 'terrain_texture']]) – A list of items to include. By default, all items are included.

  • exclude (Container[Literal['geometries', 'client_entities', 'render_controllers', 'textures', 'particles', 'rp_animations', 'rp_animation_controllers', 'attachables', 'sound_definitions', 'sounds', 'rp_items', 'terrain_texture']]) – A list of items to exclude. By default, no items are excluded.

Return type

None

If there is an item in both include and exclude, it is excluded. The include and exclude lists accept strings that are the names of the supported database components.

static open(db_path)[source]

Creates a database using path to the database file. This function doesn’t check if the database has a valid structure. It assumes it does. This function only opens the database and sets some sqlite3 adapter and converter functions for Path objects.

Parameters

db_path (Union[str, Path]) – the path to the database file

Return type

Database