# mceditlib.selection package — mceditlib 0.1 documentation

### Navigation

- index
- modules |
- next |
- previous |
- mceditlib 0.1 documentation »
- mceditlib package »

# mceditlib.selection package

## Module contents

__init__.py

class `mceditlib.selection.``ISelection`

  Bases: `object`

  Interface for block selections that can have any shape. Used by block_copy and block_fill.

  BoundingBox is the only provider for now.

  Variables: | chunkPositions() – List or iterator of (cx, cz) coordinates for the chunks within this selection

  `chunkPositions` = NotImplemented
  `contains_coords`(x, y, z)

    Return an array of boolean values indicating which of the x, y, z coordinate pairs are within this selection. x, y, and z must be numpy arrays of the same shape, and the return value will be a numpy array of the same shape.

    Return type: | ndarray(shape=x.shape, dtype=bool)

  `containsChunk`(cx, cz)

    Return True if the given chunk is in this selection

    Parameters:

    - cx (int) – Chunk X position
    - cz (int) – Chunk Z position

    Return type: | boolean

  `sectionPositions`(cx, cz)

    Return a list of cy values contained in the given chunk

    Parameters:

    - cx (int) – Chunk X position
    - cz (int) – Chunk Z position

    Returns: | Chunk Y positions
    Return type: | iterator of ints

  `box_mask`(box)
    Construct and return a contiguous 3-d array of boolean values corresponding to the part
      of this selection within the given box. The returned array’s coordinates will be ordered YZX.

    Returns: | Mask array, ordered YZX
    Return type: | ndarray(shape=(box.height, box.length, box.width), dtype=bool)

  `section_mask`(cx, cy, cz)

    Construct and return a 16x16x16 array of boolean values indicating which of the 4096 blocks within the given section cube are within this selection. The returned array’s coordinates will be ordered YZX. The default implementation calls box_mask with a box constructed for the section’s bounds.

    Returns: | Mask array, ordered YZX
    Return type: | ndarray(shape=(16, 16, 16), dtype=bool)

class `mceditlib.selection.``SelectionBox`

  Bases: `object`

  `section_mask`(cx, cy, cz)
  `box_mask`(box)
  `mincx` = NotImplemented
  `mincy` = NotImplemented
  `mincz` = NotImplemented
  `maxcx` = NotImplemented
  `maxcy` = NotImplemented
  `maxcz` = NotImplemented
  `chunkBox`(level)

    Returns this box extended to the chunk boundaries of the given level

  `containsChunk`(cx, cz)
  `chunkPositions`()
  `sectionPositions`(cx=0, cz=0)
  `chunkCount`

class `mceditlib.selection.``InvertedBox`(base)

  Bases: `mceditlib.selection.SelectionBox`

  `contains_coords`(x, y, z)
  `box_mask`(box)

class `mceditlib.selection.``CombinationBox`(left, right)

  Bases: `mceditlib.selection.SelectionBox`

  `oper` = NotImplemented
  `boundsminoper` = NotImplemented
  `boundsmaxoper` = NotImplemented
  `contains_coords`(x, y, z)
  `box_mask`(box)
  `sectionPositions`(cx, cz)

class `mceditlib.selection.``UnionBox`(left, right)

  Bases: `mceditlib.selection.CombinationBox`

  `oper`()

    or_(a, b) – Same as a | b.

  `boundsminoper`()

    min(iterable[, key=func]) -> value min(a, b, c, ...[, key=func]) -> value

    With a single iterable argument, return its smallest item. With two or more arguments, return the smallest argument.

  `boundsmaxoper`()

    max(iterable[, key=func]) -> value max(a, b, c, ...[, key=func]) -> value

    With a single iterable argument, return its largest item. With two or more arguments, return the largest argument.

class `mceditlib.selection.``IntersectionBox`(left, right)

  Bases: `mceditlib.selection.CombinationBox`

  `oper`()

    and_(a, b) – Same as a & b.

  `boundsminoper`()

    max(iterable[, key=func]) -> value max(a, b, c, ...[, key=func]) -> value

    With a single iterable argument, return its largest item. With two or more arguments, return the largest argument.

  `boundsmaxoper`()

    min(iterable[, key=func]) -> value min(a, b, c, ...[, key=func]) -> value

    With a single iterable argument, return its smallest item. With two or more arguments, return the smallest argument.

class `mceditlib.selection.``DifferenceBox`(left, right)

  Bases: `mceditlib.selection.CombinationBox`

  `oper`(a, b)
  `boundsminoper`(*a)
  `boundsmaxoper`(*a)

`mceditlib.selection.``SectionBox`(cx, cy, cz, section=None)

`mceditlib.selection.``rayIntersectsBox`(box, ray)

  Return a list of (point, face) pairs for each side of the box intersected by ray. The list is sorted by distance from the ray’s origin, nearest to furthest.

  Parameters:

  - box –
  - ray –

  Returns: |
  Return type: |

`mceditlib.selection.``createSelectionMask`(brushBox, shapeFunc, requestedBox, chance=100, hollow=False)

  Return a boolean array for a selection with the given shape and style. If ‘offset’ and ‘box’ are given, then the selection is offset into the world and only the part of the world contained in box is returned as an array

class `mceditlib.selection.``BoundingBox`(origin=(0, 0, 0), size=(0, 0, 0), maximum=None)

  Bases: `mceditlib.selection.SelectionBox`

  `type`

    alias of `int`

  `origin`

    The smallest position in the box :rtype: Vector

  `size`

    The size of the box :rtype: Vector

  `center`
  `width`

    The dimension along the X axis

  `height`

    The dimension along the Y axis

  `length`

    The dimension along the Z axis

  `minx`
  `miny`
  `minz`
  `maxx`
  `maxy`
  `maxz`
  `maximum`

    The largest point of the box; origin plus size.

  `volume`

    The volume of the box in blocks

  `positions`

    iterate through all of the positions within this selection box

  `intersect`(box)
    Return a box containing the area self and box have in common. Box will have zero volume
      if there is no common area.
  `union`(box)

    Return a box large enough to contain both self and box.

  `expand`(dx, dy=None, dz=None)

    Return a new box with boundaries expanded by dx, dy, dz. If only dx is passed, expands by dx in all dimensions.

  `contains_coords`(x, y, z)
  `box_mask`(box)

    Parameters: | box – BoundingBox

    Returns:

    rtype: | ndarray | None

  `mincx`

    The smallest chunk position contained in this box

  `mincy`

    The smallest section position contained in this box

  `mincz`

    The smallest chunk position contained in this box

  `maxcx`

    The largest chunk position contained in this box

  `maxcy`

    The largest section position contained in this box

  `maxcz`

    The largest chunk position contained in this box

  `isChunkAligned`

class `mceditlib.selection.``FloatBox`(origin=(0, 0, 0), size=(0, 0, 0), maximum=None)

  Bases: `mceditlib.selection.BoundingBox`

  `type`

    alias of `float`

class `mceditlib.selection.``ShapedSelection`(box, shapeFunc, chance=100, hollow=False)

  Bases: `mceditlib.selection.BoundingBox`

  `box_mask`(box)

`mceditlib.selection.``SphereShape`(blockCenters, shape)

`mceditlib.selection.``BoxShape`(blockCenters, shape)

`mceditlib.selection.``DiamondShape`(blockCenters, shape)

### Navigation

- index
- modules |
- next |
- previous |
- mceditlib 0.1 documentation »
- mceditlib package »