The Entity and TileEntity classes

class litemapy.Entity(str_or_nbt)

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 (str | Compound) – 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 fromnbt(nbt)

Read an entity from an nbt tag.

Parameters:

nbt (Compound) – An NBT tag with the entity’s data

Return type:

Entity

property id

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

Type:

str

property motion

The velocity vector of the entity.

Type:

tuple[float, float, float]

property position

The position of the entity.

Type:

tuple[float, float, float]

property rotation

The rotation of the entity.

Type:

tuple[float, float, float]

to_nbt()

Save this entity as an NBT tag.

Return type:

Compound

class litemapy.TileEntity(nbt)

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 fromnbt(nbt)

Reads a tile entity from an NBT tag.

Parameters:

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

Return type:

TileEntity

property position

The tile entity’s position within the Region/

Type:

tuple[int, int, int]

to_nbt()

Saves the tile entity to NBT tag.

Return type:

Compound