amulet-core 2.0a8__cp311-cp311-win_amd64.whl → 2.0.1a2.post250529084738__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 (271) hide show
  1. amulet/core/__init__.py +36 -0
  2. amulet/core/__pyinstaller/hook-amulet.core.py +4 -0
  3. amulet/core/_amulet_core.cp311-win_amd64.pyd +0 -0
  4. amulet/core/_amulet_core.pyi +7 -0
  5. amulet/{_version.py → core/_version.py} +3 -3
  6. amulet/core/amulet_core.dll +0 -0
  7. amulet/core/amulet_core.lib +0 -0
  8. amulet/core/amulet_coreConfig.cmake +18 -0
  9. amulet/{biome.pyi → core/biome/__init__.pyi} +3 -3
  10. amulet/core/biome/biome.hpp +53 -0
  11. amulet/{block.pyi → core/block/__init__.pyi} +25 -26
  12. amulet/core/block/block.hpp +156 -0
  13. amulet/{block_entity.pyi → core/block_entity/__init__.pyi} +7 -7
  14. amulet/core/block_entity/block_entity.hpp +84 -0
  15. amulet/{errors.py → core/chunk/__init__.pyi} +37 -33
  16. amulet/core/chunk/chunk.hpp +126 -0
  17. amulet/core/chunk/component/__init__.pyi +18 -0
  18. amulet/core/chunk/component/biome_3d_component.hpp +96 -0
  19. amulet/core/chunk/component/block_component.hpp +101 -0
  20. amulet/core/chunk/component/block_component.pyi +28 -0
  21. amulet/core/chunk/component/block_entity_component.hpp +119 -0
  22. amulet/core/chunk/component/section_array_map.hpp +129 -0
  23. amulet/{chunk_components.pyi → core/chunk/component/section_array_map.pyi} +4 -24
  24. amulet/core/dll.hpp +21 -0
  25. amulet/core/entity/__init__.pyi +105 -0
  26. amulet/core/entity/entity.hpp +100 -0
  27. amulet/{palette → core/palette}/__init__.pyi +2 -2
  28. amulet/core/palette/biome_palette.hpp +65 -0
  29. amulet/{palette → core/palette}/biome_palette.pyi +8 -8
  30. amulet/core/palette/block_palette.hpp +71 -0
  31. amulet/{palette → core/palette}/block_palette.pyi +12 -10
  32. amulet/core/selection/__init__.pyi +8 -0
  33. amulet/core/selection/box.hpp +86 -0
  34. amulet/core/selection/box.pyi +215 -0
  35. amulet/core/selection/group.hpp +80 -0
  36. amulet/core/selection/group.pyi +213 -0
  37. amulet/{version.pyi → core/version/__init__.pyi} +58 -10
  38. amulet/core/version/version.hpp +204 -0
  39. {amulet_core-2.0a8.dist-info → amulet_core-2.0.1a2.post250529084738.dist-info}/METADATA +25 -20
  40. amulet_core-2.0.1a2.post250529084738.dist-info/RECORD +45 -0
  41. {amulet_core-2.0a8.dist-info → amulet_core-2.0.1a2.post250529084738.dist-info}/WHEEL +1 -1
  42. amulet_core-2.0.1a2.post250529084738.dist-info/entry_points.txt +2 -0
  43. amulet/__init__.cp311-win_amd64.pyd +0 -0
  44. amulet/__init__.py.cpp +0 -45
  45. amulet/__init__.pyi +0 -30
  46. amulet/__pyinstaller/hook-amulet.py +0 -4
  47. amulet/_init.py +0 -26
  48. amulet/biome.cpp +0 -36
  49. amulet/biome.hpp +0 -43
  50. amulet/biome.py.cpp +0 -122
  51. amulet/block.cpp +0 -435
  52. amulet/block.hpp +0 -119
  53. amulet/block.py.cpp +0 -377
  54. amulet/block_entity.cpp +0 -12
  55. amulet/block_entity.hpp +0 -56
  56. amulet/block_entity.py.cpp +0 -115
  57. amulet/chunk.cpp +0 -16
  58. amulet/chunk.hpp +0 -100
  59. amulet/chunk.py.cpp +0 -80
  60. amulet/chunk.pyi +0 -28
  61. amulet/chunk_components/biome_3d_component.cpp +0 -5
  62. amulet/chunk_components/biome_3d_component.hpp +0 -79
  63. amulet/chunk_components/block_component.cpp +0 -41
  64. amulet/chunk_components/block_component.hpp +0 -88
  65. amulet/chunk_components/block_entity_component.cpp +0 -5
  66. amulet/chunk_components/block_entity_component.hpp +0 -147
  67. amulet/chunk_components/section_array_map.cpp +0 -129
  68. amulet/chunk_components/section_array_map.hpp +0 -147
  69. amulet/collections/eq.py.hpp +0 -37
  70. amulet/collections/hash.py.hpp +0 -27
  71. amulet/collections/holder.py.hpp +0 -37
  72. amulet/collections/iterator.py.hpp +0 -80
  73. amulet/collections/mapping.py.hpp +0 -199
  74. amulet/collections/mutable_mapping.py.hpp +0 -226
  75. amulet/collections/sequence.py.hpp +0 -163
  76. amulet/collections.pyi +0 -40
  77. amulet/data_types.py +0 -29
  78. amulet/entity.py +0 -182
  79. amulet/game/__init__.py +0 -7
  80. amulet/game/_game.py +0 -152
  81. amulet/game/_universal/__init__.py +0 -1
  82. amulet/game/_universal/_biome.py +0 -17
  83. amulet/game/_universal/_block.py +0 -47
  84. amulet/game/_universal/_version.py +0 -68
  85. amulet/game/abc/__init__.py +0 -22
  86. amulet/game/abc/_block_specification.py +0 -150
  87. amulet/game/abc/biome.py +0 -213
  88. amulet/game/abc/block.py +0 -331
  89. amulet/game/abc/game_version_container.py +0 -25
  90. amulet/game/abc/json_interface.py +0 -27
  91. amulet/game/abc/version.py +0 -44
  92. amulet/game/bedrock/__init__.py +0 -1
  93. amulet/game/bedrock/_biome.py +0 -35
  94. amulet/game/bedrock/_block.py +0 -42
  95. amulet/game/bedrock/_version.py +0 -165
  96. amulet/game/java/__init__.py +0 -2
  97. amulet/game/java/_biome.py +0 -35
  98. amulet/game/java/_block.py +0 -60
  99. amulet/game/java/_version.py +0 -176
  100. amulet/game/translate/__init__.py +0 -12
  101. amulet/game/translate/_functions/__init__.py +0 -15
  102. amulet/game/translate/_functions/_code_functions/__init__.py +0 -0
  103. amulet/game/translate/_functions/_code_functions/_text.py +0 -553
  104. amulet/game/translate/_functions/_code_functions/banner_pattern.py +0 -67
  105. amulet/game/translate/_functions/_code_functions/bedrock_chest_connection.py +0 -152
  106. amulet/game/translate/_functions/_code_functions/bedrock_moving_block_pos.py +0 -88
  107. amulet/game/translate/_functions/_code_functions/bedrock_sign.py +0 -152
  108. amulet/game/translate/_functions/_code_functions/bedrock_skull_rotation.py +0 -16
  109. amulet/game/translate/_functions/_code_functions/custom_name.py +0 -146
  110. amulet/game/translate/_functions/_frozen.py +0 -66
  111. amulet/game/translate/_functions/_state.py +0 -54
  112. amulet/game/translate/_functions/_typing.py +0 -98
  113. amulet/game/translate/_functions/abc.py +0 -123
  114. amulet/game/translate/_functions/carry_nbt.py +0 -160
  115. amulet/game/translate/_functions/carry_properties.py +0 -80
  116. amulet/game/translate/_functions/code.py +0 -143
  117. amulet/game/translate/_functions/map_block_name.py +0 -66
  118. amulet/game/translate/_functions/map_nbt.py +0 -111
  119. amulet/game/translate/_functions/map_properties.py +0 -93
  120. amulet/game/translate/_functions/multiblock.py +0 -112
  121. amulet/game/translate/_functions/new_block.py +0 -42
  122. amulet/game/translate/_functions/new_entity.py +0 -43
  123. amulet/game/translate/_functions/new_nbt.py +0 -206
  124. amulet/game/translate/_functions/new_properties.py +0 -64
  125. amulet/game/translate/_functions/sequence.py +0 -51
  126. amulet/game/translate/_functions/walk_input_nbt.py +0 -331
  127. amulet/game/translate/_translator.py +0 -433
  128. amulet/img/__init__.py +0 -10
  129. amulet/img/missing_no.png +0 -0
  130. amulet/img/missing_pack.png +0 -0
  131. amulet/img/missing_world.png +0 -0
  132. amulet/io/binary_reader.hpp +0 -45
  133. amulet/io/binary_writer.hpp +0 -30
  134. amulet/item.py +0 -75
  135. amulet/level/__init__.pyi +0 -23
  136. amulet/level/_load.py +0 -100
  137. amulet/level/abc/__init__.py +0 -12
  138. amulet/level/abc/_chunk_handle.py +0 -358
  139. amulet/level/abc/_dimension.py +0 -86
  140. amulet/level/abc/_history/__init__.py +0 -1
  141. amulet/level/abc/_history/_cache.py +0 -224
  142. amulet/level/abc/_history/_history_manager.py +0 -291
  143. amulet/level/abc/_level/__init__.py +0 -5
  144. amulet/level/abc/_level/_compactable_level.py +0 -10
  145. amulet/level/abc/_level/_creatable_level.py +0 -28
  146. amulet/level/abc/_level/_disk_level.py +0 -17
  147. amulet/level/abc/_level/_level.py +0 -449
  148. amulet/level/abc/_level/_loadable_level.py +0 -42
  149. amulet/level/abc/_player_storage.py +0 -7
  150. amulet/level/abc/_raw_level.py +0 -187
  151. amulet/level/abc/_registry.py +0 -40
  152. amulet/level/java/__init__.pyi +0 -16
  153. amulet/level/java/_chunk_handle.py +0 -17
  154. amulet/level/java/_dimension.py +0 -20
  155. amulet/level/java/_level.py +0 -184
  156. amulet/level/java/_raw/__init__.pyi +0 -15
  157. amulet/level/java/_raw/_chunk.pyi +0 -23
  158. amulet/level/java/_raw/_constant.py +0 -9
  159. amulet/level/java/_raw/_data_pack/__init__.py +0 -2
  160. amulet/level/java/_raw/_data_pack/data_pack.py +0 -241
  161. amulet/level/java/_raw/_data_pack/data_pack_manager.py +0 -77
  162. amulet/level/java/_raw/_dimension.py +0 -86
  163. amulet/level/java/_raw/_level.py +0 -507
  164. amulet/level/java/_raw/_typing.py +0 -3
  165. amulet/level/java/_raw/java_chunk_decode.cpp +0 -531
  166. amulet/level/java/_raw/java_chunk_decode.hpp +0 -23
  167. amulet/level/java/_raw/java_chunk_encode.cpp +0 -25
  168. amulet/level/java/_raw/java_chunk_encode.hpp +0 -23
  169. amulet/level/java/anvil/__init__.py +0 -2
  170. amulet/level/java/anvil/_dimension.py +0 -170
  171. amulet/level/java/anvil/_region.py +0 -421
  172. amulet/level/java/anvil/_sector_manager.py +0 -223
  173. amulet/level/java/chunk.pyi +0 -81
  174. amulet/level/java/chunk_/_chunk.py +0 -260
  175. amulet/level/java/chunk_/components/inhabited_time.py +0 -12
  176. amulet/level/java/chunk_/components/last_update.py +0 -12
  177. amulet/level/java/chunk_/components/legacy_version.py +0 -12
  178. amulet/level/java/chunk_/components/light_populated.py +0 -12
  179. amulet/level/java/chunk_/components/named_height_2d.py +0 -37
  180. amulet/level/java/chunk_/components/status.py +0 -11
  181. amulet/level/java/chunk_/components/terrain_populated.py +0 -12
  182. amulet/level/java/chunk_components/data_version_component.cpp +0 -32
  183. amulet/level/java/chunk_components/data_version_component.hpp +0 -31
  184. amulet/level/java/chunk_components/java_raw_chunk_component.cpp +0 -56
  185. amulet/level/java/chunk_components/java_raw_chunk_component.hpp +0 -45
  186. amulet/level/java/chunk_components.pyi +0 -22
  187. amulet/level/java/java_chunk.cpp +0 -170
  188. amulet/level/java/java_chunk.hpp +0 -141
  189. amulet/level/java/long_array.hpp +0 -175
  190. amulet/level/java/long_array.pyi +0 -39
  191. amulet/level/temporary_level/__init__.py +0 -1
  192. amulet/level/temporary_level/_level.py +0 -16
  193. amulet/mesh/__init__.py +0 -0
  194. amulet/mesh/block/__init__.pyi +0 -301
  195. amulet/mesh/block/_cube.py +0 -198
  196. amulet/mesh/block/_missing_block.py +0 -20
  197. amulet/mesh/block/block_mesh.cpp +0 -107
  198. amulet/mesh/block/block_mesh.hpp +0 -207
  199. amulet/mesh/util.py +0 -17
  200. amulet/palette/biome_palette.hpp +0 -85
  201. amulet/palette/block_palette.cpp +0 -32
  202. amulet/palette/block_palette.hpp +0 -93
  203. amulet/player.py +0 -62
  204. amulet/pybind11/collections.hpp +0 -118
  205. amulet/pybind11/numpy.hpp +0 -26
  206. amulet/pybind11/py_module.hpp +0 -34
  207. amulet/pybind11/type_hints.hpp +0 -51
  208. amulet/pybind11/types.hpp +0 -25
  209. amulet/pybind11/typing.hpp +0 -7
  210. amulet/resource_pack/__init__.py +0 -63
  211. amulet/resource_pack/abc/__init__.py +0 -2
  212. amulet/resource_pack/abc/resource_pack.py +0 -38
  213. amulet/resource_pack/abc/resource_pack_manager.py +0 -85
  214. amulet/resource_pack/java/__init__.py +0 -2
  215. amulet/resource_pack/java/download_resources.py +0 -212
  216. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_black.png +0 -0
  217. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_blue.png +0 -0
  218. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_brown.png +0 -0
  219. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_cyan.png +0 -0
  220. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_gray.png +0 -0
  221. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_green.png +0 -0
  222. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_light_blue.png +0 -0
  223. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_light_gray.png +0 -0
  224. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_lime.png +0 -0
  225. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_magenta.png +0 -0
  226. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_orange.png +0 -0
  227. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_pink.png +0 -0
  228. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_purple.png +0 -0
  229. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_red.png +0 -0
  230. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_white.png +0 -0
  231. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_yellow.png +0 -0
  232. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/barrier.png +0 -0
  233. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/end_portal.png +0 -0
  234. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/grass.png +0 -0
  235. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/lava.png +0 -0
  236. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/structure_void.png +0 -0
  237. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/water.png +0 -0
  238. amulet/resource_pack/java/java_vanilla_fix/pack.png +0 -0
  239. amulet/resource_pack/java/resource_pack.py +0 -44
  240. amulet/resource_pack/java/resource_pack_manager.py +0 -563
  241. amulet/resource_pack/unknown_resource_pack.py +0 -10
  242. amulet/selection/__init__.py +0 -2
  243. amulet/selection/abstract_selection.py +0 -342
  244. amulet/selection/box.py +0 -852
  245. amulet/selection/group.py +0 -481
  246. amulet/utils/__init__.pyi +0 -23
  247. amulet/utils/call_spec/__init__.py +0 -24
  248. amulet/utils/call_spec/_call_spec.py +0 -257
  249. amulet/utils/cast.py +0 -10
  250. amulet/utils/comment_json.py +0 -188
  251. amulet/utils/format_utils.py +0 -41
  252. amulet/utils/generator.py +0 -18
  253. amulet/utils/matrix.py +0 -243
  254. amulet/utils/numpy.hpp +0 -36
  255. amulet/utils/numpy.pyi +0 -11
  256. amulet/utils/numpy_helpers.py +0 -19
  257. amulet/utils/shareable_lock.py +0 -335
  258. amulet/utils/signal/__init__.py +0 -10
  259. amulet/utils/signal/_signal.py +0 -228
  260. amulet/utils/task_manager.py +0 -235
  261. amulet/utils/typed_property.py +0 -111
  262. amulet/utils/weakref.py +0 -70
  263. amulet/utils/world_utils.py +0 -102
  264. amulet/version.cpp +0 -136
  265. amulet/version.hpp +0 -142
  266. amulet/version.py.cpp +0 -281
  267. amulet_core-2.0a8.dist-info/RECORD +0 -241
  268. amulet_core-2.0a8.dist-info/entry_points.txt +0 -2
  269. /amulet/{__pyinstaller → core/__pyinstaller}/__init__.py +0 -0
  270. /amulet/{py.typed → core/py.typed} +0 -0
  271. {amulet_core-2.0a8.dist-info → amulet_core-2.0.1a2.post250529084738.dist-info}/top_level.txt +0 -0
@@ -1,226 +0,0 @@
1
- #pragma once
2
-
3
- #include <memory>
4
-
5
- #include <pybind11/pybind11.h>
6
-
7
- #include "mapping.py.hpp"
8
-
9
- namespace py = pybind11;
10
-
11
- namespace Amulet {
12
- namespace collections {
13
- template <typename KT = py::object, typename VT = py::object, typename clsT>
14
- void PyMutableMapping_pop(clsT cls) {
15
- py::object marker = py::module::import("builtins").attr("Ellipsis");
16
- cls.def(
17
- "pop",
18
- [marker](
19
- py::object self,
20
- Amulet::pybind11::type_hints::PyObjectCpp<KT> key,
21
- Amulet::pybind11::type_hints::PyObjectCpp<VT> default_
22
- ) -> Amulet::pybind11::type_hints::PyObjectCpp<VT> {
23
- py::object value;
24
- try {
25
- value = self.attr("__getitem__")(key);
26
- }
27
- catch (const py::error_already_set& e) {
28
- if (e.matches(PyExc_KeyError)) {
29
- if (default_.is(marker)) {
30
- throw;
31
- }
32
- return default_;
33
- }
34
- else {
35
- throw;
36
- }
37
- }
38
- self.attr("__delitem__")(key);
39
- return value;
40
- },
41
- py::arg("key"),
42
- py::arg("default") = marker
43
- );
44
- }
45
-
46
- template <typename KT = py::object, typename VT = py::object, typename clsT>
47
- void PyMutableMapping_popitem(clsT cls) {
48
- py::object iter = py::module::import("builtins").attr("iter");
49
- py::object next = py::module::import("builtins").attr("next");
50
- cls.def(
51
- "popitem",
52
- [iter, next](py::object self) -> std::pair<
53
- Amulet::pybind11::type_hints::PyObjectCpp<KT>,
54
- Amulet::pybind11::type_hints::PyObjectCpp<VT>
55
- > {
56
- py::object key;
57
- try {
58
- key = next(iter(self));
59
- }
60
- catch (const py::error_already_set& e) {
61
- if (e.matches(PyExc_StopIteration)) {
62
- throw py::key_error();
63
- }
64
- else {
65
- throw;
66
- }
67
- }
68
- py::object value = self.attr("__getitem__")(key);
69
- self.attr("__delitem__")(key);
70
- return std::make_pair(key, value);
71
- }
72
- );
73
- }
74
-
75
- template <typename clsT>
76
- void PyMutableMapping_clear(clsT cls) {
77
- cls.def(
78
- "clear",
79
- [](py::object self) {
80
- try {
81
- while (true) {
82
- self.attr("popitem")();
83
- }
84
- }
85
- catch (const py::error_already_set& e) {
86
- if (!e.matches(PyExc_KeyError)) {
87
- throw;
88
- }
89
- }
90
- }
91
- );
92
- }
93
-
94
- template <typename clsT>
95
- void PyMutableMapping_update(clsT cls) {
96
- py::object isinstance = py::module::import("builtins").attr("isinstance");
97
- py::object hasattr = py::module::import("builtins").attr("hasattr");
98
- py::object PyMapping = py::module::import("collections.abc").attr("Mapping");
99
- cls.def(
100
- "update",
101
- [
102
- isinstance,
103
- hasattr,
104
- PyMapping
105
- ](
106
- py::object self,
107
- py::object other,
108
- py::kwargs kwargs
109
- ) {
110
- if (isinstance(other, PyMapping)) {
111
- for (auto it = other.begin(); it != other.end(); it++) {
112
- self.attr("__setitem__")(*it, other.attr("__getitem__")(*it));
113
- }
114
- }
115
- else if (hasattr(other, "keys")) {
116
- py::object keys = other.attr("keys")();
117
- for (auto it = keys.begin(); it != keys.end(); it++) {
118
- self.attr("__setitem__")(*it, other.attr("__getitem__")(*it));
119
- }
120
- }
121
- else {
122
- for (auto it = other.begin(); it != other.end(); it++) {
123
- self.attr("__setitem__")(
124
- *it->attr("__getitem__")(0),
125
- *it->attr("__getitem__")(1)
126
- );
127
- }
128
- }
129
- py::object items = kwargs.attr("items")();
130
- for (auto it = items.begin(); it != items.end(); it++) {
131
- self.attr("__setitem__")(
132
- *it->attr("__getitem__")(0),
133
- *it->attr("__getitem__")(1)
134
- );
135
- }
136
-
137
- },
138
- py::arg("other") = py::tuple()
139
- );
140
- }
141
-
142
- template <typename KT = py::object, typename VT = py::object, typename clsT>
143
- void PyMutableMapping_setdefault(clsT cls) {
144
- cls.def(
145
- "setdefault",
146
- [](
147
- py::object self,
148
- Amulet::pybind11::type_hints::PyObjectCpp<KT> key,
149
- py::typing::Optional<VT> default_ = py::none()
150
- ) -> py::typing::Optional<VT> {
151
- try {
152
- return self.attr("__getitem__")(key);
153
- }
154
- catch (const py::error_already_set& e) {
155
- if (e.matches(PyExc_KeyError)) {
156
- self.attr("__setitem__")(key, default_);
157
- }
158
- else {
159
- throw;
160
- }
161
- }
162
- return default_;
163
- }
164
- );
165
- }
166
-
167
- template <typename clsT>
168
- void PyMutableMapping_register(clsT cls) {
169
- py::module::import("collections.abc").attr("MutableMapping").attr("register")(cls);
170
- }
171
-
172
- class MutableMapping : public Mapping {
173
- public:
174
- virtual ~MutableMapping() {};
175
- virtual void setitem(py::object py_key, py::object py_value) = 0;
176
- virtual void delitem(py::object py_key) = 0;
177
- virtual void clear() = 0;
178
- };
179
-
180
- template <typename mapT>
181
- class Map : public MutableMapping {
182
- private:
183
- py::object _owner;
184
- mapT& _map;
185
- public:
186
- Map(
187
- mapT& map,
188
- py::object owner = py::none()
189
- ) : _owner(owner), _map(map) {}
190
-
191
- py::object getitem(py::object py_key) const override {
192
- return py::cast(_map.at(py_key.cast<typename mapT::key_type>()));
193
- }
194
- std::shared_ptr<Iterator> iter() const override {
195
- return std::make_shared<MapIterator<mapT>>(_map, _owner);
196
- }
197
- size_t size() const override {
198
- return _map.size();
199
- }
200
- bool contains(py::object py_key) const override {
201
- return _map.contains(py_key.cast<typename mapT::key_type>());
202
- }
203
- void setitem(py::object py_key, py::object py_value) override {
204
- _map.insert_or_assign(
205
- py_key.cast<typename mapT::key_type>(),
206
- py_value.cast<typename mapT::mapped_type>()
207
- );
208
- }
209
- void delitem(py::object py_key) override {
210
- _map.erase(py_key.cast<typename mapT::key_type>());
211
- }
212
- void clear() override {
213
- _map.clear();
214
- }
215
- };
216
-
217
- template <typename mapT>
218
- static py::object make_map(mapT& value, py::object owner = py::none()) {
219
- return py::cast(
220
- static_cast<std::shared_ptr<MutableMapping>>(
221
- std::make_shared<Map<mapT>>(value, owner)
222
- )
223
- );
224
- }
225
- }
226
- }
@@ -1,163 +0,0 @@
1
- #pragma once
2
-
3
- #include <algorithm>
4
- #include <cstddef>
5
- #include <memory>
6
-
7
- #include <pybind11/pybind11.h>
8
- #include "iterator.py.hpp"
9
- #include <amulet/pybind11/collections.hpp>
10
-
11
- namespace py = pybind11;
12
-
13
- namespace Amulet {
14
- namespace collections {
15
-
16
- template <typename clsT>
17
- void Sequence_getitem_slice(clsT cls) {
18
- cls.def(
19
- "__getitem__",
20
- [](py::object self, const py::slice& slice) {
21
- size_t start = 0, stop = 0, step = 0, slicelength = 0;
22
- if (!slice.compute(py::len(self), &start, &stop, &step, &slicelength)) {
23
- throw py::error_already_set();
24
- }
25
- py::list out(slicelength);
26
- py::object getitem = self.attr("__getitem__");
27
- for (size_t i = 0; i < slicelength; ++i) {
28
- out[i] = getitem(start);
29
- start += step;
30
- }
31
- return out;
32
- }
33
- );
34
- }
35
-
36
- template <typename clsT>
37
- void Sequence_contains(clsT cls) {
38
- cls.def(
39
- "__contains__",
40
- [](py::object self, py::object value) {
41
- py::iterator it = py::iter(self);
42
- while (it != py::iterator::sentinel()) {
43
- if (it->equal(value)) {
44
- return true;
45
- }
46
- ++it;
47
- }
48
- return false;
49
- }
50
- );
51
- }
52
-
53
- template <typename elemT = py::object, typename clsT>
54
- void Sequence_iter(clsT cls) {
55
- cls.def(
56
- "__iter__",
57
- [](py::object self) -> Amulet::pybind11::collections::Iterator<elemT> {
58
- return py::cast(
59
- static_cast<std::shared_ptr<Amulet::collections::Iterator>>(
60
- std::make_shared<PySequenceIterator>(self, 0, 1)
61
- )
62
- );
63
- }
64
- );
65
- }
66
-
67
- template <typename elemT = py::object, typename clsT>
68
- void Sequence_reversed(clsT cls) {
69
- cls.def(
70
- "__reversed__",
71
- [](py::object self) -> Amulet::pybind11::collections::Iterator<elemT> {
72
- return py::cast(
73
- static_cast<std::shared_ptr<Amulet::collections::Iterator>>(
74
- std::make_shared<PySequenceIterator>(self, py::len(self) - 1, -1)
75
- )
76
- );
77
- }
78
- );
79
- }
80
-
81
- template <typename clsT>
82
- void Sequence_index(clsT cls) {
83
- cls.def(
84
- "index",
85
- [](py::object self, py::object value, Py_ssize_t s_start, Py_ssize_t s_stop) {
86
- size_t size = py::len(self);
87
- size_t start;
88
- size_t stop;
89
- if (s_start < 0) {
90
- start = std::max<Py_ssize_t>(0, size + s_start);
91
- }
92
- else {
93
- start = s_start;
94
- }
95
- if (s_stop < 0) {
96
- stop = size + s_stop;
97
- }
98
- else {
99
- stop = s_stop;
100
- }
101
- py::object getitem = self.attr("__getitem__");
102
- while (start < stop) {
103
- py::object obj;
104
- try {
105
- obj = getitem(start);
106
- }
107
- catch (py::error_already_set& e) {
108
- if (e.matches(PyExc_IndexError)) {
109
- break;
110
- }
111
- else {
112
- throw;
113
- }
114
- }
115
-
116
- if (value.equal(obj)) {
117
- return start;
118
- }
119
-
120
- start++;
121
- }
122
- throw py::value_error("");
123
- },
124
- py::arg("value"), py::arg("start") = 0, py::arg("stop") = std::numeric_limits<Py_ssize_t>::max()
125
- );
126
- }
127
-
128
- template <typename clsT>
129
- void Sequence_count(clsT cls) {
130
- cls.def(
131
- "count",
132
- [](py::object self, py::object value) {
133
- size_t count = 0;
134
- size_t size = py::len(self);
135
- py::object getitem = self.attr("__getitem__");
136
- for (size_t i = 0; i < size; ++i) {
137
- if (value.equal(getitem(i))) {
138
- count++;
139
- }
140
- }
141
- return count;
142
- },
143
- py::arg("value")
144
- );
145
- }
146
-
147
- template <typename clsT>
148
- void Sequence_register(clsT cls) {
149
- py::module::import("collections.abc").attr("Sequence").attr("register")(cls);
150
- }
151
-
152
- template <typename elemT = py::object, typename clsT>
153
- void Sequence(clsT cls) {
154
- Sequence_getitem_slice(cls);
155
- Sequence_contains(cls);
156
- Sequence_iter<elemT>(cls);
157
- Sequence_reversed<elemT>(cls);
158
- Sequence_index(cls);
159
- Sequence_count(cls);
160
- Sequence_register(cls);
161
- }
162
- }
163
- }
amulet/collections.pyi DELETED
@@ -1,40 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import collections.abc
4
- import types
5
- import typing
6
-
7
- __all__ = ["Holder", "Iterator", "Mapping", "MutableMapping"]
8
-
9
- class Holder:
10
- """
11
- A utility class for keeping smart pointers alive.
12
- """
13
-
14
- class Iterator:
15
- def __iter__(self: typing.Iterator) -> typing.Iterator: ...
16
- def __next__(self: typing.Iterator) -> typing.Any: ...
17
-
18
- class Mapping:
19
- def __contains__(self, arg0: typing.Any) -> bool: ...
20
- def __eq__(self, arg0: typing.Any) -> bool | types.NotImplementedType: ...
21
- def __getitem__(self, arg0: typing.Any) -> typing.Any: ...
22
- def __hash__(self) -> int: ...
23
- def __iter__(self) -> typing.Iterator: ...
24
- def __len__(self) -> int: ...
25
- def __repr__(self) -> str: ...
26
- def get(self, arg0: typing.Any, arg1: typing.Any | None) -> typing.Any | None: ...
27
- def items(self) -> collections.abc.ItemsView[typing.Any, typing.Any]: ...
28
- def keys(self) -> collections.abc.KeysView[typing.Any]: ...
29
- def values(self) -> collections.abc.ValuesView[typing.Any]: ...
30
-
31
- class MutableMapping(Mapping):
32
- def __delitem__(self, arg0: typing.Any) -> None: ...
33
- def __setitem__(self, arg0: typing.Any, arg1: typing.Any) -> None: ...
34
- def clear(self) -> None: ...
35
- def pop(self, key: typing.Any, default: typing.Any = ...) -> typing.Any: ...
36
- def popitem(self) -> tuple[typing.Any, typing.Any]: ...
37
- def setdefault(
38
- self, arg0: typing.Any, arg1: typing.Any | None
39
- ) -> typing.Any | None: ...
40
- def update(self, other: typing.Any = (), **kwargs) -> None: ...
amulet/data_types.py DELETED
@@ -1,29 +0,0 @@
1
- from typing import TypeAlias
2
- import numpy
3
-
4
- #: The type for a dimension identifier
5
- DimensionId: TypeAlias = str
6
-
7
- #: The data type for the x and z coordinates of a region file. Note these are no the same as block coordinates.
8
- RegionCoordinates: TypeAlias = tuple[int, int]
9
-
10
- #: The data type for the x and z coordinate of a chunk. Note these are no the same as block coordinates.
11
- ChunkCoordinates: TypeAlias = tuple[int, int]
12
-
13
- #: The data type for the x, y and z coordinates of a sub-chunk within the world. Note these are no the same as block coordinates.
14
- SubChunkCoordinates: TypeAlias = tuple[int, int, int]
15
-
16
- #: The data type for the x, y and z location of a block within the world.
17
- BlockCoordinates: TypeAlias = tuple[int, int, int]
18
-
19
- #: The data type for the x, y and z location of a block within the world in the form of a numpy array.
20
- BlockCoordinatesArray: TypeAlias = numpy.ndarray # NDArray[(3, ), int]
21
-
22
- #: The data type for the x, y and z location of a point within the world.
23
- PointCoordinates: TypeAlias = tuple[float, float, float]
24
-
25
- #: The data type for the x, y and z location of a point within the world in the form of a numpy array.
26
- PointCoordinatesArray: TypeAlias = numpy.ndarray # NDArray[(3, ), numpy.float]
27
-
28
- #: The data type for a tuple containing three floats. Use :data:`PointCoordinates` for x, y, z float coordinates.
29
- FloatTriplet: TypeAlias = tuple[float, float, float]
amulet/entity.py DELETED
@@ -1,182 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from typing import Any
4
- from amulet_nbt import NamedTag
5
- from amulet.version import PlatformVersionContainer, VersionNumber
6
- from amulet.data_types import PointCoordinates
7
-
8
-
9
- class Entity(PlatformVersionContainer):
10
- """
11
- A class to contain all the data to define an Entity.
12
- """
13
-
14
- __slots__ = (
15
- "_namespace",
16
- "_base_name",
17
- "_x",
18
- "_y",
19
- "_z",
20
- "_nbt",
21
- )
22
-
23
- def __init__(
24
- self,
25
- platform: str,
26
- version: VersionNumber,
27
- namespace: str,
28
- base_name: str,
29
- x: float,
30
- y: float,
31
- z: float,
32
- nbt: NamedTag,
33
- ) -> None:
34
- """
35
- Constructs a :class:`Entity` instance.
36
-
37
- :param platform: The platform the entity is defined in.
38
- :param version: The version the entity is defined in.
39
- :param namespace: The namespace of the entity eg "minecraft"
40
- :param base_name: The base name of the entity eg "creeper"
41
- :param x: The x coordinate of the entity
42
- :param y: The y coordinate of the entity
43
- :param z: The z coordinate of the entity
44
- :param nbt: The NBT stored with the entity
45
- """
46
- super().__init__(platform, version)
47
- self._namespace = str(namespace)
48
- self._base_name = str(base_name)
49
- self._x = float(x)
50
- self._y = float(y)
51
- self._z = float(z)
52
- if not isinstance(nbt, NamedTag):
53
- raise TypeError(f"nbt must be an NamedTag. Got {nbt}")
54
- self._nbt = nbt
55
-
56
- def __getstate__(self) -> tuple[tuple[str, VersionNumber], tuple[str, str, float, float, float, NamedTag]]: # type: ignore[override]
57
- raise NotImplementedError
58
- # return (
59
- # super().__getstate__(),
60
- # (
61
- # self._namespace,
62
- # self._base_name,
63
- # self._x,
64
- # self._y,
65
- # self._z,
66
- # self._nbt,
67
- # ),
68
- # )
69
-
70
- def __setstate__(self, state: tuple[tuple[str, VersionNumber], tuple[str, str, float, float, float, NamedTag]]) -> None: # type: ignore[override]
71
- raise NotImplementedError
72
- # super().__setstate__(state[0])
73
- # (
74
- # self._namespace,
75
- # self._base_name,
76
- # self._x,
77
- # self._y,
78
- # self._z,
79
- # self._nbt,
80
- # ) = state[1]
81
-
82
- def __eq__(self, other: Any) -> bool:
83
- if not isinstance(other, Entity):
84
- return NotImplemented
85
- return self.__getstate__() == other.__getstate__()
86
-
87
- def __hash__(self) -> int:
88
- return id(self)
89
-
90
- def __repr__(self) -> str:
91
- return f"Entity({self.platform!r}, {self.version!r}, {self._namespace!r}, {self._base_name!r}, {self._x}, {self._y}, {self._z}, {self._nbt!r})"
92
-
93
- @property
94
- def namespaced_name(self) -> str:
95
- """
96
- The namespace:base_name of the entity represented by the object (eg: `minecraft:creeper`)
97
-
98
- If the given namespace is an empty string it will just return the base name.
99
-
100
- :return: namespace:base_name of the entity
101
- """
102
- return f"{self._namespace}:{self._base_name}"
103
-
104
- @property
105
- def namespace(self) -> str:
106
- """
107
- The namespace of the entity represented by the Entity object (eg: `minecraft`)
108
-
109
- :return: The namespace of the entity
110
- """
111
- return self._namespace
112
-
113
- @namespace.setter
114
- def namespace(self, value: str) -> None:
115
- self._namespace = value
116
-
117
- @property
118
- def base_name(self) -> str:
119
- """
120
- The base name of the entity represented by the Entity object (eg: `creeper`, `pig`)
121
-
122
- :return: The base name of the entity
123
- """
124
- return self._base_name
125
-
126
- @base_name.setter
127
- def base_name(self, value: str) -> None:
128
- self._base_name = value
129
-
130
- @property
131
- def x(self) -> float:
132
- """The x location of the Entity."""
133
- return self._x
134
-
135
- @x.setter
136
- def x(self, value: float) -> None:
137
- self._x = float(value)
138
-
139
- @property
140
- def y(self) -> float:
141
- """The y location of the Entity."""
142
- return self._y
143
-
144
- @y.setter
145
- def y(self, value: float) -> None:
146
- self._y = float(value)
147
-
148
- @property
149
- def z(self) -> float:
150
- """The z location of the Entity."""
151
- return self._z
152
-
153
- @z.setter
154
- def z(self, value: float) -> None:
155
- self._z = float(value)
156
-
157
- @property
158
- def location(self) -> PointCoordinates:
159
- """The location of the Entity."""
160
- return self._x, self._y, self._z
161
-
162
- @location.setter
163
- def location(self, location: PointCoordinates) -> None:
164
- self.x, self.y, self.z = location
165
-
166
- @property
167
- def nbt(self) -> NamedTag:
168
- """
169
- The NBT behind the object
170
-
171
- :getter: Get the NBT data stored in the object
172
- :setter: Set the NBT data stored in the object
173
-
174
- :return: A NamedTag
175
- """
176
- return self._nbt
177
-
178
- @nbt.setter
179
- def nbt(self, value: NamedTag) -> None:
180
- if not isinstance(value, NamedTag):
181
- raise TypeError
182
- self._nbt = value
amulet/game/__init__.py DELETED
@@ -1,7 +0,0 @@
1
- """
2
- A module to store data about the game including state enumerations and translations between different game versions.
3
- """
4
-
5
- from ._game import game_platforms, game_versions, get_game_version
6
- from .java import JavaGameVersion
7
- from .bedrock import BedrockGameVersion