mcfonts.serde.minecraft¶
Module Contents¶
- class MinecraftLoader[P: mcfonts.provider.Provider[Any]]¶
Bases:
ProtocolInterface for loading the provider from a Minecraft: Java Edition font.
Providers will also need to add a corresponding entry to
MC_LOAD_REGISTRY, so the loader knows to link each loader to its respective "type" field value.- classmethod minecraft_load(root: mcfonts.path.PackRoot, resource_location: str, contents: collections.abc.Mapping[str, Any]) P¶
Return an instance of a provider, given the contents of the provider and where it is.
- class MinecraftSaver¶
Bases:
ProtocolInterface for saving the provider into a Minecraft: Java Edition font.
- minecraft_save(root: mcfonts.path.PackRoot, resource_location: str) None¶
Save a provider back to a location.
If the target file already exists, this provider will be appended to it.
Warning
This will overwrite files.
- Parameters:¶
- root : mcfonts.path.PackRoot¶
Resource pack root.
- resource_location : str¶
Resource location of font JSON.
- Return type:¶
None
- load_font_from_path(path: pathlib.Path) mcfonts.font.MinecraftFont¶
Create a font from a single JSON file.
- load_font_from_resource(root: mcfonts.path.JavaPackRoot, resource_location: str) mcfonts.font.MinecraftFont¶
Create a font from a single JSON file.
- load_providers_from_resource(root: mcfonts.path.JavaPackRoot, resource_location: str, seen_references: collections.abc.MutableSequence[str]) collections.abc.Generator[mcfonts.provider.Provider[Any]]¶
Yield the provider(s) located at a resource location.
- Parameters:¶
- root : mcfonts.path.JavaPackRoot¶
Resource pack root.
- resource_location : str¶
Resource location of font JSON.
- seen_references : collections.abc.MutableSequence[str]¶
List of resource locations of already-loaded font JSONs Used with reference providers.
- Returns:¶
Generator that yields providers.
- Return type:¶
collections.abc.Generator[mcfonts.provider.Provider[Any]]
- load_reference(root: mcfonts.path.JavaPackRoot, resource_location: str, contents: collections.abc.Mapping[str, Any], seen_references: collections.abc.MutableSequence[str]) collections.abc.Generator[mcfonts.provider.Provider[Any]]¶
Yield the providers referenced by a reference provider.
- Parameters:¶
- root : mcfonts.path.JavaPackRoot¶
Resource pack root.
- resource_location : str¶
Resource location of font JSON.
- contents : collections.abc.Mapping[str, Any]¶
Font JSON.
- seen_references : collections.abc.MutableSequence[str]¶
List of resource locations of already-loaded font JSONs Used with reference providers.
- Returns:¶
Generator that yields providers.
- Raises:¶
RecursionError -- If referenced provider references itself, directly or circularly.
- Return type:¶
collections.abc.Generator[mcfonts.provider.Provider[Any]]
- save_append_helper(root: mcfonts.path.PackRoot, resource_location: str, provider_dict: collections.abc.Mapping[str, Any]) None¶
Open a font JSON and robustly append a provider's contents to it.
- save_font(font: mcfonts.font.MinecraftFont, path: pathlib.Path) None¶
Export to Minecraft: Java Edition format.
This saves back every provider, localized into 1 file.
- Parameters:¶
- font : mcfonts.font.MinecraftFont¶
- path : pathlib.Path¶
- Return type:¶
None
- MC_LOAD_REGISTRY : dict[str, type[MinecraftLoader[Any]]]¶
-
MULTITHREAD_TIMEOUT : int =
10¶
-
REFERENCE_NAME : Final[str] =
'reference'¶