world_utils module

amulet.utils.world_utils.block_coords_to_chunk_coords(x, z)[source]

Converts the supplied block coordinates into chunk coordinates

Parameters:
  • x (int) – The x coordinate of the block
  • z (int) – The z coordinate of the block
Return type:

Tuple[int, int]

Returns:

The resulting chunk coordinates in (x, z) order

amulet.utils.world_utils.blocks_slice_to_chunk_slice(blocks_slice)[source]

Converts the supplied blocks slice into chunk slice :type blocks_slice: slice :param blocks_slice: The slice of the blocks :rtype: slice :return: The resulting chunk slice

amulet.utils.world_utils.chunk_coords_to_block_coords(x, z)[source]

Converts the supplied chunk coordinates into block coordinates

Parameters:
  • x (int) – The x coordinate of the chunk
  • z (int) – The z coordinate of the chunk
Return type:

Tuple[int, int]

Returns:

The resulting block coordinates in (x, z) order

amulet.utils.world_utils.chunk_coords_to_region_coords(cx, cz)[source]

Converts the supplied chunk coordinates into region coordinates

Parameters:
  • cx (int) – The x coordinate of the chunk
  • cz (int) – The z coordinate of the chunk
Return type:

Tuple[int, int]

Returns:

The resulting region coordinates in (x, z) order

amulet.utils.world_utils.decode_long_array(long_array, size)[source]

Decode an long array (from BlockStates or Heightmaps) :type long_array: ndarray :param long_array: Encoded long array :size uint: The expected size of the returned array :rtype: ndarray :return: Decoded array as numpy array

amulet.utils.world_utils.encode_long_array(array)[source]

Encode an long array (from BlockStates or Heightmaps) :type array: ndarray :param array: A numpy array of the data to be encoded. :rtype: ndarray :return: Encoded array as numpy array

amulet.utils.world_utils.from_nibble_array(arr)[source]

Unpacks a flat nibble array into a full size numpy array

Parameters:arr (ndarray) – The nibble array
Return type:ndarray
Returns:The resulting array
amulet.utils.world_utils.get_size(obj, seen=None)[source]

Recursively finds size of objects

amulet.utils.world_utils.get_smallest_dtype(arr, uint=True)[source]

Returns the smallest dtype (number) that the array can afford :type arr: ndarray :param arr: The array to check on :type uint: bool :param uint: Should the array fit in uint or not (default: True) :rtype: int :return: The number of bits all the elements can be represented with

amulet.utils.world_utils.gunzip(data)[source]

Decompresses data that is in Gzip format

amulet.utils.world_utils.region_coords_to_chunk_coords(rx, rz)[source]

Converts the supplied region coordinates into the minimum chunk coordinates of that region

Parameters:
  • rx (int) – The x coordinate of the region
  • rz (int) – The y coordinate of the region
Return type:

Tuple[int, int]

Returns:

The resulting minimum chunk coordinates of that region in (x, z) order

amulet.utils.world_utils.to_nibble_array(arr)[source]

packs a full size numpy array into a nibble array.

Parameters:arr (ndarray) – Full numpy array
Return type:ndarray
Returns:The nibble array