The Entity and TileEntity classes

class litemapy.Entity(str_or_nbt: str | Compound)

A Minecraft entity. Each entity is identified by a type identifier (e.g. minecraft:skeleton) and has a position within a region, as well as a rotation and a velocity vector. Most also have arbitrary data depending on their type (e.g. a sheep has a tag for its color and one indicating whether it has been sheared).

Parameters:

str_or_nbt – either the entity identifier as a string, in which case all other tag will be default, or an bnt compound tag with the entitie’s data.

static from_nbt(nbt: Compound) Entity

Read an entity from an nbt tag.

Parameters:

nbt – An NBT tag with the entity’s data

static fromnbt(nbt: Compound) Entity

Read an entity from an nbt tag.

Parameters:

nbt – An NBT tag with the entity’s data

property id: str

This entity’s type identifier (e.g. minecraft:pig )

property motion: tuple[float, float, float]

The velocity vector of the entity.

property position: tuple[float, float, float]

The position of the entity.

property rotation: tuple[float, float]

The rotation of the entity.

to_nbt() Compound

Save this entity as an NBT tag.

class litemapy.TileEntity(nbt: Compound)

A tile entity, also often referred to as block entities, is a type of entity which complements a block state to store additional data (e.g. containers like chest both have a block state that stores properties like their id ( minecraft:chest ) and orientation, and tile entity that stores their content. For this reason, the TileEntity class does not store an ID but only a position. The ID can be inferred by looking up the BlockState as the same position in the Region.

static from_nbt(nbt: Compound) TileEntity

Reads a tile entity from an NBT tag.

Parameters:

nbt – the tile entity’s data as an NBT tag

static fromnbt(nbt: Compound) TileEntity

Reads a tile entity from an NBT tag.

Parameters:

nbt – the tile entity’s data as an NBT tag

property position: tuple[int, int, int]

The tile entity’s position within the Region/

to_nbt() Compound

Saves the tile entity to NBT tag.