amulet-core 2.0a5__cp311-cp311-win_amd64.whl → 2.0a6__cp311-cp311-win_amd64.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.

Files changed (50) hide show
  1. amulet/__init__.cp311-win_amd64.pyd +0 -0
  2. amulet/__init__.py.cpp +39 -0
  3. amulet/_version.py +3 -3
  4. amulet/biome.py.cpp +122 -0
  5. amulet/block.py.cpp +377 -0
  6. amulet/block_entity.py.cpp +115 -0
  7. amulet/chunk.py.cpp +80 -0
  8. amulet/chunk_components/biome_3d_component.cpp +5 -0
  9. amulet/chunk_components/biome_3d_component.hpp +79 -0
  10. amulet/chunk_components/block_component.cpp +41 -0
  11. amulet/chunk_components/block_component.hpp +88 -0
  12. amulet/chunk_components/block_entity_component.cpp +5 -0
  13. amulet/chunk_components/block_entity_component.hpp +147 -0
  14. amulet/chunk_components/section_array_map.cpp +129 -0
  15. amulet/chunk_components/section_array_map.hpp +147 -0
  16. amulet/collections/eq.py.hpp +37 -0
  17. amulet/collections/hash.py.hpp +27 -0
  18. amulet/collections/holder.py.hpp +37 -0
  19. amulet/collections/iterator.py.hpp +80 -0
  20. amulet/collections/mapping.py.hpp +192 -0
  21. amulet/collections/mutable_mapping.py.hpp +215 -0
  22. amulet/collections/sequence.py.hpp +164 -0
  23. amulet/img/missing_world_icon.png +0 -0
  24. amulet/io/binary_reader.hpp +45 -0
  25. amulet/io/binary_writer.hpp +30 -0
  26. amulet/level/java/_raw/java_chunk_decode.cpp +533 -0
  27. amulet/level/java/_raw/java_chunk_decode.hpp +23 -0
  28. amulet/level/java/_raw/java_chunk_encode.cpp +25 -0
  29. amulet/level/java/_raw/java_chunk_encode.hpp +23 -0
  30. amulet/level/java/chunk_components/data_version_component.cpp +32 -0
  31. amulet/level/java/chunk_components/data_version_component.hpp +31 -0
  32. amulet/level/java/chunk_components/java_raw_chunk_component.cpp +56 -0
  33. amulet/level/java/chunk_components/java_raw_chunk_component.hpp +45 -0
  34. amulet/level/java/java_chunk.cpp +170 -0
  35. amulet/level/java/java_chunk.hpp +141 -0
  36. amulet/level/java/long_array.hpp +175 -0
  37. amulet/palette/biome_palette.hpp +85 -0
  38. amulet/palette/block_palette.cpp +32 -0
  39. amulet/palette/block_palette.hpp +93 -0
  40. amulet/pybind11/collections.hpp +76 -0
  41. amulet/pybind11/py_module.hpp +69 -0
  42. amulet/pybind11/python.hpp +14 -0
  43. amulet/pybind11/types.hpp +17 -0
  44. amulet/utils/numpy.hpp +36 -0
  45. amulet/version.py.cpp +281 -0
  46. {amulet_core-2.0a5.dist-info → amulet_core-2.0a6.dist-info}/METADATA +2 -2
  47. {amulet_core-2.0a5.dist-info → amulet_core-2.0a6.dist-info}/RECORD +50 -7
  48. {amulet_core-2.0a5.dist-info → amulet_core-2.0a6.dist-info}/WHEEL +0 -0
  49. {amulet_core-2.0a5.dist-info → amulet_core-2.0a6.dist-info}/entry_points.txt +0 -0
  50. {amulet_core-2.0a5.dist-info → amulet_core-2.0a6.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,32 @@
1
+ #include "block_palette.hpp"
2
+
3
+ namespace Amulet {
4
+ void BlockPalette::serialise(BinaryWriter& writer) const {
5
+ writer.writeNumeric<std::uint8_t>(1);
6
+ get_version_range()->serialise(writer);
7
+ const auto& blocks = get_blocks();
8
+ writer.writeNumeric<std::uint64_t>(blocks.size());
9
+ for (const auto& block : blocks) {
10
+ block->serialise(writer);
11
+ }
12
+ }
13
+ std::shared_ptr<BlockPalette> BlockPalette::deserialise(BinaryReader& reader) {
14
+ auto version = reader.readNumeric<std::uint8_t>();
15
+ switch (version) {
16
+ case 1:
17
+ {
18
+ auto version_range = VersionRange::deserialise(reader);
19
+ auto count = reader.readNumeric<std::uint64_t>();
20
+ auto palette = std::make_shared<BlockPalette>(version_range);
21
+ for (auto i = 0; i < count; i++) {
22
+ if (palette->size() != palette->block_stack_to_index(BlockStack::deserialise(reader))) {
23
+ throw std::runtime_error("Error deserialising BlockPalette");
24
+ }
25
+ }
26
+ return palette;
27
+ }
28
+ default:
29
+ throw std::invalid_argument("Unsupported BlockComponentData version " + std::to_string(version));
30
+ }
31
+ }
32
+ }
@@ -0,0 +1,93 @@
1
+ #pragma once
2
+
3
+ #include <map>
4
+ #include <memory>
5
+ #include <stdexcept>
6
+
7
+ #include <amulet/version.hpp>
8
+ #include <amulet/block.hpp>
9
+
10
+ #include <amulet/io/binary_reader.hpp>
11
+ #include <amulet/io/binary_writer.hpp>
12
+
13
+
14
+ namespace Amulet {
15
+
16
+ struct PtrLess {
17
+ bool operator()(std::shared_ptr<BlockStack> lhs, std::shared_ptr<BlockStack> rhs) const {
18
+ return *lhs < *rhs;
19
+ }
20
+ };
21
+
22
+ class BlockPalette : public VersionRangeContainer {
23
+ private:
24
+ std::vector<std::shared_ptr<BlockStack>> _index_to_block;
25
+ std::map<
26
+ const std::shared_ptr<BlockStack>,
27
+ size_t,
28
+ PtrLess
29
+ > _block_to_index;
30
+ public:
31
+ const std::vector<std::shared_ptr<BlockStack>>& get_blocks() const { return _index_to_block; }
32
+
33
+ BlockPalette(std::shared_ptr<VersionRange> version_range) :
34
+ VersionRangeContainer(version_range),
35
+ _index_to_block(),
36
+ _block_to_index() {}
37
+
38
+ void serialise(BinaryWriter&) const;
39
+ static std::shared_ptr<BlockPalette> deserialise(BinaryReader&);
40
+
41
+ bool operator==(const BlockPalette& other) const {
42
+ if (size() != other.size()) {
43
+ return false;
44
+ }
45
+ for (size_t i = 0; i < size(); i++) {
46
+ if (*_index_to_block[i] != *other._index_to_block[i]) {
47
+ return false;
48
+ }
49
+ }
50
+ return true;
51
+ };
52
+
53
+ size_t size() const { return _index_to_block.size(); }
54
+
55
+ std::shared_ptr<BlockStack> index_to_block_stack(size_t index) const {
56
+ return _index_to_block[index];
57
+ };
58
+
59
+ size_t block_stack_to_index(std::shared_ptr<BlockStack> block) {
60
+ auto it = _block_to_index.find(block);
61
+ if (it != _block_to_index.end()) {
62
+ return it->second;
63
+ }
64
+ auto version_range = get_version_range();
65
+ for (const auto& block : block->get_blocks()) {
66
+ if (!version_range->contains(block->get_platform(), *block->get_version())) {
67
+ throw std::invalid_argument(
68
+ "BlockStack(\"" +
69
+ block->get_platform() +
70
+ "\", " +
71
+ block->get_version()->toString() +
72
+ ") is incompatible with VersionRange(\"" +
73
+ version_range->get_platform() +
74
+ "\", " +
75
+ version_range->get_min_version()->toString() +
76
+ ", " +
77
+ version_range->get_max_version()->toString() +
78
+ ")."
79
+ );
80
+ }
81
+ }
82
+ size_t index = _index_to_block.size();
83
+ _index_to_block.push_back(block);
84
+ _block_to_index[block] = index;
85
+ return index;
86
+ };
87
+
88
+ bool contains_block(std::shared_ptr<BlockStack> block) const {
89
+ return _block_to_index.contains(block);
90
+ }
91
+ };
92
+
93
+ }
@@ -0,0 +1,76 @@
1
+ #pragma once
2
+ #include <pybind11/pybind11.h>
3
+
4
+ namespace pybind11 {
5
+ namespace collections {
6
+ template <typename T>
7
+ class Iterator : public object {
8
+ PYBIND11_OBJECT_DEFAULT(Iterator, object, PyObject_Type)
9
+ using object::object;
10
+ };
11
+ }
12
+ namespace detail {
13
+ template <typename T>
14
+ struct handle_type_name<collections::Iterator<T>> {
15
+ static constexpr auto name =
16
+ const_name("collections.abc.Iterator[") +
17
+ make_caster<T>::name +
18
+ const_name("]");
19
+ };
20
+ }
21
+
22
+ namespace collections {
23
+ template <typename T>
24
+ class Sequence : public object {
25
+ PYBIND11_OBJECT_DEFAULT(Sequence, object, PyObject_Type)
26
+ using object::object;
27
+ };
28
+ }
29
+ namespace detail {
30
+ template <typename T>
31
+ struct handle_type_name<collections::Sequence<T>> {
32
+ static constexpr auto name =
33
+ const_name("collections.abc.Sequence[") +
34
+ make_caster<T>::name +
35
+ const_name("]");
36
+ };
37
+ }
38
+
39
+ namespace collections {
40
+ template <typename K, typename V>
41
+ class Mapping : public object {
42
+ PYBIND11_OBJECT_DEFAULT(Mapping, object, PyObject_Type)
43
+ using object::object;
44
+ };
45
+ }
46
+ namespace detail {
47
+ template <typename K, typename V>
48
+ struct handle_type_name<collections::Mapping<K, V>> {
49
+ static constexpr auto name =
50
+ const_name("collections.abc.Mapping[") +
51
+ make_caster<K>::name +
52
+ const_name(", ") +
53
+ make_caster<V>::name +
54
+ const_name("]");
55
+ };
56
+ }
57
+
58
+ namespace collections {
59
+ template <typename K, typename V>
60
+ class MutableMapping : public object {
61
+ PYBIND11_OBJECT_DEFAULT(MutableMapping, object, PyObject_Type)
62
+ using object::object;
63
+ };
64
+ }
65
+ namespace detail {
66
+ template <typename K, typename V>
67
+ struct handle_type_name<collections::MutableMapping<K, V>> {
68
+ static constexpr auto name =
69
+ const_name("collections.abc.MutableMapping[") +
70
+ make_caster<K>::name +
71
+ const_name(", ")
72
+ + make_caster<V>::name +
73
+ const_name("]");
74
+ };
75
+ }
76
+ }
@@ -0,0 +1,69 @@
1
+ #pragma once
2
+
3
+ #include <string>
4
+ #include <functional>
5
+ #include <filesystem>
6
+ #include <map>
7
+ #include <utility>
8
+
9
+ #include <pybind11/pybind11.h>
10
+
11
+ namespace py = pybind11;
12
+
13
+ namespace pybind11 {
14
+ // Define deferred variables
15
+ inline void def_deferred(
16
+ py::module m,
17
+ std::map<std::string, std::function<py::object()>> attrs
18
+ ){
19
+ m.def(
20
+ "__getattr__",
21
+ [attrs](py::object attr) -> py::object {
22
+ if (py::isinstance<py::str>(attr)) {
23
+ std::string attr_str = attr.cast<std::string>();
24
+ auto it = attrs.find(attr_str);
25
+ if (it != attrs.end()) {
26
+ return it->second();
27
+ }
28
+ }
29
+ throw py::attribute_error(py::repr(attr));
30
+ }
31
+ );
32
+ m.def(
33
+ "__dir__",
34
+ [attrs, m]() {
35
+ py::set names;
36
+ // Add the variables defined in the module
37
+ py::object dict = m.attr("__dict__");
38
+ for (auto it = dict.begin(); it != dict.end(); it++) {
39
+ names.add(*it);
40
+ }
41
+ // Add the deferred variables
42
+ for (const auto& [name, _] : attrs) {
43
+ names.add(py::str(name));
44
+ }
45
+ // Return as list
46
+ return py::module::import("builtins").attr("list")(names);
47
+ }
48
+ );
49
+ }
50
+
51
+ inline std::pair<std::string, std::function<py::object()>> deferred_package_path(py::module m_parent, py::module m, std::string name) {
52
+ auto getter = [m_parent, m, name]() {
53
+ std::string path = m_parent.attr("__path__").attr("__getitem__")(0).cast<std::string>();
54
+ path.push_back(std::filesystem::path::preferred_separator);
55
+ path.append(name);
56
+ py::list __path__;
57
+ __path__.append(py::cast(path));
58
+ return __path__;
59
+ };
60
+ return std::make_pair("__path__", getter);
61
+ }
62
+
63
+ inline std::pair<std::string, std::function<py::object()>> deferred_import(std::string module_name, std::string name) {
64
+ auto getter = [module_name, name]() {
65
+ return py::module::import(module_name.c_str()).attr(name.c_str());
66
+ };
67
+ return std::make_pair(name, getter);
68
+ }
69
+ }
@@ -0,0 +1,14 @@
1
+ #pragma once
2
+
3
+ #include <pybind11/pybind11.h>
4
+
5
+ namespace py = pybind11;
6
+
7
+ namespace pybind11 {
8
+ inline bool equals(
9
+ const py::handle l,
10
+ const py::handle r
11
+ ){
12
+ return PyObject_RichCompare(l.ptr(), r.ptr(), Py_EQ);
13
+ }
14
+ }
@@ -0,0 +1,17 @@
1
+ #pragma once
2
+ #include <pybind11/pybind11.h>
3
+
4
+ namespace pybind11 {
5
+ namespace types {
6
+ class NotImplementedType : public object {
7
+ PYBIND11_OBJECT_DEFAULT(NotImplementedType, object, PyObject_Type)
8
+ using object::object;
9
+ };
10
+ }
11
+ namespace detail {
12
+ template <>
13
+ struct handle_type_name<types::NotImplementedType> {
14
+ static constexpr auto name = const_name("types.NotImplementedType");
15
+ };
16
+ }
17
+ }
amulet/utils/numpy.hpp ADDED
@@ -0,0 +1,36 @@
1
+ #pragma once
2
+
3
+ #include <cstdint>
4
+ #include <vector>
5
+ #include <utility>
6
+ #include <span>
7
+ #include <unordered_map>
8
+
9
+
10
+ namespace Amulet {
11
+ // dtypeT can be any numerical type.
12
+ // inverseT must be large enough to store the length of arr.
13
+ template <typename dtypeT, typename inverseT>
14
+ void unique_inverse(const std::span<dtypeT> arr, std::vector<dtypeT>& unique, std::span<inverseT>& inverse){
15
+ if (arr.size() != inverse.size()){
16
+ throw std::invalid_argument("arr and inverse must have the same size.");
17
+ }
18
+ if (unique.size()){
19
+ throw std::invalid_argument("unique must be empty.");
20
+ }
21
+ // Map from found values to their index in unique
22
+ std::unordered_map<dtypeT, inverseT> value_to_index;
23
+
24
+ for (inverseT i = 0; i < arr.size(); i++){
25
+ dtypeT value = arr[i];
26
+ auto it = value_to_index.find(value);
27
+ if (it == value_to_index.end()){
28
+ inverse[i] = unique.size();
29
+ value_to_index[value] = unique.size();
30
+ unique.push_back(value);
31
+ } else {
32
+ inverse[i] = it->second;
33
+ }
34
+ }
35
+ }
36
+ }
amulet/version.py.cpp ADDED
@@ -0,0 +1,281 @@
1
+ #include <sstream>
2
+
3
+ #include <pybind11/pybind11.h>
4
+ #include <pybind11/stl.h>
5
+ #include <pybind11/operators.h>
6
+
7
+ #include <amulet/collections/eq.py.hpp>
8
+ #include <amulet/version.hpp>
9
+
10
+ namespace py = pybind11;
11
+
12
+ void init_version(py::module m_parent) {
13
+ auto m = m_parent.def_submodule("version");
14
+ py::options options;
15
+
16
+ m.attr("PlatformType") = py::module::import("builtins").attr("str");
17
+
18
+ py::class_<Amulet::VersionNumber, std::shared_ptr<Amulet::VersionNumber>> VersionNumber(m, "VersionNumber",
19
+ "This class is designed to store semantic versions and data versions and allow comparisons between them.\n"
20
+ "\n"
21
+ ">>> v1 = VersionNumber(1, 0, 0)\n"
22
+ ">>> v2 = VersionNumber(1, 0)\n"
23
+ ">>> assert v2 == v1\n"
24
+ "\n"
25
+ "This class should also be used to store single number data versions.\n"
26
+ ">>> v3 = VersionNumber(3578)"
27
+ );
28
+ options.disable_function_signatures();
29
+ VersionNumber.def(
30
+ py::init(
31
+ [](py::args v){
32
+ return std::make_shared<Amulet::VersionNumber>(
33
+ v.cast<std::vector<std::int64_t>>()
34
+ );
35
+ }
36
+ ),
37
+ py::doc("__init__(self: amulet.version.VersionNumber, *args: typing.SupportsInt) -> None")
38
+ );
39
+
40
+ // Start collections.abc.Sequence
41
+ VersionNumber.def(
42
+ "__getitem__",
43
+ &Amulet::VersionNumber::operator[],
44
+ py::doc(
45
+ "__getitem__(*args, **kwargs)\n"
46
+ "Overloaded function.\n"
47
+ "1. __getitem__(self: amulet.version.VersionNumber, item: typing.SupportsInt) -> int\n"
48
+ "2. __getitem__(self: amulet.version.VersionNumber, item: slice) -> list[int]"
49
+ )
50
+ );
51
+ VersionNumber.def(
52
+ "__getitem__",
53
+ [](const Amulet::VersionNumber& self, const py::slice &slice) -> std::vector<std::int64_t> {
54
+ size_t start = 0, stop = 0, step = 0, slicelength = 0;
55
+ if (!slice.compute(self.size(), &start, &stop, &step, &slicelength)) {
56
+ throw py::error_already_set();
57
+ }
58
+ std::vector<std::int64_t> out(slicelength);
59
+ for (size_t i = 0; i < slicelength; ++i) {
60
+ out[i] = self[start];
61
+ start += step;
62
+ }
63
+ return out;
64
+ }
65
+ );
66
+ options.enable_function_signatures();
67
+
68
+ VersionNumber.def(
69
+ "__repr__",
70
+ [](const Amulet::VersionNumber& self){
71
+ std::ostringstream oss;
72
+ auto& vec = self.get_vector();
73
+ oss << "VersionNumber(";
74
+ for (size_t i = 0; i < vec.size(); i++){
75
+ if (i != 0){
76
+ oss << ", ";
77
+ }
78
+ oss << vec[i];
79
+ }
80
+ oss << ")";
81
+ return oss.str();
82
+ }
83
+ );
84
+ VersionNumber.def(
85
+ py::pickle(
86
+ [](const Amulet::VersionNumber& self) {
87
+ return py::bytes(Amulet::serialise(self));
88
+ },
89
+ [](py::bytes state){
90
+ return Amulet::deserialise<Amulet::VersionNumber>(state.cast<std::string>());
91
+ }
92
+ )
93
+ );
94
+
95
+ VersionNumber.def(
96
+ "__len__",
97
+ &Amulet::VersionNumber::size
98
+ );
99
+
100
+ VersionNumber.def(
101
+ "__contains__",
102
+ [](const Amulet::VersionNumber& self, std::int64_t value) {
103
+ for (auto it = self.begin(); it != self.end(); it++){
104
+ if (*it == value) return true;
105
+ }
106
+ return false;
107
+ }
108
+ );
109
+
110
+ VersionNumber.def(
111
+ "__iter__",
112
+ [](const Amulet::VersionNumber& self) {return py::make_iterator(self.begin(), self.end());},
113
+ py::keep_alive<0, 1>() /* Essential: keep object alive while iterator exists */
114
+ );
115
+
116
+ VersionNumber.def(
117
+ "__reversed__",
118
+ [](const Amulet::VersionNumber& self) {return py::make_iterator(self.rbegin(), self.rend());},
119
+ py::keep_alive<0, 1>() /* Essential: keep object alive while iterator exists */
120
+ );
121
+
122
+ VersionNumber.def(
123
+ "index",
124
+ [](const Amulet::VersionNumber& self, std::int64_t value, size_t start, size_t stop) {
125
+ start = std::min(start, self.size());
126
+ stop = std::min(stop, self.size());
127
+ for (size_t i = start; i < stop; i++){
128
+ if (self[i] == value) return i;
129
+ }
130
+ throw py::value_error(std::to_string(value) + " is not in VersionNumber.");
131
+ },
132
+ py::arg("value"), py::arg("start") = 0, py::arg("stop") = std::numeric_limits<size_t>::max()
133
+ );
134
+
135
+ VersionNumber.def(
136
+ "count",
137
+ [](const Amulet::VersionNumber& self, std::int64_t value) {
138
+ size_t count = 0;
139
+ for (size_t i = 0; i < self.size(); i++){
140
+ if (self[i] == value) ++count;
141
+ }
142
+ return count;
143
+ },
144
+ py::arg("value")
145
+ );
146
+
147
+ // End collections.abc.Sequence
148
+
149
+ VersionNumber.def(
150
+ "__str__",
151
+ &Amulet::VersionNumber::toString
152
+ );
153
+
154
+ Eq(VersionNumber);
155
+ Eq_default(VersionNumber);
156
+ VersionNumber.def(pybind11::self < pybind11::self);
157
+ VersionNumber.def(pybind11::self > pybind11::self);
158
+ VersionNumber.def(pybind11::self <= pybind11::self);
159
+ VersionNumber.def(pybind11::self >= pybind11::self);
160
+
161
+ VersionNumber.def(
162
+ "cropped_version",
163
+ [](const Amulet::VersionNumber& self) -> py::tuple {return py::cast(self.cropped_version());},
164
+ py::doc("The version number with trailing zeros cut off.")
165
+ );
166
+
167
+ VersionNumber.def(
168
+ "padded_version",
169
+ [](const Amulet::VersionNumber& self, size_t len) -> py::tuple {return py::cast(self.padded_version(len));},
170
+ py::doc("Get the version number padded with zeros to the given length."),
171
+ py::arg("len")
172
+ );
173
+
174
+ VersionNumber.def(
175
+ "__hash__",
176
+ [](const Amulet::VersionNumber& self) {
177
+ py::tuple py_tuple = py::cast(self.cropped_version());
178
+ return py::hash(py_tuple);
179
+ }
180
+ );
181
+
182
+ py::module::import("collections.abc").attr("Sequence").attr("register")(VersionNumber);
183
+
184
+
185
+ py::class_<Amulet::PlatformVersionContainer, std::shared_ptr<Amulet::PlatformVersionContainer>> PlatformVersionContainer(m, "PlatformVersionContainer");
186
+ PlatformVersionContainer.def(
187
+ py::init<
188
+ const Amulet::PlatformType&,
189
+ std::shared_ptr<Amulet::VersionNumber>
190
+ >(),
191
+ py::arg("platform"),
192
+ py::arg("version")
193
+ );
194
+ PlatformVersionContainer.def_property_readonly("platform", &Amulet::PlatformVersionContainer::get_platform);
195
+ PlatformVersionContainer.def_property_readonly("version", &Amulet::PlatformVersionContainer::get_version);
196
+ PlatformVersionContainer.def(
197
+ "__repr__",
198
+ [](const Amulet::PlatformVersionContainer& self){
199
+ return "PlatformVersionContainer(" +
200
+ py::repr(py::cast(self.get_platform())).cast<std::string>() + ", " +
201
+ py::repr(py::cast(self.get_version())).cast<std::string>() +
202
+ ")";
203
+ }
204
+ );
205
+ PlatformVersionContainer.def(
206
+ py::pickle(
207
+ [](const Amulet::PlatformVersionContainer& self) -> py::bytes {
208
+ return py::bytes(Amulet::serialise(self));
209
+ },
210
+ [](py::bytes state){
211
+ return Amulet::deserialise<Amulet::PlatformVersionContainer>(state.cast<std::string>());
212
+ }
213
+ )
214
+ );
215
+
216
+
217
+ py::class_<Amulet::VersionRange, std::shared_ptr<Amulet::VersionRange>> VersionRange(m, "VersionRange");
218
+ VersionRange.def(
219
+ py::init<
220
+ const Amulet::PlatformType&,
221
+ std::shared_ptr<Amulet::VersionNumber>,
222
+ std::shared_ptr<Amulet::VersionNumber>
223
+ >(),
224
+ py::arg("platform"),
225
+ py::arg("min_version"),
226
+ py::arg("max_version")
227
+ );
228
+ VersionRange.def_property_readonly("platform", &Amulet::VersionRange::get_platform);
229
+ VersionRange.def_property_readonly("min_version", &Amulet::VersionRange::get_min_version);
230
+ VersionRange.def_property_readonly("max_version", &Amulet::VersionRange::get_max_version);
231
+ VersionRange.def(
232
+ "contains",
233
+ &Amulet::VersionRange::contains
234
+ );
235
+ VersionRange.def(
236
+ "__repr__",
237
+ [](const Amulet::VersionRange& self){
238
+ return "VersionRange(" +
239
+ py::repr(py::cast(self.get_platform())).cast<std::string>() + ", " +
240
+ py::repr(py::cast(self.get_min_version())).cast<std::string>() + ", " +
241
+ py::repr(py::cast(self.get_max_version())).cast<std::string>() +
242
+ ")";
243
+ }
244
+ );
245
+ VersionRange.def(
246
+ py::pickle(
247
+ [](const Amulet::VersionRange& self) -> py::bytes {
248
+ return py::bytes(Amulet::serialise(self));
249
+ },
250
+ [](py::bytes state){
251
+ return Amulet::deserialise<Amulet::VersionRange>(state.cast<std::string>());
252
+ }
253
+ )
254
+ );
255
+
256
+
257
+ py::class_<Amulet::VersionRangeContainer, std::shared_ptr<Amulet::VersionRangeContainer>> VersionRangeContainer(m, "VersionRangeContainer");
258
+ VersionRangeContainer.def(
259
+ py::init<
260
+ std::shared_ptr<Amulet::VersionRange>
261
+ >(),
262
+ py::arg("version_range")
263
+ );
264
+ VersionRangeContainer.def_property_readonly("version_range", &Amulet::VersionRangeContainer::get_version_range);
265
+ VersionRangeContainer.def(
266
+ "__repr__",
267
+ [](const Amulet::VersionRangeContainer& self){
268
+ return "VersionRangeContainer(" + py::repr(py::cast(self.get_version_range())).cast<std::string>() + ")";
269
+ }
270
+ );
271
+ VersionRangeContainer.def(
272
+ py::pickle(
273
+ [](const Amulet::VersionRangeContainer& self) -> py::bytes {
274
+ return py::bytes(Amulet::serialise(self));
275
+ },
276
+ [](py::bytes state){
277
+ return Amulet::deserialise<Amulet::VersionRangeContainer>(state.cast<std::string>());
278
+ }
279
+ )
280
+ );
281
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: amulet-core
3
- Version: 2.0a5
3
+ Version: 2.0a6
4
4
  Summary: A Python library for reading/writing Minecraft's various save formats.
5
5
  Home-page: https://www.amuletmc.com
6
6
  Author: James Clare, Ben Gothard et al.
@@ -10,7 +10,7 @@ Classifier: Programming Language :: Python :: 3
10
10
  Classifier: Operating System :: OS Independent
11
11
  Requires-Python: >=3.11
12
12
  Description-Content-Type: text/markdown
13
- Requires-Dist: numpy~=1.21
13
+ Requires-Dist: numpy~=2.0
14
14
  Requires-Dist: amulet-nbt~=4.0a2
15
15
  Requires-Dist: portalocker~=2.4
16
16
  Requires-Dist: amulet-leveldb~=1.0b0