amulet.api.wrapper.structure_format_wrapper
module¶
- class amulet.api.wrapper.StructureFormatWrapper(path)[source]¶
Bases:
FormatWrapper
[VersionNumberT
]A base FormatWrapper for all structures that only have one dimension.
- __init__(path)[source]¶
Construct a new instance of
StructureFormatWrapper
.This should not be used directly. You should instead use
amulet.load_format()
.- Parameters
path (
str
) – The file path to the serialised data.
- property can_add_dimension: bool[source]¶
Can external code register a new dimension.
If False
register_dimension()
will have no effect.
- 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?
- abstract property extensions: Tuple[str, ...][source]¶
The extension the file can have to be valid.
eg (“.schematic”,)
- abstract open_from(f)[source]¶
Load from a file like object. Useful to load from RAM rather than disk.
- Parameters
f (
BinaryIO
) – The file like object to read data from.
- abstract save_to(f)[source]¶
Write to a file like object. Useful to write to RAM rather than disk.
- Parameters
f (
BinaryIO
) – The file like object to write data to.
- abstract all_chunk_coords(dimension)[source]¶
A generator of all chunk coords in the given dimension.
- property changed: bool[source]¶
Has any data been pushed to the format wrapper that has not been saved to disk.
- 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.
- 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
- abstract static is_valid(path)[source]¶
Returns whether this format wrapper is able to load the given data.
- 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.
- load_player(player_id)[source]¶
Gets the
Player
object that belongs to the specified player idIf no parameter is supplied, the data of the local player should be returned
- Parameters
player_id (
str
) – The desired player id- Return type
Player
- Returns
A Player instance
- 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 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.
- 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.
- 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.
- property selection: SelectionGroup[source]¶
The area that all chunk data must fit within.
- property translation_manager: TranslationManager[source]¶
The translation manager attached to the world.
- 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.