amulet.api.registry.block_manager
module¶
- class amulet.api.registry.block_manager.BlockManager(blocks=())[source]¶
Bases:
BaseRegistry
Class to handle the mappings between Block objects and their index-based internal IDs
- __contains__(item)[source]¶
Is the given
Block
already in the registry.>>> block in level.block_palette True >>> 7 in level.block_palette True
- __iter__()[source]¶
Iterate through all blocks in the registry.
>>> for block in level.block_palette: >>> ...
- __getitem__(item)[source]¶
If a Block object is passed to this function, it will return the internal ID/index of the blockstate.
If an int is given, this method will return the Block object at that specified index.
>>> level.block_palette[block] 7 >>> level.block_palette[7] block
- Parameters
item – The Block object or int to get the mapping data of
- Returns
An int if a Block object was supplied, a Block object if an int was supplied
:raises KeyError if the requested item is not present.
- get_add_block(block)[source]¶
Adds a Block object to the internal Block object/ID mappings.
If the Block already exists in the mappings, the existing ID is returned.
- register(block)[source]¶
An alias of
get_add_block()
.Adds a Block object to the internal Block object/ID mappings.
If the Block already exists in the mappings, the existing ID is returned.