amulet-core 2.0.1.0.309027957683952396889703.15.0.0.15000309a1__cp311-cp311-macosx_10_15_universal2.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of amulet-core might be problematic. Click here for more details.
- amulet/core/__init__.py +36 -0
- amulet/core/__pyinstaller/__init__.py +2 -0
- amulet/core/__pyinstaller/hook-amulet.core.py +4 -0
- amulet/core/_amulet_core.cpython-311-darwin.so +0 -0
- amulet/core/_amulet_core.pyi +7 -0
- amulet/core/_version.py +21 -0
- amulet/core/amulet_coreConfig.cmake +18 -0
- amulet/core/biome/__init__.pyi +75 -0
- amulet/core/biome/biome.hpp +53 -0
- amulet/core/block/__init__.pyi +270 -0
- amulet/core/block/block.hpp +156 -0
- amulet/core/block_entity/__init__.pyi +78 -0
- amulet/core/block_entity/block_entity.hpp +84 -0
- amulet/core/chunk/__init__.pyi +67 -0
- amulet/core/chunk/chunk.hpp +126 -0
- amulet/core/chunk/component/__init__.pyi +18 -0
- amulet/core/chunk/component/biome_3d_component.hpp +96 -0
- amulet/core/chunk/component/block_component.hpp +101 -0
- amulet/core/chunk/component/block_component.pyi +28 -0
- amulet/core/chunk/component/block_entity_component.hpp +119 -0
- amulet/core/chunk/component/section_array_map.hpp +129 -0
- amulet/core/chunk/component/section_array_map.pyi +77 -0
- amulet/core/dll.hpp +21 -0
- amulet/core/entity/__init__.pyi +105 -0
- amulet/core/entity/entity.hpp +100 -0
- amulet/core/libamulet_core.dylib +0 -0
- amulet/core/palette/__init__.pyi +8 -0
- amulet/core/palette/biome_palette.hpp +65 -0
- amulet/core/palette/biome_palette.pyi +45 -0
- amulet/core/palette/block_palette.hpp +71 -0
- amulet/core/palette/block_palette.pyi +47 -0
- amulet/core/py.typed +0 -0
- amulet/core/selection/__init__.pyi +8 -0
- amulet/core/selection/box.hpp +86 -0
- amulet/core/selection/box.pyi +215 -0
- amulet/core/selection/group.hpp +80 -0
- amulet/core/selection/group.pyi +213 -0
- amulet/core/version/__init__.pyi +134 -0
- amulet/core/version/version.hpp +204 -0
- amulet_core-2.0.1.0.309027957683952396889703.15.0.0.15000309a1.dist-info/METADATA +108 -0
- amulet_core-2.0.1.0.309027957683952396889703.15.0.0.15000309a1.dist-info/RECORD +44 -0
- amulet_core-2.0.1.0.309027957683952396889703.15.0.0.15000309a1.dist-info/WHEEL +5 -0
- amulet_core-2.0.1.0.309027957683952396889703.15.0.0.15000309a1.dist-info/entry_points.txt +2 -0
- amulet_core-2.0.1.0.309027957683952396889703.15.0.0.15000309a1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <map>
|
|
4
|
+
#include <stdexcept>
|
|
5
|
+
|
|
6
|
+
#include <amulet/io/binary_reader.hpp>
|
|
7
|
+
#include <amulet/io/binary_writer.hpp>
|
|
8
|
+
|
|
9
|
+
#include <amulet/core/block/block.hpp>
|
|
10
|
+
#include <amulet/core/dll.hpp>
|
|
11
|
+
#include <amulet/core/version/version.hpp>
|
|
12
|
+
|
|
13
|
+
namespace Amulet {
|
|
14
|
+
|
|
15
|
+
class BlockPalette : public VersionRangeContainer {
|
|
16
|
+
private:
|
|
17
|
+
std::vector<BlockStack> _index_to_block;
|
|
18
|
+
std::map<BlockStack, size_t> _block_to_index;
|
|
19
|
+
|
|
20
|
+
public:
|
|
21
|
+
const std::vector<BlockStack>& get_blocks() const { return _index_to_block; }
|
|
22
|
+
|
|
23
|
+
template <typename VersionRangeT>
|
|
24
|
+
BlockPalette(VersionRangeT&& version_range)
|
|
25
|
+
: VersionRangeContainer(std::forward<VersionRangeT>(version_range))
|
|
26
|
+
, _index_to_block()
|
|
27
|
+
, _block_to_index()
|
|
28
|
+
{
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
AMULET_CORE_EXPORT void serialise(BinaryWriter&) const;
|
|
32
|
+
AMULET_CORE_EXPORT static BlockPalette deserialise(BinaryReader&);
|
|
33
|
+
|
|
34
|
+
bool operator==(const BlockPalette& other) const
|
|
35
|
+
{
|
|
36
|
+
return _index_to_block == other._index_to_block;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
size_t size() const { return _index_to_block.size(); }
|
|
40
|
+
|
|
41
|
+
const BlockStack& index_to_block_stack(size_t index) const
|
|
42
|
+
{
|
|
43
|
+
return _index_to_block.at(index);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
size_t block_stack_to_index(const BlockStack& block_stack)
|
|
47
|
+
{
|
|
48
|
+
auto it = _block_to_index.find(block_stack);
|
|
49
|
+
if (it != _block_to_index.end()) {
|
|
50
|
+
return it->second;
|
|
51
|
+
}
|
|
52
|
+
auto version_range = get_version_range();
|
|
53
|
+
for (const auto& block : block_stack.get_blocks()) {
|
|
54
|
+
if (!version_range.contains(block.get_platform(), block.get_version())) {
|
|
55
|
+
throw std::invalid_argument(
|
|
56
|
+
"BlockStack(\"" + block.get_platform() + "\", " + block.get_version().toString() + ") is incompatible with VersionRange(\"" + version_range.get_platform() + "\", " + version_range.get_min_version().toString() + ", " + version_range.get_max_version().toString() + ").");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
size_t index = _index_to_block.size();
|
|
60
|
+
_index_to_block.push_back(block_stack);
|
|
61
|
+
_block_to_index.emplace(block_stack, index);
|
|
62
|
+
return index;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
bool contains_block(const BlockStack& block) const
|
|
66
|
+
{
|
|
67
|
+
return _block_to_index.contains(block);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import collections.abc
|
|
4
|
+
import typing
|
|
5
|
+
|
|
6
|
+
import amulet.core.block
|
|
7
|
+
import amulet.core.version
|
|
8
|
+
|
|
9
|
+
__all__ = ["BlockPalette"]
|
|
10
|
+
|
|
11
|
+
class BlockPalette(amulet.core.version.VersionRangeContainer):
|
|
12
|
+
@typing.overload
|
|
13
|
+
def __contains__(self, arg0: int) -> bool: ...
|
|
14
|
+
@typing.overload
|
|
15
|
+
def __contains__(self, arg0: amulet.core.block.BlockStack) -> bool: ...
|
|
16
|
+
@typing.overload
|
|
17
|
+
def __getitem__(self, arg0: int) -> amulet.core.block.BlockStack: ...
|
|
18
|
+
@typing.overload
|
|
19
|
+
def __getitem__(self, arg0: slice) -> list: ...
|
|
20
|
+
def __init__(self, arg0: amulet.core.version.VersionRange) -> None: ...
|
|
21
|
+
def __iter__(self) -> collections.abc.Iterator[amulet.core.block.BlockStack]: ...
|
|
22
|
+
def __len__(self) -> int: ...
|
|
23
|
+
def __repr__(self) -> str: ...
|
|
24
|
+
def __reversed__(
|
|
25
|
+
self,
|
|
26
|
+
) -> collections.abc.Iterator[amulet.core.block.BlockStack]: ...
|
|
27
|
+
def block_stack_to_index(self, arg0: amulet.core.block.BlockStack) -> int:
|
|
28
|
+
"""
|
|
29
|
+
Get the index of the block stack in the palette.
|
|
30
|
+
If it is not in the palette already it will be added first.
|
|
31
|
+
|
|
32
|
+
:param block_stack: The block stack to get the index of.
|
|
33
|
+
:return: The index of the block stack in the palette.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
def count(self, value: typing.Any) -> int: ...
|
|
37
|
+
def index(
|
|
38
|
+
self, value: typing.Any, start: int = 0, stop: int = 9223372036854775807
|
|
39
|
+
) -> int: ...
|
|
40
|
+
def index_to_block_stack(self, arg0: int) -> amulet.core.block.BlockStack:
|
|
41
|
+
"""
|
|
42
|
+
Get the block stack at the specified palette index.
|
|
43
|
+
|
|
44
|
+
:param index: The index to get
|
|
45
|
+
:return: The block stack at that index
|
|
46
|
+
:raises IndexError if there is no block stack at that index.
|
|
47
|
+
"""
|
amulet/core/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#include <array>
|
|
3
|
+
#include <cstdint>
|
|
4
|
+
|
|
5
|
+
#include <amulet/core/dll.hpp>
|
|
6
|
+
|
|
7
|
+
namespace Amulet {
|
|
8
|
+
|
|
9
|
+
class SelectionGroup;
|
|
10
|
+
|
|
11
|
+
// The SelectionBox class represents a single cuboid selection.
|
|
12
|
+
class SelectionBox {
|
|
13
|
+
private:
|
|
14
|
+
std::int64_t _min_x;
|
|
15
|
+
std::int64_t _min_y;
|
|
16
|
+
std::int64_t _min_z;
|
|
17
|
+
std::uint64_t _size_x;
|
|
18
|
+
std::uint64_t _size_y;
|
|
19
|
+
std::uint64_t _size_z;
|
|
20
|
+
|
|
21
|
+
public:
|
|
22
|
+
SelectionBox(
|
|
23
|
+
std::int64_t min_x,
|
|
24
|
+
std::int64_t min_y,
|
|
25
|
+
std::int64_t min_z,
|
|
26
|
+
std::uint64_t size_x,
|
|
27
|
+
std::uint64_t size_y,
|
|
28
|
+
std::uint64_t size_z)
|
|
29
|
+
: _min_x(min_x)
|
|
30
|
+
, _min_y(min_y)
|
|
31
|
+
, _min_z(min_z)
|
|
32
|
+
, _size_x(size_x)
|
|
33
|
+
, _size_y(size_y)
|
|
34
|
+
, _size_z(size_z)
|
|
35
|
+
{
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
SelectionBox(
|
|
39
|
+
std::array<std::int64_t, 3> point_1,
|
|
40
|
+
std::array<std::int64_t, 3> point_2)
|
|
41
|
+
{
|
|
42
|
+
_min_x = std::min(point_1[0], point_2[0]);
|
|
43
|
+
_min_y = std::min(point_1[1], point_2[1]);
|
|
44
|
+
_min_z = std::min(point_1[2], point_2[2]);
|
|
45
|
+
_size_x = std::max(point_1[0], point_2[0]) - _min_x;
|
|
46
|
+
_size_y = std::max(point_1[1], point_2[1]) - _min_y;
|
|
47
|
+
_size_z = std::max(point_1[2], point_2[2]) - _min_z;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Accessors
|
|
51
|
+
std::int64_t min_x() const { return _min_x; }
|
|
52
|
+
std::int64_t min_y() const { return _min_y; }
|
|
53
|
+
std::int64_t min_z() const { return _min_z; }
|
|
54
|
+
std::int64_t max_x() const { return _min_x + _size_x; }
|
|
55
|
+
std::int64_t max_y() const { return _min_y + _size_y; }
|
|
56
|
+
std::int64_t max_z() const { return _min_z + _size_z; }
|
|
57
|
+
std::array<std::int64_t, 3> min() const { return { _min_x, _min_y, _min_z }; }
|
|
58
|
+
std::array<std::int64_t, 3> max() const { return { max_x(), max_y(), max_z() }; }
|
|
59
|
+
|
|
60
|
+
// Shape and volume
|
|
61
|
+
std::uint64_t size_x() const { return _size_x; }
|
|
62
|
+
std::uint64_t size_y() const { return _size_y; }
|
|
63
|
+
std::uint64_t size_z() const { return _size_z; }
|
|
64
|
+
std::array<std::uint64_t, 3> shape() const { return { _size_x, _size_y, _size_z }; }
|
|
65
|
+
size_t volume() const { return _size_x * _size_y * _size_z; }
|
|
66
|
+
|
|
67
|
+
// Contains and intersects
|
|
68
|
+
AMULET_CORE_EXPORT bool contains_block(std::int64_t x, std::int64_t y, std::int64_t z) const;
|
|
69
|
+
AMULET_CORE_EXPORT bool contains_point(double x, double y, double z) const;
|
|
70
|
+
AMULET_CORE_EXPORT bool contains_box(const SelectionBox& other) const;
|
|
71
|
+
AMULET_CORE_EXPORT bool intersects(const SelectionBox& other) const;
|
|
72
|
+
AMULET_CORE_EXPORT bool intersects(const SelectionGroup& other) const;
|
|
73
|
+
AMULET_CORE_EXPORT bool touches_or_intersects(const SelectionBox& other) const;
|
|
74
|
+
AMULET_CORE_EXPORT bool touches(const SelectionBox& other) const;
|
|
75
|
+
|
|
76
|
+
// Transform
|
|
77
|
+
AMULET_CORE_EXPORT SelectionBox translate(std::int64_t dx, std::int64_t dy, std::int64_t dz) const;
|
|
78
|
+
// AMULET_CORE_EXPORT SelectionGroup transform() const;
|
|
79
|
+
|
|
80
|
+
// Operators
|
|
81
|
+
auto operator<=>(const SelectionBox&) const = default;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
} // namespace Amulet
|
|
85
|
+
|
|
86
|
+
#include "group.hpp"
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import types
|
|
4
|
+
import typing
|
|
5
|
+
|
|
6
|
+
import amulet.core.selection.group
|
|
7
|
+
|
|
8
|
+
__all__ = ["SelectionBox"]
|
|
9
|
+
|
|
10
|
+
class SelectionBox:
|
|
11
|
+
"""
|
|
12
|
+
The SelectionBox class represents a single cuboid selection.
|
|
13
|
+
|
|
14
|
+
When combined with :class:`~amulet.api.selection.SelectionGroup` it can represent any arbitrary shape.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
@typing.overload
|
|
18
|
+
def __eq__(self, arg0: SelectionBox) -> bool: ...
|
|
19
|
+
@typing.overload
|
|
20
|
+
def __eq__(self, arg0: typing.Any) -> bool | types.NotImplementedType: ...
|
|
21
|
+
def __ge__(self, arg0: SelectionBox) -> bool: ...
|
|
22
|
+
def __gt__(self, arg0: SelectionBox) -> bool: ...
|
|
23
|
+
def __hash__(self) -> int: ...
|
|
24
|
+
@typing.overload
|
|
25
|
+
def __init__(
|
|
26
|
+
self, min_x: int, min_y: int, min_z: int, size_x: int, size_y: int, size_z: int
|
|
27
|
+
) -> None:
|
|
28
|
+
"""
|
|
29
|
+
Construct a new SelectionBox instance.
|
|
30
|
+
|
|
31
|
+
>>> # a selection box that selects one block.
|
|
32
|
+
>>> box = SelectionBox(0, 0, 0, 1, 1, 1)
|
|
33
|
+
|
|
34
|
+
:param min_x: The minimum x coordinate of the box.
|
|
35
|
+
:param min_y: The minimum y coordinate of the box.
|
|
36
|
+
:param min_z: The minimum z coordinate of the box.
|
|
37
|
+
:param size_x: The size of the box in the x axis.
|
|
38
|
+
:param size_y: The size of the box in the y axis.
|
|
39
|
+
:param size_z: The size of the box in the z axis.
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
@typing.overload
|
|
43
|
+
def __init__(
|
|
44
|
+
self, point_1: tuple[int, int, int], point_2: tuple[int, int, int]
|
|
45
|
+
) -> None:
|
|
46
|
+
"""
|
|
47
|
+
Construct a new SelectionBox instance.
|
|
48
|
+
|
|
49
|
+
>>> # a selection box that selects one block.
|
|
50
|
+
>>> box = SelectionBox((0, 0, 0), (1, 1, 1))
|
|
51
|
+
|
|
52
|
+
:param point_1: The first coordinate of the box.
|
|
53
|
+
:param point_2: The second coordinate of the box.
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
def __le__(self, arg0: SelectionBox) -> bool: ...
|
|
57
|
+
def __lt__(self, arg0: SelectionBox) -> bool: ...
|
|
58
|
+
def __repr__(self) -> str: ...
|
|
59
|
+
def __str__(self) -> str: ...
|
|
60
|
+
def contains_block(self, x: int, y: int, z: int) -> bool:
|
|
61
|
+
"""
|
|
62
|
+
Is the block contained within the selection.
|
|
63
|
+
|
|
64
|
+
>>> selection1: AbstractBaseSelection
|
|
65
|
+
>>> (1, 2, 3) in selection1
|
|
66
|
+
True
|
|
67
|
+
|
|
68
|
+
:param x: The x coordinate of the block. Defined by the most negative corner.
|
|
69
|
+
:param y: The y coordinate of the block. Defined by the most negative corner.
|
|
70
|
+
:param z: The z coordinate of the block. Defined by the most negative corner.
|
|
71
|
+
:return: True if the block is in the selection.
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
def contains_box(self, other: SelectionBox) -> bool:
|
|
75
|
+
"""
|
|
76
|
+
Does the other SelectionBox other fit entirely within this SelectionBox.
|
|
77
|
+
|
|
78
|
+
:param other: The SelectionBox to test.
|
|
79
|
+
:return: True if other fits in self, False otherwise.
|
|
80
|
+
"""
|
|
81
|
+
|
|
82
|
+
def contains_point(self, x: float, y: float, z: float) -> bool:
|
|
83
|
+
"""
|
|
84
|
+
Is the point contained within the selection.
|
|
85
|
+
|
|
86
|
+
>>> selection1: AbstractBaseSelection
|
|
87
|
+
>>> (1.5, 2.5, 3.5) in selection1
|
|
88
|
+
True
|
|
89
|
+
|
|
90
|
+
:param x: The x coordinate of the point.
|
|
91
|
+
:param y: The y coordinate of the point.
|
|
92
|
+
:param z: The z coordinate of the point.
|
|
93
|
+
:return: True if the point is in the selection.
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
@typing.overload
|
|
97
|
+
def intersects(self, other: SelectionBox) -> bool:
|
|
98
|
+
"""
|
|
99
|
+
Does this selection intersect ``other``.
|
|
100
|
+
|
|
101
|
+
:param other: The other selection.
|
|
102
|
+
:return: True if the selections intersect, False otherwise.
|
|
103
|
+
"""
|
|
104
|
+
|
|
105
|
+
@typing.overload
|
|
106
|
+
def intersects(self, other: amulet.core.selection.group.SelectionGroup) -> bool: ...
|
|
107
|
+
def touches(self, other: SelectionBox) -> bool:
|
|
108
|
+
"""
|
|
109
|
+
Method to check if this instance of :class:`SelectionBox` touches but does not intersect another SelectionBox.
|
|
110
|
+
|
|
111
|
+
:param other: The other SelectionBox
|
|
112
|
+
:return: True if the two :class:`SelectionBox` instances touch, False otherwise
|
|
113
|
+
"""
|
|
114
|
+
|
|
115
|
+
def touches_or_intersects(self, other: SelectionBox) -> bool:
|
|
116
|
+
"""
|
|
117
|
+
Does this SelectionBox touch or intersect the other SelectionBox.
|
|
118
|
+
|
|
119
|
+
:param other: The other SelectionBox.
|
|
120
|
+
:return: True if the two :class:`SelectionBox` instances touch or intersect, False otherwise.
|
|
121
|
+
"""
|
|
122
|
+
|
|
123
|
+
def translate(self, x: int, y: int, z: int) -> SelectionBox:
|
|
124
|
+
"""
|
|
125
|
+
Create a new :class:`SelectionBox` based on this one with the coordinates moved by the given offset.
|
|
126
|
+
|
|
127
|
+
:param x: The x offset.
|
|
128
|
+
:param y: The y offset.
|
|
129
|
+
:param z: The z offset.
|
|
130
|
+
:return: The new selection with the given offset.
|
|
131
|
+
"""
|
|
132
|
+
|
|
133
|
+
@property
|
|
134
|
+
def max(self) -> tuple[int, int, int]:
|
|
135
|
+
"""
|
|
136
|
+
The maximum coordinate of the box.
|
|
137
|
+
"""
|
|
138
|
+
|
|
139
|
+
@property
|
|
140
|
+
def max_x(self) -> int:
|
|
141
|
+
"""
|
|
142
|
+
The maximum x coordinate of the box.
|
|
143
|
+
"""
|
|
144
|
+
|
|
145
|
+
@property
|
|
146
|
+
def max_y(self) -> int:
|
|
147
|
+
"""
|
|
148
|
+
The maximum y coordinate of the box.
|
|
149
|
+
"""
|
|
150
|
+
|
|
151
|
+
@property
|
|
152
|
+
def max_z(self) -> int:
|
|
153
|
+
"""
|
|
154
|
+
The maximum z coordinate of the box.
|
|
155
|
+
"""
|
|
156
|
+
|
|
157
|
+
@property
|
|
158
|
+
def min(self) -> tuple[int, int, int]:
|
|
159
|
+
"""
|
|
160
|
+
The minimum coordinate of the box.
|
|
161
|
+
"""
|
|
162
|
+
|
|
163
|
+
@property
|
|
164
|
+
def min_x(self) -> int:
|
|
165
|
+
"""
|
|
166
|
+
The minimum x coordinate of the box.
|
|
167
|
+
"""
|
|
168
|
+
|
|
169
|
+
@property
|
|
170
|
+
def min_y(self) -> int:
|
|
171
|
+
"""
|
|
172
|
+
The minimum y coordinate of the box.
|
|
173
|
+
"""
|
|
174
|
+
|
|
175
|
+
@property
|
|
176
|
+
def min_z(self) -> int:
|
|
177
|
+
"""
|
|
178
|
+
The minimum z coordinate of the box.
|
|
179
|
+
"""
|
|
180
|
+
|
|
181
|
+
@property
|
|
182
|
+
def shape(self) -> tuple[int, int, int]:
|
|
183
|
+
"""
|
|
184
|
+
The length of the box in the x, y and z axis.
|
|
185
|
+
|
|
186
|
+
>>> SelectionBox(0, 0, 0, 1, 1, 1).shape
|
|
187
|
+
(1, 1, 1)
|
|
188
|
+
"""
|
|
189
|
+
|
|
190
|
+
@property
|
|
191
|
+
def size_x(self) -> int:
|
|
192
|
+
"""
|
|
193
|
+
The length of the box in the x axis.
|
|
194
|
+
"""
|
|
195
|
+
|
|
196
|
+
@property
|
|
197
|
+
def size_y(self) -> int:
|
|
198
|
+
"""
|
|
199
|
+
The length of the box in the y axis.
|
|
200
|
+
"""
|
|
201
|
+
|
|
202
|
+
@property
|
|
203
|
+
def size_z(self) -> int:
|
|
204
|
+
"""
|
|
205
|
+
The length of the box in the z axis.
|
|
206
|
+
"""
|
|
207
|
+
|
|
208
|
+
@property
|
|
209
|
+
def volume(self) -> int:
|
|
210
|
+
"""
|
|
211
|
+
The number of blocks in the box.
|
|
212
|
+
|
|
213
|
+
>>> SelectionBox(0, 0, 0, 1, 1, 1).volume
|
|
214
|
+
1
|
|
215
|
+
"""
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <array>
|
|
4
|
+
#include <concepts>
|
|
5
|
+
#include <ranges>
|
|
6
|
+
#include <set>
|
|
7
|
+
|
|
8
|
+
#include <amulet/core/dll.hpp>
|
|
9
|
+
|
|
10
|
+
#include "box.hpp"
|
|
11
|
+
|
|
12
|
+
namespace Amulet {
|
|
13
|
+
|
|
14
|
+
class SelectionBox;
|
|
15
|
+
|
|
16
|
+
class SelectionGroup {
|
|
17
|
+
private:
|
|
18
|
+
std::set<SelectionBox> _boxes;
|
|
19
|
+
|
|
20
|
+
public:
|
|
21
|
+
// Constructors
|
|
22
|
+
SelectionGroup() {};
|
|
23
|
+
SelectionGroup(const SelectionBox& box)
|
|
24
|
+
{
|
|
25
|
+
_boxes.insert(box);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
template <typename Iterable>
|
|
29
|
+
requires std::ranges::input_range<Iterable> && std::convertible_to<std::ranges::range_value_t<Iterable>, const SelectionBox&>
|
|
30
|
+
SelectionGroup(const Iterable& boxes)
|
|
31
|
+
{
|
|
32
|
+
for (const SelectionBox& box : boxes) {
|
|
33
|
+
_boxes.emplace(box);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Accessors
|
|
38
|
+
const std::set<SelectionBox>& selection_boxes() const
|
|
39
|
+
{
|
|
40
|
+
return _boxes;
|
|
41
|
+
}
|
|
42
|
+
size_t size() const
|
|
43
|
+
{
|
|
44
|
+
return _boxes.size();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Bounds
|
|
48
|
+
AMULET_CORE_EXPORT std::int64_t min_x() const;
|
|
49
|
+
AMULET_CORE_EXPORT std::int64_t min_y() const;
|
|
50
|
+
AMULET_CORE_EXPORT std::int64_t min_z() const;
|
|
51
|
+
AMULET_CORE_EXPORT std::int64_t max_x() const;
|
|
52
|
+
AMULET_CORE_EXPORT std::int64_t max_y() const;
|
|
53
|
+
AMULET_CORE_EXPORT std::int64_t max_z() const;
|
|
54
|
+
AMULET_CORE_EXPORT std::array<std::int64_t, 3> min() const;
|
|
55
|
+
AMULET_CORE_EXPORT std::array<std::int64_t, 3> max() const;
|
|
56
|
+
AMULET_CORE_EXPORT std::pair<
|
|
57
|
+
std::array<std::int64_t, 3>,
|
|
58
|
+
std::array<std::int64_t, 3>>
|
|
59
|
+
bounds() const;
|
|
60
|
+
AMULET_CORE_EXPORT SelectionBox bounding_box() const;
|
|
61
|
+
|
|
62
|
+
// Contains and intersects
|
|
63
|
+
AMULET_CORE_EXPORT bool contains_block(std::int64_t x, std::int64_t y, std::int64_t z) const;
|
|
64
|
+
AMULET_CORE_EXPORT bool contains_point(double x, double y, double z) const;
|
|
65
|
+
AMULET_CORE_EXPORT bool intersects(const SelectionBox& other) const;
|
|
66
|
+
AMULET_CORE_EXPORT bool intersects(const SelectionGroup& other) const;
|
|
67
|
+
|
|
68
|
+
// Transform
|
|
69
|
+
AMULET_CORE_EXPORT SelectionGroup translate(std::int64_t dx, std::int64_t dy, std::int64_t dz) const;
|
|
70
|
+
|
|
71
|
+
// Operators
|
|
72
|
+
operator bool() const
|
|
73
|
+
{
|
|
74
|
+
return !_boxes.empty();
|
|
75
|
+
}
|
|
76
|
+
bool operator==(const SelectionGroup& rhs) const = default;
|
|
77
|
+
bool operator!=(const SelectionGroup& rhs) const = default;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
}
|