🔄 Convert#

Format conversion utilities and auto-detection.

Detect#

Format auto-detection by file extension.

auto(source, output=None, options=None)[source]#

Automatically convert one file between formats based on its extension.

Parameters:
  • source (str | Path | PathLike[str]) – Path to source file.

  • output (optional) – Path to directory. Defaults to same location as source.

  • options (optional) – Shared handlers options.

Raises:
Return type:

None

Example

  • auto("model.mcsb", "model.obj")

  • auto("model.mcsb", "model.obj", Options(skeleton=True))

  • auto("model.mcsb", "path/to/output/dir")

Formats#

Named conversion functions for specific format pairs.

mcsb_to_obj(source, output=None, options=None)[source]#

Converts model from .mcsb to .obj format.

Parameters:
  • source (str | Path | PathLike[str]) – Path to source .mcsb file.

  • output (optional) – Path to file or directory. Defaults to same location as source.

  • options (optional) – Shared handlers options.

Example

  • mcsb_to_obj("model.mcsb", "model.obj")

  • mcsb_to_obj("model.mcsb", "path/to/output/dir")

mcsb_to_glb(source, output=None, options=None)[source]#

Converts model from .mcsb to .glb format.

Parameters:
  • source (str | Path | PathLike[str]) – Path to source .mcsb file.

  • output (optional) – Path to file or directory. Defaults to same location as source.

  • options (optional) – Shared handlers options.

Example

  • mcsb_to_glb("model.mcsb", "model.glb")

  • mcsb_to_glb("model.mcsb", "path/to/output/dir")

mcsb_to_dae(source, output=None, options=None)[source]#

Converts model from .mcsb to .dae format.

Parameters:
  • source (str | Path | PathLike[str]) – Path to source .mcsb file.

  • output (optional) – Path to file or directory. Defaults to same location as source.

  • options (optional) – Shared handlers options.

Example

  • mcsb_to_dae("model.mcsb", "model.dae")

  • mcsb_to_dae("model.mcsb", "path/to/output/dir")

mcsb_to_ms3d(source, output=None, options=None)[source]#

Converts model from .mcsb to .ms3d format.

Parameters:
  • source (str | Path | PathLike[str]) – Path to source .mcsb file.

  • output (optional) – Path to file or directory. Defaults to same location as source.

  • options (optional) – Shared handlers options.

Example

  • mcsb_to_ms3d("model.mcsb", "model.ms3d")

  • mcsb_to_ms3d("model.mcsb", "path/to/output/dir")

mcsb_to_fbx(source, output=None, options=None)[source]#

Converts model from .mcsb to .fbx format.

Parameters:
  • source (str | Path | PathLike[str]) – Path to source .mcsb file.

  • output (optional) – Path to file or directory. Defaults to same location as source.

  • options (optional) – Shared handlers options.

Example

  • mcsb_to_fbx("model.mcsb", "model.fbx")

  • mcsb_to_fbx("model.mcsb", "path/to/output/dir")

mcsa_to_obj(source, output=None, options=None)[source]#

Converts model from .mcsa to .obj format.

Parameters:
  • source (str | Path | PathLike[str]) – Path to source .mcsa file.

  • output (optional) – Path to file or directory. Defaults to same location as source.

  • options (optional) – Shared handlers options.

Example

  • mcsa_to_obj("model.mcsa", "model.obj")

  • mcsa_to_obj("model.mcsa", "path/to/output/dir")

mcsa_to_glb(source, output=None, options=None)[source]#

Converts model from .mcsa to .glb format.

Parameters:
  • source (str | Path | PathLike[str]) – Path to source .mcsa file.

  • output (optional) – Path to file or directory. Defaults to same location as source.

  • options (optional) – Shared handlers options.

Example

  • mcsa_to_glb("model.mcsa", "model.glb")

  • mcsa_to_glb("model.mcsa", "path/to/output/dir")

mcsa_to_dae(source, output=None, options=None)[source]#

Converts model from .mcsa to .dae format.

Parameters:
  • source (str | Path | PathLike[str]) – Path to source .mcsa file.

  • output (optional) – Path to file or directory. Defaults to same location as source.

  • options (optional) – Shared handlers options.

Example

  • mcsa_to_dae("model.mcsa", "model.dae")

  • mcsa_to_dae("model.mcsa", "path/to/output/dir")

mcsa_to_ms3d(source, output=None, options=None)[source]#

Converts model from .mcsa to .ms3d format.

Parameters:
  • source (str | Path | PathLike[str]) – Path to source .mcsa file.

  • output (optional) – Path to file or directory. Defaults to same location as source.

  • options (optional) – Shared handlers options.

Example

  • mcsa_to_ms3d("model.mcsa", "model.ms3d")

  • mcsa_to_ms3d("model.mcsa", "path/to/output/dir")

mcsa_to_fbx(source, output=None, options=None)[source]#

Converts model from .mcsa to .fbx format.

Parameters:
  • source (str | Path | PathLike[str]) – Path to source .mcsa file.

  • output (optional) – Path to file or directory. Defaults to same location as source.

  • options (optional) – Shared handlers options.

Example

  • mcsa_to_fbx("model.mcsa", "model.fbx")

  • mcsa_to_fbx("model.mcsa", "path/to/output/dir")

efkmodel_to_obj(source, output=None, options=None)[source]#

Converts model from .efkmodel to .obj format.

Parameters:
  • source (str | Path | PathLike[str]) – Path to source .efkmodel file.

  • output (optional) – Path to file or directory. Defaults to same location as source.

  • options (optional) – Shared handlers options.

Example

  • efkmodel_to_obj("model.efkmodel", "model.obj")

  • efkmodel_to_obj("model.efkmodel", "path/to/output/dir")

efkmodel_to_glb(source, output=None, options=None)[source]#

Converts model from .efkmodel to .glb format.

Parameters:
  • source (str | Path | PathLike[str]) – Path to source .efkmodel file.

  • output (optional) – Path to file or directory. Defaults to same location as source.

  • options (optional) – Shared handlers options.

Example

  • efkmodel_to_glb("model.efkmodel", "model.glb")

  • efkmodel_to_glb("model.efkmodel", "path/to/output/dir")

efkmodel_to_dae(source, output=None, options=None)[source]#

Converts model from .efkmodel to .dae format.

Parameters:
  • source (str | Path | PathLike[str]) – Path to source .efkmodel file.

  • output (optional) – Path to file or directory. Defaults to same location as source.

  • options (optional) – Shared handlers options.

Example

  • efkmodel_to_dae("model.efkmodel", "model.dae")

  • efkmodel_to_dae("model.efkmodel", "path/to/output/dir")

efkmodel_to_ms3d(source, output=None, options=None)[source]#

Converts model from .efkmodel to .ms3d format.

Parameters:
  • source (str | Path | PathLike[str]) – Path to source .efkmodel file.

  • output (optional) – Path to file or directory. Defaults to same location as source.

  • options (optional) – Shared handlers options.

Example

  • efkmodel_to_ms3d("model.efkmodel", "model.ms3d")

  • efkmodel_to_ms3d("model.efkmodel", "path/to/output/dir")

efkmodel_to_fbx(source, output=None, options=None)[source]#

Converts model from .efkmodel to .fbx format.

Parameters:
  • source (str | Path | PathLike[str]) – Path to source .efkmodel file.

  • output (optional) – Path to file or directory. Defaults to same location as source.

  • options (optional) – Shared handlers options.

Example

  • efkmodel_to_fbx("model.efkmodel", "model.fbx")

  • efkmodel_to_fbx("model.efkmodel", "path/to/output/dir")

ol_to_dds(source, output=None, options=None)[source]#

Converts texture from .ol to .dds format.

Parameters:
  • source (str | Path | PathLike[str]) – Path to source .ol file.

  • output (optional) – Path to file or directory. Defaults to same location as source.

  • options (optional) – Shared handlers options.

Example

  • ol_to_dds("texture.ol", "texture.dds")

  • ol_to_dds("texture.ol", "path/to/output/dir")

ol_cubemap_to_dds(source, output=None, options=None)[source]#

Converts cubemap texture from .ol to .dds format.

Parameters:
  • source (str | Path | PathLike[str]) – Path to source .ol file.

  • output (optional) – Path to file or directory. Defaults to same location as source.

  • options (optional) – Shared handlers options.

Example

  • ol_cubemap_to_dds("cubemap.ol", "cubemap.dds")

  • ol_cubemap_to_dds("cubemap.ol", "path/to/output/dir")

mic_to_png(source, output=None, options=None)[source]#

Converts image from .mic to .png format.

Parameters:
  • source (str | Path | PathLike[str]) – Path to source .mic file.

  • output (optional) – Path to file or directory. Defaults to same location as source.

  • options (optional) – Shared handlers options.

Example

  • mic_to_png("image.mic", "image.png")

  • mic_to_png("image.mic", "path/to/output/dir")

texarr_to_zip(source, output=None, options=None)[source]#

Converts texture array from .texarr to .zip format.

Parameters:
  • source (str | Path | PathLike[str]) – Path to source .texarr file.

  • output (optional) – Path to file or directory. Defaults to same location as source.

  • options (optional) – Shared handlers options.

Example

  • texarr_to_zip("blocks.texarr", "blocks.zip")

  • texarr_to_zip("blocks.texarr", "path/to/output/dir")

nbt_to_json(source, output=None, options=None)[source]#

Converts data from NBT to .json format.

Parameters:
  • source (str | Path | PathLike[str]) – Path to source NBT file.

  • output (optional) – Path to file or directory. Defaults to same location as source.

  • options (optional) – Shared handlers options.

Example

  • nbt_to_json("itemnames.dat", "itemnames.json")

  • nbt_to_json("itemnames.dat", "path/to/output/dir")

mdat_to_mca(source, output=None, options=None)[source]#

Converts world region from .mdat to .mca format.

Parameters:
  • source (str | Path | PathLike[str]) – Path to source .mdat file.

  • output (optional) – Path to file or directory. Defaults to same location as source.

  • options (optional) – Shared handlers options.

Example

  • mdat_to_mca("reg.0.0.mdat", "r.0.0.mca")

  • mdat_to_mca("reg.0.0.mdat", "path/to/output/dir")

Convert#

Basic implementation of converting one format to another.

convert(decoder, encoder, source, output=None, options=None)[source]#

Convert one file between formats.

Parameters:
  • decoder (Type[FileDecoder[TypeVar(ContentType, bound= BaseContent)]]) – Decoder class for source format.

  • encoder (Type[FileEncoder[TypeVar(ContentType, bound= BaseContent)]]) – Encoder class for output format.

  • source (str | Path | PathLike[str]) – Path to source file.

  • output (optional) – Path to output file or directory. Defaults to source directory.

  • options (optional) – Shared handlers options.

Raises:

FileNotFound – Source file does not exist.

Return type:

None

Example

  • convert(McsaDecoder, ObjEncoder, "model.mcsb", "model.obj")

  • convert(McsaDecoder, ObjEncoder, "model.mcsb", "path/to/output/dir")

ensure_unique_path(path)[source]#

Append a counter to path if a file already exists.

Return type:

Path

Factory#

Decorator for registering named format converters.

converters(src_format)[source]#

Converters for source format.

Return type:

dict[str, Callable]

registry()[source]#

Copy of full converter registry.

Return type:

dict[str, dict[str, Callable]]

converter(decoder, encoder)[source]#

Factory decorator for named conversion between two formats.

Return type:

Callable