amulet.api.chunk.block_entity_dict module

class amulet.api.chunk.block_entity_dict.BlockEntityDict(block_entities=())[source]

Bases: UserDict

A custom implementation of the dictionary class.

It can only store BlockEntity instances under the absolute coordinate of the block entity Tuple[int, int, int]

__init__(block_entities=())[source]
clear()[source]

Remove all block entities from the chunk.

Return type

None

keys()[source]

The location of every block entity in the chunk. Absolute coordinates.

Return type

KeysView[Tuple[int, int, int]]

values()[source]

An iterable of all the BlockEntity objects.

Return type

ValuesView[BlockEntity]

items()[source]

An iterable of all the locations and BlockEntity objects.

Return type

ItemsView[Tuple[int, int, int], BlockEntity]

copy()[source]

Create a shallow copy of the block entity container.

Return type

BlockEntityDict

insert(block_entity)[source]

Insert the given BlockEntity into the chunk at the location BlockEntity.location

If a block entity already exists at this location it will be overwritten.

Parameters

block_entity (BlockEntity) – The block entity to add to the chunk.

pop(coordinate)[source]

Remove and return the BlockEntity at coordinate.

Parameters

coordinate (Tuple[int, int, int]) – The coordinate to remove the block entity from.

Return type

BlockEntity

Returns

The block entity at the specified coordinate.

Raises

KeyError if there is no BlockEntity at the given coordinate.

setdefault(coordinate, block_entity)[source]

Set the block entity at the given coordinate if there is not a block entity present.

Parameters
  • coordinate (Tuple[int, int, int]) – The coordinate to set the block entity at.

  • block_entity (BlockEntity) – The block entity to set at the specified coordinate if one is not present.

Return type

BlockEntity

popitem() (k, v), remove and return some (key, value) pair[source]

as a 2-tuple; but raise KeyError if D is empty.

update(block_entities)[source]

Add the sequence of BlockEntity instances to the chunk at the location BlockEntity.location

If multiple block entities have the same coordinate only the last one will remain.

Parameters

block_entities (Iterable[BlockEntity]) – A sequence of BlockEntity objects to add to the chunk.

get(k[, d]) D[k] if k in D, else d.  d defaults to None.[source]