amulet-core 2.0a8__cp312-cp312-win_amd64.whl → 2.0.1.0.1297307203.19.43.34808.0a0__cp312-cp312-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.cp312-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.0a0.dist-info}/METADATA +25 -20
  40. amulet_core-2.0.1.0.1297307203.19.43.34808.0a0.dist-info/RECORD +45 -0
  41. {amulet_core-2.0a8.dist-info → amulet_core-2.0.1.0.1297307203.19.43.34808.0a0.dist-info}/WHEEL +1 -1
  42. amulet_core-2.0.1.0.1297307203.19.43.34808.0a0.dist-info/entry_points.txt +2 -0
  43. amulet/__init__.cp312-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.0a0.dist-info}/top_level.txt +0 -0
amulet/block.py.cpp DELETED
@@ -1,377 +0,0 @@
1
- #include <span>
2
- #include <memory>
3
-
4
- #include <pybind11/pybind11.h>
5
- #include <pybind11/stl.h>
6
- #include <pybind11/operators.h>
7
- #include <pybind11/typing.h>
8
-
9
- #include <amulet/collections/sequence.py.hpp>
10
- #include <amulet/collections/eq.py.hpp>
11
- #include <amulet/pybind11/types.hpp>
12
- #include <amulet/block.hpp>
13
-
14
- namespace py = pybind11;
15
-
16
- void init_block(py::module m_parent) {
17
- auto m = m_parent.def_submodule("block");
18
- py::options options;
19
-
20
- py::object PySorted = py::module::import("builtins").attr("sorted");
21
-
22
- // Required for docstrings
23
- py::object amulet_nbt = py::module::import("amulet_nbt");
24
- py::object ByteTag = amulet_nbt.attr("ByteTag");
25
- py::object ShortTag = amulet_nbt.attr("ShortTag");
26
- py::object IntTag = amulet_nbt.attr("IntTag");
27
- py::object LongTag = amulet_nbt.attr("LongTag");
28
- py::object StringTag = amulet_nbt.attr("StringTag");
29
-
30
- m.attr("PropertyValueType") = ByteTag | ShortTag | IntTag | LongTag | StringTag;
31
-
32
- py::class_<Amulet::Block, Amulet::PlatformVersionContainer, std::shared_ptr<Amulet::Block>> Block(m, "Block",
33
- "A class to manage the state of a block.\n"
34
- "\n"
35
- "It is an immutable object that contains the platform, version, namespace, base name and properties.\n"
36
- "\n"
37
- "Here's a few examples on how create a Block object:\n"
38
- "\n"
39
- ">>> # Create a stone block for Java 1.20.2\n"
40
- ">>> stone = Block(\"java\", VersionNumber(3578), \"minecraft\", \"stone\")\n"
41
- ">>> # The Java block version number is the Java data version\n"
42
- "\n"
43
- ">>> # Create a stone block for Bedrock \n"
44
- ">>> stone = Block(\"bedrock\", VersionNumber(1, 21, 0, 3), \"minecraft\", \"stone\")\n"
45
- ">>> # The Bedrock block version number is the value stored as an int with the block data.\n"
46
- "\n"
47
- ">>> # Create a Java water block with the level property\n"
48
- ">>> water = Block(\n"
49
- ">>> \"java\", VersionNumber(3578),\n"
50
- ">>> \"minecraft\", # the namespace\n"
51
- ">>> \"water\", # the base name\n"
52
- ">>> { # A dictionary of properties.\n"
53
- ">>> # Keys must be strings and values must be a numerical or string NBT type.\n"
54
- ">>> \"level\": StringTag(\"0\") # define a property `level` with a string value `0`\n"
55
- ">>> }\n"
56
- ">>> )"
57
- );
58
- Block.def(
59
- py::init<
60
- const Amulet::PlatformType&,
61
- std::shared_ptr<Amulet::VersionNumber>,
62
- const std::string&,
63
- const std::string&,
64
- const std::map<std::string, Amulet::PropertyValueType>&
65
- >(),
66
- py::arg("platform"),
67
- py::arg("version"),
68
- py::arg("namespace"),
69
- py::arg("base_name"),
70
- py::arg("properties") = py::dict()
71
- );
72
- Block.def_property_readonly(
73
- "namespaced_name",
74
- [](const Amulet::Block& self) {
75
- return self.get_namespace() + ":" + self.get_base_name();
76
- },
77
- py::doc(
78
- "The namespace:base_name of the blockstate represented by the :class:`Block` object.\n"
79
- "\n"
80
- ">>> block: Block\n"
81
- ">>> block.namespaced_name\n"
82
- "\n"
83
- ":return: The namespace:base_name of the blockstate"
84
- )
85
- );
86
- Block.def_property_readonly(
87
- "namespace",
88
- &Amulet::Block::get_namespace,
89
- py::doc(
90
- "The namespace of the blockstate represented by the :class:`Block` object.\n"
91
- "\n"
92
- ">>> block: Block\n"
93
- ">>> water.namespace\n"
94
- "\n"
95
- ":return: The namespace of the blockstate"
96
- )
97
- );
98
- Block.def_property_readonly(
99
- "base_name",
100
- &Amulet::Block::get_base_name,
101
- py::doc(
102
- "The base name of the blockstate represented by the :class:`Block` object.\n"
103
- "\n"
104
- ">>> block: Block\n"
105
- ">>> block.base_name\n"
106
- "\n"
107
- ":return: The base name of the blockstate"
108
- )
109
- );
110
- Block.def_property_readonly(
111
- "properties",
112
- &Amulet::Block::get_properties,
113
- py::doc(
114
- "The properties of the blockstate represented by the :class:`Block` object as a dictionary.\n"
115
- ">>> block: Block\n"
116
- ">>> block.properties\n"
117
- "\n"
118
- ":return: A mapping of the properties of the blockstate"
119
- )
120
- );
121
- Block.def(
122
- "__repr__",
123
- [](const Amulet::Block& self){
124
- return "Block(" +
125
- py::repr(py::cast(self.get_platform())).cast<std::string>() + ", " +
126
- py::repr(py::cast(self.get_version())).cast<std::string>() + ", " +
127
- py::repr(py::cast(self.get_namespace())).cast<std::string>() + ", " +
128
- py::repr(py::cast(self.get_base_name())).cast<std::string>() + ", " +
129
- py::repr(py::cast(self.get_properties())).cast<std::string>() +
130
- ")";
131
- }
132
- );
133
- Block.def(
134
- "__hash__",
135
- [PySorted](const Amulet::Block& self) {
136
- return py::hash(
137
- py::make_tuple(
138
- py::cast(self.get_platform()),
139
- py::cast(self.get_version()),
140
- py::cast(self.get_namespace()),
141
- py::cast(self.get_base_name()),
142
- py::tuple(PySorted(py::cast(self.get_properties()).attr("items")()))
143
- )
144
- );
145
- }
146
- );
147
- Block.def(
148
- py::pickle(
149
- [](const Amulet::Block& self) -> py::bytes {
150
- return py::bytes(Amulet::serialise(self));
151
- },
152
- [](py::bytes state){
153
- return Amulet::deserialise<Amulet::Block>(state.cast<std::string>());
154
- }
155
- )
156
- );
157
-
158
- Eq(Block);
159
- Eq_default(Block);
160
- Block.def(py::self > py::self);
161
- Block.def(py::self < py::self);
162
- Block.def(py::self >= py::self);
163
- Block.def(py::self <= py::self);
164
-
165
- Block.def_static(
166
- "from_java_blockstate",
167
- &Amulet::Block::from_java_blockstate,
168
- py::doc(
169
- "Parse a Java format blockstate where values are all strings and populate a :class:`Block` class with the data.\n"
170
- "\n"
171
- ">>> stone = Block.from_java_blockstate(\"minecraft:stone\")\n"
172
- ">>> water = Block.from_java_blockstate(\"minecraft:water[level=0]\")\n"
173
- "\n"
174
- ":param platform: The platform the block is defined in.\n"
175
- ":param version: The version the block is defined in.\n"
176
- ":param blockstate: The Java blockstate string to parse.\n"
177
- ":return: A Block instance containing the state."
178
- ),
179
- py::arg("platform"),
180
- py::arg("version"),
181
- py::arg("blockstate")
182
- );
183
- Block.def_static(
184
- "from_bedrock_blockstate",
185
- &Amulet::Block::from_bedrock_blockstate,
186
- py::doc(
187
- "Parse a Bedrock format blockstate where values are all strings and populate a :class:`Block` class with the data.\n"
188
- "\n"
189
- ">>> stone = Block.from_bedrock_blockstate(\"minecraft:stone\")\n"
190
- ">>> water = Block.from_bedrock_blockstate(\"minecraft:water[\"liquid_depth\"=0]\")\n"
191
- "\n"
192
- ":param platform: The platform the block is defined in.\n"
193
- ":param version: The version the block is defined in.\n"
194
- ":param blockstate: The Bedrock blockstate string to parse.\n"
195
- ":return: A Block instance containing the state."
196
- ),
197
- py::arg("platform"),
198
- py::arg("version"),
199
- py::arg("blockstate")
200
- );
201
-
202
- Block.def_property_readonly(
203
- "java_blockstate",
204
- &Amulet::Block::java_blockstate,
205
- py::doc(
206
- "The Java blockstate string of this :class:`Block` object.\n"
207
- "Note this will only contain properties with StringTag values.\n"
208
- "\n"
209
- ">>> stone = Block(\"java\", VersionNumber(3578), \"minecraft\", \"stone\")\n"
210
- ">>> stone.java_blockstate\n"
211
- "minecraft:stone\n"
212
- ">>> water = Block(\"java\", VersionNumber(3578), \"minecraft\", \"water\", {\"level\": StringTag(\"0\")})\n"
213
- ">>> water.java_blockstate\n"
214
- "minecraft:water[level=0]\n"
215
- "\n"
216
- ":return: The blockstate string"
217
- )
218
- );
219
- Block.def_property_readonly(
220
- "bedrock_blockstate",
221
- &Amulet::Block::bedrock_blockstate,
222
- py::doc(
223
- "The Bedrock blockstate string of this :class:`Block` object.\n"
224
- "Converts the property values to the SNBT format to preserve type.\n"
225
- "\n"
226
- ">>> bell = Block(\n"
227
- ">>> \"java\", VersionNumber(3578),\n"
228
- ">>> \"minecraft\",\n"
229
- ">>> \"bell\",\n"
230
- ">>> {\n"
231
- ">>> \"attachment\":StringTag(\"standing\"),\n"
232
- ">>> \"direction\":IntTag(0),\n"
233
- ">>> \"toggle_bit\":ByteTag(0)\n"
234
- ">>> }\n"
235
- ">>> )\n"
236
- ">>> bell.bedrock_blockstate\n"
237
- "minecraft:bell[\"attachment\"=\"standing\",\"direction\"=0,\"toggle_bit\"=false]\n"
238
- "\n"
239
- ":return: The SNBT blockstate string"
240
- )
241
- );
242
-
243
- py::class_<Amulet::BlockStack, std::shared_ptr<Amulet::BlockStack>> BlockStack(m, "BlockStack",
244
- "A stack of block objects.\n"
245
- "\n"
246
- "Java 1.13 added the concept of waterlogging blocks whereby some blocks have a `waterlogged` property.\n"
247
- "Bedrock achieved the same behaviour by added a layering system which allows the second block to be any block.\n"
248
- "\n"
249
- "Amulet supports both implementations with a stack of one or more block objects similar to how Bedrock handles it.\n"
250
- "Amulet places no restrictions on which blocks can be extra blocks.\n"
251
- "Extra block may be discarded if the format does not support them.\n"
252
- "\n"
253
- "Create a waterlogged stone block.\n"
254
- ">>> waterlogged_stone = BlockStack(\n"
255
- ">>> Block(\"java\", VersionNumber(3578), \"minecraft\", \"stone\"),\n"
256
- ">>> Block(\"java\", VersionNumber(3578), \"minecraft\", \"water\", {\"level\": StringTag(\"0\")})\n"
257
- ">>> )\n"
258
- "\n"
259
- "Get a block at an index\n"
260
- ">>> stone = waterlogged_stone[0]\n"
261
- ">>> water = waterlogged_stone[1]\n"
262
- "\n"
263
- "Get the blocks as a list\n"
264
- ">>> blocks = list(waterlogged_stone)"
265
- );
266
- options.disable_function_signatures();
267
- BlockStack.def(
268
- py::init(
269
- [](std::shared_ptr<Amulet::Block> block, py::args py_extra_blocks){
270
- std::vector<std::shared_ptr<Amulet::Block>> blocks;
271
- blocks.push_back(block);
272
- auto extra_blocks = py_extra_blocks.cast<std::vector<std::shared_ptr<Amulet::Block>>>();
273
- blocks.insert(blocks.end(), extra_blocks.begin(), extra_blocks.end());
274
- return Amulet::BlockStack(blocks);
275
- }
276
- ),
277
- py::doc("__init__(self, block: amulet.block.Block, *extra_blocks: amulet.block.Block) -> None")
278
- );
279
- options.enable_function_signatures();
280
-
281
- BlockStack.def(
282
- "__repr__",
283
- [](const Amulet::BlockStack& self) {
284
- const auto& blocks = self.get_blocks();
285
- std::string repr = "BlockStack(";
286
- for (size_t i = 0; i < blocks.size(); i++) {
287
- if (i != 0) {
288
- repr += ", ";
289
- }
290
- repr += py::repr(py::cast(blocks[i])).cast<std::string>();
291
- }
292
- repr += ")";
293
- return repr;
294
- }
295
- );
296
-
297
- BlockStack.def(
298
- "__len__",
299
- &Amulet::BlockStack::size
300
- );
301
-
302
- BlockStack.def(
303
- "__getitem__",
304
- [](const Amulet::BlockStack& self, Py_ssize_t index) {
305
- if (index < 0) {
306
- index += self.size();
307
- if (index < 0) {
308
- throw py::index_error("");
309
- }
310
- }
311
- if (index >= self.size()) {
312
- throw py::index_error("");
313
- }
314
- return self[index];
315
- }
316
- );
317
- BlockStack.def(
318
- "__hash__",
319
- [](const Amulet::BlockStack& self) {
320
- return py::hash(
321
- py::tuple(py::cast(self.get_blocks()))
322
- );
323
- }
324
- );
325
-
326
- Amulet::collections::Sequence<Amulet::Block>(BlockStack);
327
-
328
- Eq(BlockStack);
329
- Eq_default(BlockStack);
330
-
331
- BlockStack.def(py::self > py::self);
332
- BlockStack.def(py::self < py::self);
333
- BlockStack.def(py::self >= py::self);
334
- BlockStack.def(py::self <= py::self);
335
-
336
- BlockStack.def_property_readonly(
337
- "base_block",
338
- [](const Amulet::BlockStack& self) -> std::shared_ptr<Amulet::Block> {
339
- return self.get_blocks()[0];
340
- },
341
- py::doc(
342
- "The first block in the stack.\n"
343
- "\n"
344
- ">>> waterlogged_stone = BlockStack(\n"
345
- ">>> Block(\"java\", VersionNumber(3578), \"minecraft\", \"stone\"),\n"
346
- ">>> Block(\"java\", VersionNumber(3578), \"minecraft\", \"water\", {\"level\": StringTag(\"0\")})\n"
347
- ">>> )\n"
348
- ">>> waterlogged_stone.base_block\n"
349
- "Block(\"java\", VersionNumber(3578), \"minecraft\", \"stone\")\n"
350
- "\n"
351
- ":return: A Block object"
352
- )
353
- );
354
- BlockStack.def_property_readonly(
355
- "extra_blocks",
356
- [](const Amulet::BlockStack& self) -> py::tuple {
357
- const auto& blocks = self.get_blocks();
358
- py::tuple py_blocks(blocks.size() - 1);
359
- for (size_t i = 1; i < blocks.size(); i++) {
360
- py_blocks[i - 1] = py::cast(blocks[i]);
361
- }
362
- return py_blocks;
363
- },
364
- py::doc(
365
- "The extra blocks in the stack.\n"
366
- "\n"
367
- ">>> waterlogged_stone = BlockStack(\n"
368
- ">>> Block(\"java\", VersionNumber(3578), \"minecraft\", \"stone\"),\n"
369
- ">>> Block(\"java\", VersionNumber(3578), \"minecraft\", \"water\", {\"level\": StringTag(\"0\")})\n"
370
- ">>> )\n"
371
- ">>> waterlogged_stone.extra_blocks\n"
372
- "(Block(\"java\", VersionNumber(3578), \"minecraft\", \"water\", {\"level\": StringTag(\"0\")}),)\n"
373
- "\n"
374
- ":return: A tuple of :class:`Block` objects"
375
- )
376
- );
377
- }
amulet/block_entity.cpp DELETED
@@ -1,12 +0,0 @@
1
- #include <amulet/block_entity.hpp>
2
-
3
- namespace Amulet {
4
-
5
- void BlockEntity::serialise(BinaryWriter&) const {
6
- throw std::runtime_error("NotImplemented");
7
- }
8
- std::shared_ptr<BlockEntity> BlockEntity::deserialise(BinaryReader&) {
9
- throw std::runtime_error("NotImplemented");
10
- }
11
-
12
- }
amulet/block_entity.hpp DELETED
@@ -1,56 +0,0 @@
1
- #pragma once
2
-
3
- #include <map>
4
- #include <variant>
5
- #include <string>
6
-
7
- #include <amulet/io/binary_reader.hpp>
8
- #include <amulet/io/binary_writer.hpp>
9
- #include <amulet/version.hpp>
10
- #include <amulet_nbt/tag/named_tag.hpp>
11
- #include <amulet_nbt/tag/eq.hpp>
12
-
13
-
14
- namespace Amulet {
15
- class BlockEntity: public PlatformVersionContainer {
16
- private:
17
- std::string _namespace;
18
- std::string _base_name;
19
- std::shared_ptr<AmuletNBT::NamedTag> _nbt;
20
-
21
- public:
22
- const std::string& get_namespace() const { return _namespace; }
23
- void set_namespace(const std::string& namespace_) { _namespace = namespace_; }
24
-
25
- const std::string& get_base_name() const { return _base_name; }
26
- void set_base_name(const std::string& base_name) { _base_name = base_name; }
27
-
28
- std::shared_ptr<AmuletNBT::NamedTag> get_nbt() const { return _nbt; }
29
- void set_nbt(std::shared_ptr<AmuletNBT::NamedTag> nbt) { _nbt = nbt; }
30
-
31
- BlockEntity(
32
- const PlatformType& platform,
33
- std::shared_ptr<VersionNumber> version,
34
- const std::string& namespace_,
35
- const std::string& base_name,
36
- std::shared_ptr<AmuletNBT::NamedTag> nbt
37
- ):
38
- PlatformVersionContainer(platform, version),
39
- _namespace(namespace_),
40
- _base_name(base_name),
41
- _nbt(nbt)
42
- {}
43
-
44
- void serialise(BinaryWriter&) const;
45
- static std::shared_ptr<BlockEntity> deserialise(BinaryReader&);
46
-
47
- bool operator==(const BlockEntity& other) const {
48
- return (
49
- PlatformVersionContainer::operator==(other) &&
50
- _namespace == other._namespace &&
51
- _base_name == other._base_name &&
52
- AmuletNBT::NBTTag_eq(*_nbt, *other._nbt)
53
- );
54
- };
55
- };
56
- }
@@ -1,115 +0,0 @@
1
- #include <memory>
2
-
3
- #include <pybind11/pybind11.h>
4
- #include <pybind11/stl.h>
5
- #include <pybind11/operators.h>
6
- #include <pybind11/typing.h>
7
-
8
- #include <amulet/collections/eq.py.hpp>
9
- #include <amulet/collections/hash.py.hpp>
10
- #include <amulet_nbt/tag/named_tag.hpp>
11
- #include <amulet/version.hpp>
12
- #include <amulet/block_entity.hpp>
13
-
14
-
15
- namespace py = pybind11;
16
-
17
- void init_block_entity(py::module m_parent) {
18
- auto m = m_parent.def_submodule("block_entity");
19
-
20
- py::class_<Amulet::BlockEntity, Amulet::PlatformVersionContainer, std::shared_ptr<Amulet::BlockEntity>> BlockEntity(m, "BlockEntity",
21
- "A class to contain all the data to define a BlockEntity."
22
- );
23
- BlockEntity.def(
24
- py::init<
25
- const Amulet::PlatformType&,
26
- std::shared_ptr<Amulet::VersionNumber>,
27
- const std::string&,
28
- const std::string&,
29
- std::shared_ptr<AmuletNBT::NamedTag>
30
- >(),
31
- py::arg("platform"),
32
- py::arg("version"),
33
- py::arg("namespace"),
34
- py::arg("base_name"),
35
- py::arg("nbt")
36
- );
37
- BlockEntity.def_property_readonly(
38
- "namespaced_name",
39
- [](const Amulet::BlockEntity& self) {
40
- return self.get_namespace() + ":" + self.get_base_name();
41
- },
42
- py::doc(
43
- "The namespace:base_name of the block entity represented by the :class:`BlockEntity` object.\n"
44
- "\n"
45
- ">>> block_entity: BlockEntity\n"
46
- ">>> block_entity.namespaced_name\n"
47
- "\n"
48
- ":return: The namespace:base_name of the block entity"
49
- )
50
- );
51
- BlockEntity.def_property(
52
- "namespace",
53
- &Amulet::BlockEntity::get_namespace,
54
- &Amulet::BlockEntity::set_namespace,
55
- py::doc(
56
- "The namespace of the block entity represented by the :class:`BlockEntity` object.\n"
57
- "\n"
58
- ">>> block_entity: BlockEntity\n"
59
- ">>> block_entity.namespace\n"
60
- "\n"
61
- ":return: The namespace of the block entity"
62
- )
63
- );
64
- BlockEntity.def_property(
65
- "base_name",
66
- &Amulet::BlockEntity::get_base_name,
67
- &Amulet::BlockEntity::set_base_name,
68
- py::doc(
69
- "The base name of the block entity represented by the :class:`BlockEntity` object.\n"
70
- "\n"
71
- ">>> block_entity: BlockEntity\n"
72
- ">>> block_entity.base_name\n"
73
- "\n"
74
- ":return: The base name of the block entity"
75
- )
76
- );
77
- BlockEntity.def_property(
78
- "nbt",
79
- &Amulet::BlockEntity::get_nbt,
80
- &Amulet::BlockEntity::set_nbt,
81
- py::doc(
82
- "The nbt data for the block entity.\n"
83
- ">>> block_entity: BlockEntity\n"
84
- ">>> block_entity.nbt\n"
85
- "\n"
86
- ":return: The NamedTag of the block entity"
87
- )
88
- );
89
- BlockEntity.def(
90
- "__repr__",
91
- [](const Amulet::BlockEntity& self){
92
- return "Block(" +
93
- py::repr(py::cast(self.get_platform())).cast<std::string>() + ", " +
94
- py::repr(py::cast(self.get_version())).cast<std::string>() + ", " +
95
- py::repr(py::cast(self.get_namespace())).cast<std::string>() + ", " +
96
- py::repr(py::cast(self.get_base_name())).cast<std::string>() + ", " +
97
- py::repr(py::cast(self.get_nbt())).cast<std::string>() +
98
- ")";
99
- }
100
- );
101
- BlockEntity.def(
102
- py::pickle(
103
- [](const Amulet::BlockEntity& self) -> py::bytes {
104
- return py::bytes(Amulet::serialise(self));
105
- },
106
- [](py::bytes state){
107
- return Amulet::deserialise<Amulet::BlockEntity>(state.cast<std::string>());
108
- }
109
- )
110
- );
111
-
112
- Eq(BlockEntity);
113
- Eq_default(BlockEntity);
114
- hash_default(BlockEntity);
115
- }
amulet/chunk.cpp DELETED
@@ -1,16 +0,0 @@
1
- #include <string>
2
- #include <unordered_map>
3
- #include <optional>
4
- #include <functional>
5
- #include <memory>
6
-
7
- #include <amulet/chunk.hpp>
8
-
9
- namespace Amulet {
10
- namespace detail {
11
- std::unordered_map<std::string, std::function<std::shared_ptr<Chunk>()>> chunk_constructors;
12
- }
13
- std::shared_ptr<Chunk> get_null_chunk(std::string chunk_id) {
14
- return detail::chunk_constructors.at(chunk_id)();
15
- }
16
- }
amulet/chunk.hpp DELETED
@@ -1,100 +0,0 @@
1
- #pragma once
2
-
3
- #include <string>
4
- #include <unordered_map>
5
- #include <optional>
6
- #include <functional>
7
- #include <memory>
8
- #include <stdexcept>
9
-
10
- // Requirements:
11
- // Split chunk data into components that are orthogonal to each other.
12
- // create a chunk with all components default initialised.
13
- // reconstruct a chunk from a subset of its components.
14
- // reconstruct a chunk with all components.
15
- // query if a chunk has a component. (isinstance/is_base_of/dynamic_cast or has_component)
16
- // get a component. (method/property or get_component)
17
- // set and validate a component. (method/property or set_component)
18
- // serialise loaded components.
19
-
20
- namespace Amulet {
21
- typedef std::unordered_map<std::string, std::optional<std::string>> SerialisedComponents;
22
-
23
- // The abstract chunk class
24
- class Chunk {
25
- public:
26
- virtual ~Chunk() {}
27
- virtual std::string get_chunk_id() const = 0;
28
- virtual std::vector<std::string> get_component_ids() const = 0;
29
- //private:
30
- // These are public but may become private one day
31
- virtual SerialisedComponents serialise_chunk() const = 0;
32
- virtual void reconstruct_chunk(SerialisedComponents) = 0;
33
- };
34
-
35
- namespace detail {
36
- extern std::unordered_map<std::string, std::function<std::shared_ptr<Chunk>()>> chunk_constructors;
37
- }
38
-
39
- std::shared_ptr<Chunk> get_null_chunk(std::string chunk_id);
40
-
41
- // An object that concrete chunk classes must be registered with.
42
- // This enables reconstructing the chunk class.
43
- template <typename ChunkT>
44
- class ChunkNullConstructor {
45
- public:
46
- ChunkNullConstructor() {
47
- if (detail::chunk_constructors.contains(ChunkT::ChunkID)) {
48
- throw std::runtime_error("A chunk class has already been registered with ID " + ChunkT::ChunkID);
49
- }
50
- detail::chunk_constructors[ChunkT::ChunkID] = []() {
51
- return std::make_shared<ChunkT>();
52
- };
53
- };
54
- ~ChunkNullConstructor() {
55
- detail::chunk_constructors.erase(ChunkT::ChunkID);
56
- };
57
- };
58
-
59
- // A utility class to simplify component serialisation and deserialisation.
60
- template <class ChunkBaseClass, class ... Components>
61
- class ChunkComponentHelper: public ChunkBaseClass, public Components... {
62
- public:
63
- // Component list
64
- std::vector<std::string> get_component_ids() const override {
65
- std::vector<std::string> component_ids;
66
- (
67
- [&]{
68
- component_ids.push_back(Components::ComponentID);
69
- }(),
70
- ...
71
- );
72
- return component_ids;
73
- }
74
- // These are public but may become private one day
75
- // Null constructor
76
- ChunkComponentHelper() : Components()... {}
77
- //private:
78
- // Serialiser
79
- SerialisedComponents serialise_chunk() const override {
80
- SerialisedComponents component_data;
81
- (
82
- [&]{
83
- component_data[Components::ComponentID] = Components::serialise();
84
- }(),
85
- ...
86
- );
87
- return component_data;
88
- }
89
- // Deserialiser
90
- void reconstruct_chunk(SerialisedComponents component_data) override {
91
- (
92
- [&]{
93
- auto node = component_data.extract(Components::ComponentID);
94
- Components::deserialise(node ? node.mapped() : std::nullopt);
95
- }(),
96
- ...
97
- );
98
- }
99
- };
100
- }