amulet-core 2.0a8__cp311-cp311-win_amd64.whl → 2.0.1.0.1297307203.19.43.34808.0a1__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.1.0.1297307203.19.43.34808.0a1.dist-info}/METADATA +25 -20
  40. amulet_core-2.0.1.0.1297307203.19.43.34808.0a1.dist-info/RECORD +45 -0
  41. {amulet_core-2.0a8.dist-info → amulet_core-2.0.1.0.1297307203.19.43.34808.0a1.dist-info}/WHEEL +1 -1
  42. amulet_core-2.0.1.0.1297307203.19.43.34808.0a1.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.1.0.1297307203.19.43.34808.0a1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,126 @@
1
+ #pragma once
2
+
3
+ #include <functional>
4
+ #include <memory>
5
+ #include <optional>
6
+ #include <set>
7
+ #include <stdexcept>
8
+ #include <string>
9
+ #include <unordered_map>
10
+
11
+ #include <amulet/core/dll.hpp>
12
+
13
+ // Requirements:
14
+ // Split chunk data into components that are orthogonal to each other.
15
+ // create a chunk with all components default initialised.
16
+ // reconstruct a chunk from a subset of its components.
17
+ // reconstruct a chunk with all components.
18
+ // query if a chunk has a component. (isinstance/is_base_of/dynamic_cast or has_component)
19
+ // get a component. (method/property or get_component)
20
+ // set and validate a component. (method/property or set_component)
21
+ // serialise loaded components.
22
+
23
+ namespace Amulet {
24
+ typedef std::unordered_map<std::string, std::optional<std::string>> SerialisedChunkComponents;
25
+
26
+ // The abstract chunk class
27
+ class Chunk {
28
+ public:
29
+ virtual ~Chunk() = default;
30
+ virtual std::string get_chunk_id() const = 0;
31
+ virtual std::set<std::string> get_component_ids() const = 0;
32
+ // private:
33
+ // These are public but may become private one day
34
+ virtual SerialisedChunkComponents serialise_chunk() const = 0;
35
+ virtual void reconstruct_chunk(SerialisedChunkComponents) = 0;
36
+ };
37
+
38
+ namespace detail {
39
+ using ChunkContructor = std::function<std::shared_ptr<Chunk>()>;
40
+ AMULET_CORE_EXPORT void add_null_chunk_constructor(const std::string& id, ChunkContructor constructor);
41
+ AMULET_CORE_EXPORT void remove_null_chunk_constructor(const std::string& id);
42
+ }
43
+
44
+ AMULET_CORE_EXPORT std::shared_ptr<Chunk> get_null_chunk(std::string chunk_id);
45
+
46
+ // An object that concrete chunk classes must be registered with.
47
+ // This enables reconstructing the chunk class.
48
+ template <typename ChunkT>
49
+ class ChunkNullConstructor {
50
+ public:
51
+ ChunkNullConstructor()
52
+ {
53
+ detail::add_null_chunk_constructor(ChunkT::ChunkID, []() {
54
+ return std::make_shared<ChunkT>();
55
+ });
56
+ }
57
+ ~ChunkNullConstructor()
58
+ {
59
+ detail::remove_null_chunk_constructor(ChunkT::ChunkID);
60
+ }
61
+ };
62
+
63
+ // A utility class to simplify component serialisation and deserialisation.
64
+ template <class ChunkBaseClass, class... Components>
65
+ class ChunkComponentHelper : public ChunkBaseClass, public Components... {
66
+ public:
67
+ // Component list
68
+ std::set<std::string> get_component_ids() const override
69
+ {
70
+ std::set<std::string> component_ids;
71
+ (
72
+ [&] {
73
+ component_ids.emplace(Components::ComponentID);
74
+ }(),
75
+ ...);
76
+ return component_ids;
77
+ }
78
+ // These are public but may become private one day
79
+ // Null constructor
80
+ ChunkComponentHelper()
81
+ : Components()...
82
+ {
83
+ }
84
+ // private:
85
+ // Serialiser
86
+ SerialisedChunkComponents serialise_chunk() const override
87
+ {
88
+ SerialisedChunkComponents component_data;
89
+ (
90
+ [&] {
91
+ component_data[Components::ComponentID] = Components::serialise();
92
+ }(),
93
+ ...);
94
+ return component_data;
95
+ }
96
+ // Deserialiser
97
+ void reconstruct_chunk(SerialisedChunkComponents component_data) override
98
+ {
99
+ (
100
+ [&] {
101
+ auto node = component_data.extract(Components::ComponentID);
102
+ Components::deserialise(node ? node.mapped() : std::nullopt);
103
+ }(),
104
+ ...);
105
+ }
106
+ };
107
+
108
+ class AMULET_CORE_EXPORT_EXCEPTION ChunkLoadError : public std::runtime_error {
109
+ public:
110
+ using std::runtime_error::runtime_error;
111
+ ChunkLoadError()
112
+ : ChunkLoadError("ChunkLoadError")
113
+ {
114
+ }
115
+ };
116
+
117
+ class AMULET_CORE_EXPORT_EXCEPTION ChunkDoesNotExist : public ChunkLoadError {
118
+ public:
119
+ using ChunkLoadError::ChunkLoadError;
120
+ ChunkDoesNotExist()
121
+ : ChunkDoesNotExist("ChunkDoesNotExist")
122
+ {
123
+ }
124
+ };
125
+
126
+ } // namespace Amulet
@@ -0,0 +1,18 @@
1
+ from __future__ import annotations
2
+
3
+ from amulet.core.chunk.component.block_component import (
4
+ BlockComponent,
5
+ BlockComponentData,
6
+ )
7
+ from amulet.core.chunk.component.section_array_map import IndexArray3D, SectionArrayMap
8
+
9
+ from . import block_component, section_array_map
10
+
11
+ __all__ = [
12
+ "BlockComponent",
13
+ "BlockComponentData",
14
+ "IndexArray3D",
15
+ "SectionArrayMap",
16
+ "block_component",
17
+ "section_array_map",
18
+ ]
@@ -0,0 +1,96 @@
1
+ #pragma once
2
+
3
+ #include <cstdint>
4
+ #include <memory>
5
+ #include <optional>
6
+ #include <tuple>
7
+
8
+ #include <amulet/core/biome/biome.hpp>
9
+ #include <amulet/core/dll.hpp>
10
+ #include <amulet/core/palette/biome_palette.hpp>
11
+ #include <amulet/core/version/version.hpp>
12
+
13
+ #include "section_array_map.hpp"
14
+
15
+ namespace Amulet {
16
+
17
+ class Biome3DComponentData {
18
+ private:
19
+ std::shared_ptr<BiomePalette> _palette;
20
+ std::shared_ptr<SectionArrayMap> _sections;
21
+
22
+ public:
23
+ template <typename PaletteT, typename SectionsT>
24
+ Biome3DComponentData(
25
+ PaletteT&& palette,
26
+ SectionsT&& sections)
27
+ : _palette(
28
+ [&palette] {
29
+ if constexpr (std::is_same_v<std::shared_ptr<BiomePalette>, std::decay_t<PaletteT>>) {
30
+ return std::forward<PaletteT>(palette);
31
+ } else {
32
+ return std::make_shared<BiomePalette>(palette);
33
+ }
34
+ }())
35
+ , _sections(
36
+ [&sections] {
37
+ if constexpr (std::is_same_v<std::shared_ptr<SectionArrayMap>, std::decay_t<SectionsT>>) {
38
+ return std::forward<SectionsT>(sections);
39
+ } else {
40
+ return std::make_shared<SectionArrayMap>(sections);
41
+ }
42
+ }())
43
+ {
44
+ }
45
+
46
+ template <typename VersionRangeT>
47
+ Biome3DComponentData(
48
+ VersionRangeT&& version_range,
49
+ const SectionShape& array_shape,
50
+ const Biome& default_biome)
51
+ : Biome3DComponentData(
52
+ std::make_shared<BiomePalette>(std::forward<VersionRangeT>(version_range)),
53
+ std::make_shared<SectionArrayMap>(array_shape, static_cast<std::uint32_t>(0)))
54
+ {
55
+ _palette->biome_to_index(default_biome);
56
+ }
57
+
58
+ BiomePalette& get_palette() { return *_palette; }
59
+ std::shared_ptr<BiomePalette> get_palette_ptr() { return _palette; }
60
+ SectionArrayMap& get_sections() { return *_sections; }
61
+ std::shared_ptr<SectionArrayMap> get_sections_ptr() { return _sections; }
62
+ };
63
+
64
+ class Biome3DComponent {
65
+ private:
66
+ std::optional<std::shared_ptr<Biome3DComponentData>> _value;
67
+
68
+ protected:
69
+ // Null constructor
70
+ Biome3DComponent() = default;
71
+
72
+ // Default constructor
73
+ template <typename VersionRangeT>
74
+ void init(
75
+ VersionRangeT&& version_range,
76
+ const SectionShape& array_shape,
77
+ const Biome& default_biome)
78
+ {
79
+ _value = std::make_shared<Biome3DComponentData>(
80
+ std::forward<VersionRangeT>(version_range),
81
+ array_shape,
82
+ default_biome);
83
+ }
84
+
85
+ // Serialise the component data
86
+ AMULET_CORE_EXPORT std::optional<std::string> serialise() const;
87
+ // Deserialise the component
88
+ AMULET_CORE_EXPORT void deserialise(std::optional<std::string>);
89
+
90
+ public:
91
+ AMULET_CORE_EXPORT static const std::string ComponentID;
92
+ AMULET_CORE_EXPORT std::shared_ptr<Biome3DComponentData> get_biome();
93
+ AMULET_CORE_EXPORT void set_biome(std::shared_ptr<Biome3DComponentData> component);
94
+ };
95
+
96
+ } // namespace Amulet
@@ -0,0 +1,101 @@
1
+ #pragma once
2
+
3
+ #include <memory>
4
+ #include <optional>
5
+ #include <tuple>
6
+
7
+ #include <amulet/io/binary_reader.hpp>
8
+ #include <amulet/io/binary_writer.hpp>
9
+
10
+ #include <amulet/core/block/block.hpp>
11
+ #include <amulet/core/dll.hpp>
12
+ #include <amulet/core/palette/block_palette.hpp>
13
+ #include <amulet/core/version/version.hpp>
14
+
15
+ #include "section_array_map.hpp"
16
+
17
+ namespace Amulet {
18
+
19
+ class BlockComponentData {
20
+ private:
21
+ std::shared_ptr<BlockPalette> _palette;
22
+ std::shared_ptr<SectionArrayMap> _sections;
23
+
24
+ public:
25
+ template <typename PaletteT, typename SectionsT>
26
+ BlockComponentData(
27
+ PaletteT&& palette,
28
+ SectionsT&& sections)
29
+ : _palette(
30
+ [&palette] {
31
+ if constexpr (std::is_same_v<std::shared_ptr<BlockPalette>, std::decay_t<PaletteT>>) {
32
+ return std::forward<PaletteT>(palette);
33
+ } else {
34
+ return std::make_shared<BlockPalette>(palette);
35
+ }
36
+ }())
37
+ , _sections(
38
+ [&sections] {
39
+ if constexpr (std::is_same_v<std::shared_ptr<SectionArrayMap>, std::decay_t<SectionsT>>) {
40
+ return std::forward<SectionsT>(sections);
41
+ } else {
42
+ return std::make_shared<SectionArrayMap>(sections);
43
+ }
44
+ }())
45
+ {
46
+ }
47
+
48
+ template <typename VersionRangeT>
49
+ BlockComponentData(
50
+ VersionRangeT&& version_range,
51
+ const SectionShape& array_shape,
52
+ const BlockStack& default_block)
53
+ : BlockComponentData(
54
+ std::make_shared<BlockPalette>(std::forward<VersionRangeT>(version_range)),
55
+ std::make_shared<SectionArrayMap>(array_shape, static_cast<std::uint32_t>(0)))
56
+ {
57
+ _palette->block_stack_to_index(default_block);
58
+ }
59
+
60
+ AMULET_CORE_EXPORT void serialise(BinaryWriter&) const;
61
+ AMULET_CORE_EXPORT static BlockComponentData deserialise(BinaryReader&);
62
+
63
+ BlockPalette& get_palette() const { return *_palette; }
64
+ std::shared_ptr<BlockPalette> get_palette_ptr() const { return _palette; }
65
+ SectionArrayMap& get_sections() const { return *_sections; }
66
+ std::shared_ptr<SectionArrayMap> get_sections_ptr() const { return _sections; }
67
+ };
68
+
69
+ class BlockComponent {
70
+ private:
71
+ std::optional<std::shared_ptr<BlockComponentData>> _value;
72
+
73
+ protected:
74
+ // Null constructor
75
+ BlockComponent() = default;
76
+
77
+ // Default constructor
78
+ template <typename VersionRangeT>
79
+ void init(
80
+ VersionRangeT&& version_range,
81
+ const SectionShape& array_shape,
82
+ const BlockStack& default_block)
83
+ {
84
+ _value = std::make_shared<BlockComponentData>(
85
+ std::forward<VersionRangeT>(version_range),
86
+ array_shape,
87
+ default_block);
88
+ }
89
+
90
+ // Serialise the component data
91
+ AMULET_CORE_EXPORT std::optional<std::string> serialise() const;
92
+ // Deserialise the component
93
+ AMULET_CORE_EXPORT void deserialise(std::optional<std::string>);
94
+
95
+ public:
96
+ AMULET_CORE_EXPORT static const std::string ComponentID;
97
+ AMULET_CORE_EXPORT std::shared_ptr<BlockComponentData> get_block();
98
+ AMULET_CORE_EXPORT void set_block(std::shared_ptr<BlockComponentData> component);
99
+ };
100
+
101
+ } // namespace Amulet
@@ -0,0 +1,28 @@
1
+ from __future__ import annotations
2
+
3
+ import typing
4
+
5
+ import amulet.core.block
6
+ import amulet.core.chunk.component.section_array_map
7
+ import amulet.core.palette.block_palette
8
+ import amulet.core.version
9
+
10
+ __all__ = ["BlockComponent", "BlockComponentData"]
11
+
12
+ class BlockComponent:
13
+ ComponentID: typing.ClassVar[str] = "Amulet::BlockComponent"
14
+ block: BlockComponentData
15
+
16
+ class BlockComponentData:
17
+ def __init__(
18
+ self,
19
+ version_range: amulet.core.version.VersionRange,
20
+ array_shape: tuple[int, int, int],
21
+ default_block: amulet.core.block.BlockStack,
22
+ ) -> None: ...
23
+ @property
24
+ def palette(self) -> amulet.core.palette.block_palette.BlockPalette: ...
25
+ @property
26
+ def sections(
27
+ self,
28
+ ) -> amulet.core.chunk.component.section_array_map.SectionArrayMap: ...
@@ -0,0 +1,119 @@
1
+ #pragma once
2
+
3
+ #include <cstdint>
4
+ #include <map>
5
+ #include <memory>
6
+ #include <optional>
7
+ #include <tuple>
8
+
9
+ #include <amulet/core/block_entity/block_entity.hpp>
10
+ #include <amulet/core/dll.hpp>
11
+ #include <amulet/core/version/version.hpp>
12
+
13
+ namespace Amulet {
14
+ typedef std::tuple<std::uint16_t, std::int64_t, std::uint16_t> BlockEntityChunkCoord;
15
+ class BlockEntityComponentData : public VersionRangeContainer {
16
+ private:
17
+ std::uint16_t _x_size;
18
+ std::uint16_t _z_size;
19
+ std::map<
20
+ BlockEntityChunkCoord,
21
+ std::shared_ptr<BlockEntity>>
22
+ _block_entities;
23
+
24
+ public:
25
+ template <typename VersionRangeT>
26
+ BlockEntityComponentData(
27
+ VersionRangeT&& version_range,
28
+ std::uint16_t x_size,
29
+ std::uint16_t z_size)
30
+ : VersionRangeContainer(std::forward<VersionRangeT>(version_range))
31
+ , _x_size(x_size)
32
+ , _z_size(z_size)
33
+ , _block_entities()
34
+ {
35
+ }
36
+
37
+ AMULET_CORE_EXPORT void serialise(BinaryWriter&) const;
38
+ AMULET_CORE_EXPORT static BlockEntityComponentData deserialise(BinaryReader&);
39
+
40
+ std::uint16_t get_x_size() const { return _x_size; }
41
+ std::uint16_t get_z_size() const { return _z_size; }
42
+
43
+ const std::map<BlockEntityChunkCoord, std::shared_ptr<BlockEntity>>&
44
+ get_block_entities() const
45
+ {
46
+ return _block_entities;
47
+ }
48
+
49
+ size_t get_size() const { return _block_entities.size(); }
50
+
51
+ bool contains(
52
+ const BlockEntityChunkCoord& coord) const
53
+ {
54
+ return _block_entities.contains(coord);
55
+ }
56
+
57
+ std::shared_ptr<BlockEntity> get(
58
+ const BlockEntityChunkCoord& coord) const
59
+ {
60
+ return _block_entities.at(coord);
61
+ }
62
+
63
+ template <typename BlockEntityT>
64
+ void set(
65
+ const BlockEntityChunkCoord& coord,
66
+ BlockEntityT&& block_entity)
67
+ {
68
+ std::shared_ptr<BlockEntity> block_entity_ptr;
69
+ if constexpr (std::is_same_v<std::shared_ptr<BlockEntity>, std::decay_t<BlockEntityT>>) {
70
+ block_entity_ptr = std::forward<BlockEntityT>(block_entity);
71
+ } else {
72
+ block_entity_ptr = std::make_shared<BlockEntity>(block_entity);
73
+ }
74
+
75
+ if (
76
+ std::get<0>(coord) < 0 || std::get<2>(coord) < 0 || _x_size <= std::get<0>(coord) || _z_size <= std::get<2>(coord)) {
77
+ throw std::invalid_argument(
78
+ "Coord must be 0 <= " + std::to_string(std::get<0>(coord)) + " < " + std::to_string(_x_size) + "and 0 <= " + std::to_string(std::get<1>(coord)) + " < " + std::to_string(_z_size));
79
+ }
80
+ if (!(
81
+ get_version_range().contains(
82
+ block_entity->get_platform(),
83
+ block_entity->get_version()))) {
84
+ throw std::invalid_argument(
85
+ "BlockEntity is incompatible with VersionRange.");
86
+ }
87
+ _block_entities.insert_or_assign(coord, std::move(block_entity));
88
+ }
89
+
90
+ void del(const BlockEntityChunkCoord& coord)
91
+ {
92
+ _block_entities.erase(coord);
93
+ }
94
+ };
95
+
96
+ class BlockEntityComponent {
97
+ private:
98
+ std::optional<std::shared_ptr<BlockEntityComponentData>> _value;
99
+
100
+ protected:
101
+ // Null constructor
102
+ BlockEntityComponent() = default;
103
+ // Default constructor
104
+ AMULET_CORE_EXPORT void init(
105
+ const VersionRange& version_range,
106
+ std::uint16_t x_size,
107
+ std::uint16_t z_size);
108
+
109
+ // Serialise the component data
110
+ AMULET_CORE_EXPORT std::optional<std::string> serialise() const;
111
+ // Deserialise the component
112
+ AMULET_CORE_EXPORT void deserialise(std::optional<std::string>);
113
+
114
+ public:
115
+ AMULET_CORE_EXPORT static const std::string ComponentID;
116
+ AMULET_CORE_EXPORT std::shared_ptr<BlockEntityComponentData> get_block_entity();
117
+ AMULET_CORE_EXPORT void set_block_entity(std::shared_ptr<BlockEntityComponentData> component);
118
+ };
119
+ }
@@ -0,0 +1,129 @@
1
+ #pragma once
2
+
3
+ #include <cstdint>
4
+ #include <cstdlib>
5
+ #include <memory>
6
+ #include <span>
7
+ #include <stdexcept>
8
+ #include <tuple>
9
+ #include <type_traits>
10
+ #include <unordered_map>
11
+ #include <variant>
12
+ #include <vector>
13
+
14
+ #include <amulet/io/binary_reader.hpp>
15
+ #include <amulet/io/binary_writer.hpp>
16
+
17
+ #include <amulet/core/dll.hpp>
18
+
19
+ namespace Amulet {
20
+
21
+ typedef std::tuple<std::uint16_t, std::uint16_t, std::uint16_t> SectionShape;
22
+
23
+ class IndexArray3D {
24
+ private:
25
+ SectionShape _shape;
26
+ size_t _size;
27
+ std::uint32_t* _buffer;
28
+
29
+ public:
30
+ AMULET_CORE_EXPORT IndexArray3D(const SectionShape& shape);
31
+ AMULET_CORE_EXPORT IndexArray3D(const SectionShape& shape, std::uint32_t value);
32
+
33
+ AMULET_CORE_EXPORT IndexArray3D(const IndexArray3D& other);
34
+ AMULET_CORE_EXPORT IndexArray3D(IndexArray3D&& other) noexcept;
35
+ AMULET_CORE_EXPORT IndexArray3D& operator=(const IndexArray3D& other);
36
+ AMULET_CORE_EXPORT IndexArray3D& operator=(IndexArray3D&& other) noexcept;
37
+
38
+ AMULET_CORE_EXPORT ~IndexArray3D();
39
+
40
+ AMULET_CORE_EXPORT void serialise(BinaryWriter&) const;
41
+ AMULET_CORE_EXPORT static IndexArray3D deserialise(BinaryReader&);
42
+
43
+ const SectionShape& get_shape() const { return _shape; }
44
+ const size_t& get_size() const { return _size; }
45
+ std::uint32_t* get_buffer() const { return _buffer; }
46
+ std::span<std::uint32_t> get_span() const { return { _buffer, _size }; }
47
+ };
48
+
49
+ class SectionArrayMap {
50
+ private:
51
+ SectionShape _array_shape;
52
+ std::variant<std::uint32_t, std::shared_ptr<IndexArray3D>> _default_array;
53
+ std::unordered_map<std::int64_t, std::shared_ptr<IndexArray3D>> _arrays;
54
+
55
+ void validate_array_shape(const IndexArray3D& array)
56
+ {
57
+ if (_array_shape != array.get_shape()) {
58
+ throw std::invalid_argument("Array shape does not match stored shape.");
59
+ }
60
+ }
61
+
62
+ void validate_array_shape(
63
+ const std::variant<std::uint32_t, std::shared_ptr<IndexArray3D>>& array)
64
+ {
65
+ if (auto* arr = std::get_if<std::shared_ptr<IndexArray3D>>(&array)) {
66
+ return validate_array_shape(**arr);
67
+ }
68
+ }
69
+
70
+ public:
71
+ template <typename DefaultArrayT>
72
+ SectionArrayMap(
73
+ const SectionShape& array_shape,
74
+ DefaultArrayT&& default_array)
75
+ : _array_shape(array_shape)
76
+ , _default_array(std::forward<DefaultArrayT>(default_array))
77
+ , _arrays()
78
+ {
79
+ validate_array_shape(_default_array);
80
+ }
81
+
82
+ AMULET_CORE_EXPORT void serialise(BinaryWriter&) const;
83
+ AMULET_CORE_EXPORT static SectionArrayMap deserialise(BinaryReader&);
84
+
85
+ const SectionShape& get_array_shape() const { return _array_shape; }
86
+
87
+ std::variant<std::uint32_t, std::shared_ptr<IndexArray3D>> get_default_array() const
88
+ {
89
+ return _default_array;
90
+ }
91
+
92
+ void set_default_array(std::variant<std::uint32_t, std::shared_ptr<IndexArray3D>> default_array)
93
+ {
94
+ validate_array_shape(default_array);
95
+ _default_array = std::move(default_array);
96
+ }
97
+
98
+ const std::unordered_map<std::int64_t, std::shared_ptr<IndexArray3D>>& get_arrays() const
99
+ {
100
+ return _arrays;
101
+ }
102
+
103
+ size_t get_size() const { return _arrays.size(); }
104
+
105
+ bool contains_section(std::int64_t cy) const
106
+ {
107
+ return _arrays.contains(cy);
108
+ }
109
+
110
+ std::shared_ptr<IndexArray3D> get_section(std::int64_t cy) const
111
+ {
112
+ return _arrays.at(cy);
113
+ }
114
+
115
+ void set_section(std::int64_t cy, std::shared_ptr<IndexArray3D> section)
116
+ {
117
+ validate_array_shape(*section);
118
+ _arrays.insert_or_assign(cy, std::move(section));
119
+ }
120
+
121
+ AMULET_CORE_EXPORT void populate_section(std::int64_t cy);
122
+
123
+ void del_section(std::int64_t cy)
124
+ {
125
+ _arrays.erase(cy);
126
+ }
127
+ };
128
+
129
+ } // namespace Amulet
@@ -4,31 +4,11 @@ import collections.abc
4
4
  import types
5
5
  import typing
6
6
 
7
- import amulet.block
8
- import amulet.collections
9
- import amulet.palette.block_palette
10
- import amulet.version
11
7
  import numpy
12
8
  import numpy.typing
13
9
  import typing_extensions
14
10
 
15
- __all__ = ["BlockComponent", "BlockComponentData", "IndexArray3D", "SectionArrayMap"]
16
-
17
- class BlockComponent:
18
- ComponentID: typing.ClassVar[str] = "Amulet::BlockComponent"
19
- block: BlockComponentData
20
-
21
- class BlockComponentData:
22
- def __init__(
23
- self,
24
- version_range: amulet.version.VersionRange,
25
- array_shape: tuple[int, int, int],
26
- default_block: amulet.block.BlockStack,
27
- ) -> None: ...
28
- @property
29
- def palette(self) -> amulet.palette.block_palette.BlockPalette: ...
30
- @property
31
- def sections(self) -> SectionArrayMap: ...
11
+ __all__ = ["IndexArray3D", "SectionArrayMap"]
32
12
 
33
13
  class IndexArray3D:
34
14
  """
@@ -63,13 +43,13 @@ class SectionArrayMap:
63
43
  array_shape: tuple[int, int, int],
64
44
  default_array: int | IndexArray3D | typing_extensions.Buffer,
65
45
  ) -> None: ...
66
- def __iter__(self) -> amulet.collections.Iterator: ...
46
+ def __iter__(self) -> collections.abc.Iterator[int]: ...
67
47
  def __len__(self) -> int: ...
68
48
  def __setitem__(
69
49
  self, arg0: int, arg1: IndexArray3D | typing_extensions.Buffer
70
50
  ) -> None: ...
71
51
  def get(
72
- self, arg0: int, arg1: numpy.typing.NDArray[numpy.uint32] | None
52
+ self, key: int, default: numpy.typing.NDArray[numpy.uint32] | None = None
73
53
  ) -> numpy.typing.NDArray[numpy.uint32] | None: ...
74
54
  def items(
75
55
  self,
@@ -83,7 +63,7 @@ class SectionArrayMap:
83
63
  def setdefault(
84
64
  self, arg0: int, arg1: numpy.typing.NDArray[numpy.uint32] | None
85
65
  ) -> numpy.typing.NDArray[numpy.uint32] | None: ...
86
- def update(self, other: typing.Any = (), **kwargs) -> None: ...
66
+ def update(self, other: typing.Any = (), **kwargs: typing.Any) -> None: ...
87
67
  def values(
88
68
  self,
89
69
  ) -> collections.abc.ValuesView[numpy.typing.NDArray[numpy.uint32]]: ...
amulet/core/dll.hpp ADDED
@@ -0,0 +1,21 @@
1
+ #pragma once
2
+
3
+ #ifndef AMULET_CORE_EXPORT
4
+ #if defined(WIN32) || defined(_WIN32)
5
+ #ifdef ExportAmuletCore
6
+ #define AMULET_CORE_EXPORT __declspec(dllexport)
7
+ #else
8
+ #define AMULET_CORE_EXPORT __declspec(dllimport)
9
+ #endif
10
+ #else
11
+ #define AMULET_CORE_EXPORT
12
+ #endif
13
+ #endif
14
+
15
+ #if !defined(AMULET_CORE_EXPORT_EXCEPTION)
16
+ #if defined(_LIBCPP_EXCEPTION)
17
+ #define AMULET_CORE_EXPORT_EXCEPTION __attribute__((visibility("default")))
18
+ #else
19
+ #define AMULET_CORE_EXPORT_EXCEPTION
20
+ #endif
21
+ #endif