amulet.api.wrapper.format_wrapper
module¶
- class amulet.api.wrapper.FormatWrapper(path)[source]¶
The FormatWrapper class is a class that sits between the serialised world or structure data and the program using amulet-core.
It is used to access data from the serialised source in the universal format and write them back again.
- __init__(path)[source]¶
Construct a new instance of
FormatWrapper
.This should not be used directly. You should instead use
amulet.load_format()
.- Parameters
path (
str
) – The file path to the serialised data.
- property translation_manager: TranslationManager[source]¶
The translation manager attached to the world.
- abstract static is_valid(path)[source]¶
Returns whether this format wrapper is able to load the given data.
- abstract property valid_formats: Dict[str, Tuple[bool, bool]][source]¶
The valid platform and version combinations that this object can accept.
This is used when setting the platform and version in the create_and_open method to verify that the platform and version are valid.
- Returns
A dictionary mapping the platform to a tuple of two booleans to determine if numerical and blockstate are valid respectively.
- property version: VersionNumberT[source]¶
The version number for the given platform the data is stored in eg (1, 16, 2)
- property max_world_version: Tuple[str, VersionNumberT][source]¶
The version the world was last opened in.
This should be greater than or equal to the chunk versions found within.
- property changed: bool[source]¶
Has any data been pushed to the format wrapper that has not been saved to disk.
- abstract property dimensions: List[str][source]¶
A list of all the dimensions contained in the world.
- abstract property can_add_dimension: bool[source]¶
Can external code register a new dimension.
If False
register_dimension()
will have no effect.
- abstract register_dimension(dimension_identifier)[source]¶
Register a new dimension.
- Parameters
dimension_identifier (
Any
) – The identifier for the dimension.
- property requires_selection: bool[source]¶
Does this object require that a selection be defined when creating it from scratch?
- property multi_selection: bool[source]¶
Does this object support having multiple selection boxes.
If False it will be given exactly 1 selection.
If True can be given 0 or more.
- property selection: SelectionGroup[source]¶
The area that all chunk data must fit within.
- create_and_open(platform, version, bounds=None, overwrite=False, **kwargs)[source]¶
Remove the data at the path and set up a new database.
You might want to call
exists
to check if something exists at the path and warn the user they are going to overwrite existing data before calling this method.- Parameters
platform (
str
) – The platform the data should use.version (
Union
[int
,Tuple
[int
,...
]]) – The version the data should use.bounds (
Union
[SelectionGroup
,Dict
[str
,Optional
[SelectionGroup
]],None
]) – The bounds for each dimension. If oneSelectionGroup
is given it will be applied to all dimensions.overwrite (
bool
) – Should an existing database be overwritten. If this is False and one exists and error will be thrown.kwargs – Extra arguments as each implementation requires.
- Returns
- static pre_save_operation(level)[source]¶
Logic to run before saving. Eg recalculating height maps or lighting.
Must be a generator that yields a number and returns a bool.
The yielded number is the progress from 0 to 1.
The returned bool is if changes have been made.
- abstract all_chunk_coords(dimension)[source]¶
A generator of all chunk coords in the given dimension.
- load_chunk(cx, cz, dimension)[source]¶
Loads and creates a universal
Chunk
object from chunk coordinates.- Parameters
- Return type
- Returns
The chunk at the given coordinates.
- Raises
ChunkDoesNotExist: If the chunk does not exist (was deleted or never created) ChunkLoadError: If the chunk was not able to be loaded. Eg. If the chunk is corrupt or some error occurred when loading.
- commit_chunk(chunk, dimension)[source]¶
Save a universal format chunk to the FormatWrapper database (not the level database)
Call save method to write changed chunks back to the level.
- put_raw_chunk_data(cx, cz, data, dimension)[source]¶
Commit the raw chunk data to the FormatWrapper cache.
Call
save()
to push all the cache data to the level.