amulet.api.registry.biome_manager module

class amulet.api.registry.biome_manager.BiomeManager(biomes=())[source]

Bases: BaseRegistry

Class to handle the mappings between biome strings and their index-based internal IDs

__init__(biomes=())[source]

Creates a new BiomeManager object

__len__()[source]

The number of biomes in the registry.

>>> len(level.biome_palette)
10
__contains__(item)[source]

Is the given biome string already in the registry.

>>> biome_string in level.biome_palette
True
>>> 7 in level.biome_palette
True
Parameters

item (Union[int, str]) – The biome or id to check.

__iter__()[source]

Iterate through all biomes in the registry.

Return type

Iterable[str]

>>> for biome in level.biome_palette:
>>>     ...
property biomes: Tuple[str][source]

The biomes in the registry as a tuple.

values()[source]

The biomes in the registry as a tuple.

Return type

Tuple[str]

items()[source]

A generator of the biome indexes and the biome strings.

Return type

Generator[Tuple[int, str], None, None]

__getitem__(item)[source]

If a string is passed to this function, it will return the internal ID/index of the biome.

If an int is given, this method will return the biome string at that specified index.

>>> level.biome_palette[biome]
7
>>> level.biome_palette[7]
biome
Parameters

item – The string or int to get the mapping data of

Returns

An int if a string was supplied, a string if an int was supplied

:raises KeyError if the requested item is not present.

get_add_biome(biome)[source]

Adds a biome string to the internal biome string/ID mappings.

If the biome already exists in the mappings, the existing ID is returned.

Parameters

biome (str) – The biome string to add to the manager

Return type

int

Returns

The internal ID of the biome

register(biome)[source]

An alias of get_add_biome().

Adds a biome string to the internal biome string/ID mappings.

If the biome already exists in the mappings, the existing ID is returned.

Parameters

biome (str) – The biome string to add to the manager

Return type

int

Returns

The internal ID of the biome