amulet-core 2.0a6__cp312-cp312-win_amd64.whl → 2.0a7__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 (201) hide show
  1. amulet/__init__.cp312-win_amd64.pyd +0 -0
  2. amulet/__init__.py.cpp +4 -0
  3. amulet/__init__.pyi +0 -2
  4. amulet/_init.py +0 -2
  5. amulet/_version.py +3 -3
  6. amulet/biome.pyi +0 -2
  7. amulet/block.pyi +0 -2
  8. amulet/block_entity.pyi +0 -2
  9. amulet/chunk.pyi +0 -2
  10. amulet/chunk_components.pyi +20 -18
  11. amulet/collections/eq.py.hpp +1 -1
  12. amulet/collections/mapping.py.hpp +18 -11
  13. amulet/collections/mutable_mapping.py.hpp +17 -6
  14. amulet/collections/sequence.py.hpp +5 -6
  15. amulet/collections.pyi +8 -5
  16. amulet/entity.py +22 -20
  17. amulet/game/translate/_functions/_code_functions/_text.py +2 -2
  18. amulet/game/translate/_functions/abc.py +10 -3
  19. amulet/img/__init__.py +10 -0
  20. amulet/img/missing_no.png +0 -0
  21. amulet/img/missing_pack.png +0 -0
  22. amulet/level/__init__.pyi +2 -6
  23. amulet/level/abc/_level/_creatable_level.py +1 -2
  24. amulet/level/abc/_level/_level.py +1 -5
  25. amulet/level/java/__init__.pyi +0 -5
  26. amulet/level/java/_raw/__init__.pyi +0 -4
  27. amulet/level/java/_raw/java_chunk_decode.cpp +2 -4
  28. amulet/level/java/long_array.pyi +2 -1
  29. amulet/mesh/block/__init__.py +1 -0
  30. amulet/mesh/block/block_mesh.py +369 -0
  31. amulet/mesh/block/cube.py +149 -0
  32. amulet/mesh/block/missing_block.py +20 -0
  33. amulet/mesh/util.py +17 -0
  34. amulet/player.py +4 -6
  35. amulet/pybind11/collections.hpp +80 -38
  36. amulet/pybind11/numpy.hpp +26 -0
  37. amulet/pybind11/py_module.hpp +16 -51
  38. amulet/pybind11/type_hints.hpp +51 -0
  39. amulet/pybind11/types.hpp +14 -6
  40. amulet/pybind11/typing.hpp +7 -0
  41. amulet/resource_pack/__init__.py +62 -0
  42. amulet/resource_pack/abc/__init__.py +2 -0
  43. amulet/resource_pack/abc/resource_pack.py +38 -0
  44. amulet/resource_pack/abc/resource_pack_manager.py +87 -0
  45. amulet/resource_pack/bedrock/__init__.py +2 -0
  46. amulet/resource_pack/bedrock/bedrock_vanilla_fix/pack_icon.png +0 -0
  47. amulet/resource_pack/bedrock/bedrock_vanilla_fix/textures/blocks/grass_carried.png +0 -0
  48. amulet/resource_pack/bedrock/bedrock_vanilla_fix/textures/blocks/grass_side_carried.png +0 -0
  49. amulet/resource_pack/bedrock/bedrock_vanilla_fix/textures/blocks/water.png +0 -0
  50. amulet/resource_pack/bedrock/blockshapes/__init__.py +31 -0
  51. amulet/resource_pack/bedrock/blockshapes/air.py +35 -0
  52. amulet/resource_pack/bedrock/blockshapes/base_blockshape.py +29 -0
  53. amulet/resource_pack/bedrock/blockshapes/bubble_column.py +29 -0
  54. amulet/resource_pack/bedrock/blockshapes/cake.py +46 -0
  55. amulet/resource_pack/bedrock/blockshapes/chest.py +54 -0
  56. amulet/resource_pack/bedrock/blockshapes/comparator.py +51 -0
  57. amulet/resource_pack/bedrock/blockshapes/cross_texture.py +186 -0
  58. amulet/resource_pack/bedrock/blockshapes/cross_texture0.py +17 -0
  59. amulet/resource_pack/bedrock/blockshapes/cross_texture_green.py +16 -0
  60. amulet/resource_pack/bedrock/blockshapes/cube.py +38 -0
  61. amulet/resource_pack/bedrock/blockshapes/default.py +14 -0
  62. amulet/resource_pack/bedrock/blockshapes/door.py +38 -0
  63. amulet/resource_pack/bedrock/blockshapes/door1.py +14 -0
  64. amulet/resource_pack/bedrock/blockshapes/door2.py +14 -0
  65. amulet/resource_pack/bedrock/blockshapes/door3.py +14 -0
  66. amulet/resource_pack/bedrock/blockshapes/door4.py +14 -0
  67. amulet/resource_pack/bedrock/blockshapes/door5.py +14 -0
  68. amulet/resource_pack/bedrock/blockshapes/door6.py +14 -0
  69. amulet/resource_pack/bedrock/blockshapes/double_plant.py +40 -0
  70. amulet/resource_pack/bedrock/blockshapes/enchanting_table.py +22 -0
  71. amulet/resource_pack/bedrock/blockshapes/farmland.py +22 -0
  72. amulet/resource_pack/bedrock/blockshapes/fence.py +22 -0
  73. amulet/resource_pack/bedrock/blockshapes/flat.py +55 -0
  74. amulet/resource_pack/bedrock/blockshapes/flat_wall.py +55 -0
  75. amulet/resource_pack/bedrock/blockshapes/furnace.py +44 -0
  76. amulet/resource_pack/bedrock/blockshapes/furnace_lit.py +14 -0
  77. amulet/resource_pack/bedrock/blockshapes/green_cube.py +39 -0
  78. amulet/resource_pack/bedrock/blockshapes/ladder.py +36 -0
  79. amulet/resource_pack/bedrock/blockshapes/lilypad.py +14 -0
  80. amulet/resource_pack/bedrock/blockshapes/partial_block.py +57 -0
  81. amulet/resource_pack/bedrock/blockshapes/piston.py +44 -0
  82. amulet/resource_pack/bedrock/blockshapes/piston_arm.py +72 -0
  83. amulet/resource_pack/bedrock/blockshapes/portal_frame.py +22 -0
  84. amulet/resource_pack/bedrock/blockshapes/pressure_plate.py +29 -0
  85. amulet/resource_pack/bedrock/blockshapes/pumpkin.py +36 -0
  86. amulet/resource_pack/bedrock/blockshapes/pumpkin_carved.py +14 -0
  87. amulet/resource_pack/bedrock/blockshapes/pumpkin_lit.py +14 -0
  88. amulet/resource_pack/bedrock/blockshapes/red_dust.py +14 -0
  89. amulet/resource_pack/bedrock/blockshapes/repeater.py +53 -0
  90. amulet/resource_pack/bedrock/blockshapes/slab.py +33 -0
  91. amulet/resource_pack/bedrock/blockshapes/slab_double.py +15 -0
  92. amulet/resource_pack/bedrock/blockshapes/tree.py +41 -0
  93. amulet/resource_pack/bedrock/blockshapes/turtle_egg.py +15 -0
  94. amulet/resource_pack/bedrock/blockshapes/vine.py +52 -0
  95. amulet/resource_pack/bedrock/blockshapes/wall.py +22 -0
  96. amulet/resource_pack/bedrock/blockshapes/water.py +38 -0
  97. amulet/resource_pack/bedrock/download_resources.py +147 -0
  98. amulet/resource_pack/bedrock/resource_pack.py +40 -0
  99. amulet/resource_pack/bedrock/resource_pack_manager.py +361 -0
  100. amulet/resource_pack/bedrock/sort_blockshapes.py +15 -0
  101. amulet/resource_pack/java/__init__.py +2 -0
  102. amulet/resource_pack/java/download_resources.py +212 -0
  103. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_black.png +0 -0
  104. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_blue.png +0 -0
  105. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_brown.png +0 -0
  106. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_cyan.png +0 -0
  107. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_gray.png +0 -0
  108. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_green.png +0 -0
  109. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_light_blue.png +0 -0
  110. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_light_gray.png +0 -0
  111. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_lime.png +0 -0
  112. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_magenta.png +0 -0
  113. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_orange.png +0 -0
  114. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_pink.png +0 -0
  115. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_purple.png +0 -0
  116. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_red.png +0 -0
  117. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_white.png +0 -0
  118. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_yellow.png +0 -0
  119. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/barrier.png +0 -0
  120. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/end_portal.png +0 -0
  121. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/grass.png +0 -0
  122. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/lava.png +0 -0
  123. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/structure_void.png +0 -0
  124. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/water.png +0 -0
  125. amulet/resource_pack/java/java_vanilla_fix/pack.png +0 -0
  126. amulet/resource_pack/java/resource_pack.py +44 -0
  127. amulet/resource_pack/java/resource_pack_manager.py +551 -0
  128. amulet/resource_pack/unknown_resource_pack.py +10 -0
  129. amulet/utils/__init__.pyi +0 -5
  130. amulet/utils/call_spec/_call_spec.py +2 -7
  131. amulet/utils/comment_json.py +188 -0
  132. amulet/utils/matrix.py +3 -3
  133. amulet/utils/numpy_helpers.py +2 -2
  134. amulet/utils/world_utils.py +2 -2
  135. amulet/version.pyi +0 -8
  136. {amulet_core-2.0a6.dist-info → amulet_core-2.0a7.dist-info}/METADATA +2 -2
  137. amulet_core-2.0a7.dist-info/RECORD +295 -0
  138. amulet/chunk_/components/biome.py +0 -155
  139. amulet/chunk_/components/block_entity.py +0 -117
  140. amulet/chunk_/components/entity.py +0 -64
  141. amulet/chunk_/components/height_2d.py +0 -16
  142. amulet/level/bedrock/__init__.py +0 -2
  143. amulet/level/bedrock/_chunk_handle.py +0 -19
  144. amulet/level/bedrock/_dimension.py +0 -22
  145. amulet/level/bedrock/_level.py +0 -187
  146. amulet/level/bedrock/_raw/__init__.py +0 -5
  147. amulet/level/bedrock/_raw/_actor_counter.py +0 -53
  148. amulet/level/bedrock/_raw/_chunk.py +0 -54
  149. amulet/level/bedrock/_raw/_chunk_decode.py +0 -668
  150. amulet/level/bedrock/_raw/_chunk_encode.py +0 -602
  151. amulet/level/bedrock/_raw/_constant.py +0 -9
  152. amulet/level/bedrock/_raw/_dimension.py +0 -343
  153. amulet/level/bedrock/_raw/_level.py +0 -463
  154. amulet/level/bedrock/_raw/_level_dat.py +0 -90
  155. amulet/level/bedrock/_raw/_typing.py +0 -6
  156. amulet/level/bedrock/_raw/leveldb_chunk_versions.py +0 -83
  157. amulet/level/bedrock/chunk/__init__.py +0 -1
  158. amulet/level/bedrock/chunk/_chunk.py +0 -126
  159. amulet/level/bedrock/chunk/components/chunk_version.py +0 -12
  160. amulet/level/bedrock/chunk/components/finalised_state.py +0 -13
  161. amulet/level/bedrock/chunk/components/raw_chunk.py +0 -15
  162. amulet/level/construction/__init__.py +0 -0
  163. amulet/level/java/_chunk_handle.pyi +0 -15
  164. amulet/level/java/_dimension.pyi +0 -13
  165. amulet/level/java/_level.pyi +0 -120
  166. amulet/level/java/_raw/_chunk_decode.py +0 -561
  167. amulet/level/java/_raw/_chunk_encode.py +0 -463
  168. amulet/level/java/_raw/_constant.pyi +0 -20
  169. amulet/level/java/_raw/_data_pack/__init__.pyi +0 -8
  170. amulet/level/java/_raw/_data_pack/data_pack.pyi +0 -197
  171. amulet/level/java/_raw/_data_pack/data_pack_manager.pyi +0 -75
  172. amulet/level/java/_raw/_dimension.pyi +0 -72
  173. amulet/level/java/_raw/_level.pyi +0 -238
  174. amulet/level/java/_raw/_typing.pyi +0 -5
  175. amulet/level/java/anvil/__init__.pyi +0 -11
  176. amulet/level/java/anvil/_dimension.pyi +0 -109
  177. amulet/level/java/anvil/_region.pyi +0 -197
  178. amulet/level/java/anvil/_sector_manager.pyi +0 -142
  179. amulet/level/java_forge/__init__.py +0 -0
  180. amulet/level/mcstructure/__init__.py +0 -0
  181. amulet/level/nbt/__init__.py +0 -0
  182. amulet/level/schematic/__init__.py +0 -0
  183. amulet/level/sponge_schematic/__init__.py +0 -0
  184. amulet/pybind11/python.hpp +0 -14
  185. amulet/utils/call_spec/__init__.pyi +0 -53
  186. amulet/utils/call_spec/_call_spec.pyi +0 -272
  187. amulet/utils/matrix.pyi +0 -177
  188. amulet/utils/shareable_lock.pyi +0 -190
  189. amulet/utils/signal/__init__.pyi +0 -25
  190. amulet/utils/signal/_signal.pyi +0 -84
  191. amulet/utils/task_manager.pyi +0 -168
  192. amulet/utils/typing.py +0 -4
  193. amulet/utils/typing.pyi +0 -6
  194. amulet/utils/weakref.pyi +0 -50
  195. amulet/utils/world_utils.pyi +0 -109
  196. amulet_core-2.0a6.dist-info/RECORD +0 -253
  197. /amulet/img/{missing_world_icon.png → missing_world.png} +0 -0
  198. /amulet/{level/bedrock/chunk/components → mesh}/__init__.py +0 -0
  199. {amulet_core-2.0a6.dist-info → amulet_core-2.0a7.dist-info}/WHEEL +0 -0
  200. {amulet_core-2.0a6.dist-info → amulet_core-2.0a7.dist-info}/entry_points.txt +0 -0
  201. {amulet_core-2.0a6.dist-info → amulet_core-2.0a7.dist-info}/top_level.txt +0 -0
@@ -1,51 +1,76 @@
1
1
  #pragma once
2
2
  #include <pybind11/pybind11.h>
3
3
 
4
- namespace pybind11 {
5
- namespace collections {
6
- template <typename T>
7
- class Iterator : public object {
8
- PYBIND11_OBJECT_DEFAULT(Iterator, object, PyObject_Type)
4
+ namespace py = pybind11;
5
+
6
+ namespace Amulet {
7
+ namespace pybind11 {
8
+ namespace collections {
9
+ template <typename T>
10
+ class Iterator : public py::object {
11
+ PYBIND11_OBJECT_DEFAULT(Iterator, object, PyObject_Type)
9
12
  using object::object;
10
- };
13
+ };
14
+
15
+ template <typename T>
16
+ class Sequence : public py::object {
17
+ PYBIND11_OBJECT_DEFAULT(Sequence, object, PyObject_Type)
18
+ using object::object;
19
+ };
20
+
21
+ template <typename K, typename V>
22
+ class Mapping : public py::object {
23
+ PYBIND11_OBJECT_DEFAULT(Mapping, object, PyObject_Type)
24
+ using object::object;
25
+ };
26
+
27
+ template <typename K, typename V>
28
+ class MutableMapping : public py::object {
29
+ PYBIND11_OBJECT_DEFAULT(MutableMapping, object, PyObject_Type)
30
+ using object::object;
31
+ };
32
+
33
+ template <typename K>
34
+ class KeysView : public py::object {
35
+ PYBIND11_OBJECT_DEFAULT(KeysView, object, PyObject_Type)
36
+ using object::object;
37
+ };
38
+
39
+ template <typename V>
40
+ class ValuesView : public py::object {
41
+ PYBIND11_OBJECT_DEFAULT(ValuesView, object, PyObject_Type)
42
+ using object::object;
43
+ };
44
+
45
+ template <typename K, typename V>
46
+ class ItemsView : public py::object {
47
+ PYBIND11_OBJECT_DEFAULT(ItemsView, object, PyObject_Type)
48
+ using object::object;
49
+ };
50
+ }
11
51
  }
52
+ }
53
+
54
+ namespace pybind11 {
12
55
  namespace detail {
13
56
  template <typename T>
14
- struct handle_type_name<collections::Iterator<T>> {
57
+ struct handle_type_name<Amulet::pybind11::collections::Iterator<T>> {
15
58
  static constexpr auto name =
16
59
  const_name("collections.abc.Iterator[") +
17
60
  make_caster<T>::name +
18
61
  const_name("]");
19
62
  };
20
- }
21
-
22
- namespace collections {
23
- template <typename T>
24
- class Sequence : public object {
25
- PYBIND11_OBJECT_DEFAULT(Sequence, object, PyObject_Type)
26
- using object::object;
27
- };
28
- }
29
- namespace detail {
63
+
30
64
  template <typename T>
31
- struct handle_type_name<collections::Sequence<T>> {
65
+ struct handle_type_name<Amulet::pybind11::collections::Sequence<T>> {
32
66
  static constexpr auto name =
33
67
  const_name("collections.abc.Sequence[") +
34
68
  make_caster<T>::name +
35
69
  const_name("]");
36
70
  };
37
- }
38
-
39
- namespace collections {
40
- template <typename K, typename V>
41
- class Mapping : public object {
42
- PYBIND11_OBJECT_DEFAULT(Mapping, object, PyObject_Type)
43
- using object::object;
44
- };
45
- }
46
- namespace detail {
71
+
47
72
  template <typename K, typename V>
48
- struct handle_type_name<collections::Mapping<K, V>> {
73
+ struct handle_type_name<Amulet::pybind11::collections::Mapping<K, V>> {
49
74
  static constexpr auto name =
50
75
  const_name("collections.abc.Mapping[") +
51
76
  make_caster<K>::name +
@@ -53,20 +78,37 @@ namespace pybind11 {
53
78
  make_caster<V>::name +
54
79
  const_name("]");
55
80
  };
56
- }
57
81
 
58
- namespace collections {
59
82
  template <typename K, typename V>
60
- class MutableMapping : public object {
61
- PYBIND11_OBJECT_DEFAULT(MutableMapping, object, PyObject_Type)
62
- using object::object;
83
+ struct handle_type_name<Amulet::pybind11::collections::MutableMapping<K, V>> {
84
+ static constexpr auto name =
85
+ const_name("collections.abc.MutableMapping[") +
86
+ make_caster<K>::name +
87
+ const_name(", ")
88
+ + make_caster<V>::name +
89
+ const_name("]");
63
90
  };
64
- }
65
- namespace detail {
91
+
92
+ template <typename K>
93
+ struct handle_type_name<Amulet::pybind11::collections::KeysView<K>> {
94
+ static constexpr auto name =
95
+ const_name("collections.abc.KeysView[") +
96
+ make_caster<K>::name +
97
+ const_name("]");
98
+ };
99
+
100
+ template <typename V>
101
+ struct handle_type_name<Amulet::pybind11::collections::ValuesView<V>> {
102
+ static constexpr auto name =
103
+ const_name("collections.abc.ValuesView[") +
104
+ make_caster<V>::name +
105
+ const_name("]");
106
+ };
107
+
66
108
  template <typename K, typename V>
67
- struct handle_type_name<collections::MutableMapping<K, V>> {
109
+ struct handle_type_name<Amulet::pybind11::collections::ItemsView<K, V>> {
68
110
  static constexpr auto name =
69
- const_name("collections.abc.MutableMapping[") +
111
+ const_name("collections.abc.ItemsView[") +
70
112
  make_caster<K>::name +
71
113
  const_name(", ")
72
114
  + make_caster<V>::name +
@@ -0,0 +1,26 @@
1
+ #pragma once
2
+ #include <pybind11/pybind11.h>
3
+ #include <pybind11/numpy.h>
4
+
5
+ namespace py = pybind11;
6
+
7
+ namespace Amulet {
8
+ namespace pybind11 {
9
+ namespace numpy {
10
+ template <typename T, int ExtraFlags = py::array::forcecast>
11
+ class array_t : public py::array_t<T, ExtraFlags> {
12
+ using py::array_t<T, ExtraFlags>::array_t;
13
+ };
14
+ }
15
+ }
16
+ }
17
+
18
+ namespace pybind11 {
19
+ namespace detail {
20
+ template <typename T, int Flags>
21
+ struct handle_type_name<Amulet::pybind11::numpy::array_t<T, Flags>> {
22
+ static constexpr auto name
23
+ = const_name("numpy.typing.NDArray[") + npy_format_descriptor<T>::name + const_name("]");
24
+ };
25
+ }
26
+ }
@@ -7,63 +7,28 @@
7
7
  #include <utility>
8
8
 
9
9
  #include <pybind11/pybind11.h>
10
+ #include <amulet/pybind11/typing.hpp>
10
11
 
11
12
  namespace py = pybind11;
12
13
 
13
14
  namespace pybind11 {
14
- // Define deferred variables
15
- inline void def_deferred(
16
- py::module m,
17
- std::map<std::string, std::function<py::object()>> attrs
18
- ){
19
- m.def(
20
- "__getattr__",
21
- [attrs](py::object attr) -> py::object {
22
- if (py::isinstance<py::str>(attr)) {
23
- std::string attr_str = attr.cast<std::string>();
24
- auto it = attrs.find(attr_str);
25
- if (it != attrs.end()) {
26
- return it->second();
27
- }
28
- }
29
- throw py::attribute_error(py::repr(attr));
15
+ inline void def_package_path(py::module m_parent, py::module m, std::string name) {
16
+ py::list paths;
17
+ py::list parent_paths = m_parent.attr("__path__").cast<py::list>();
18
+ for (auto py_path : parent_paths) {
19
+ if (py::isinstance<py::str>(py_path)) {
20
+ std::string path = py_path.cast<std::string>();
21
+ path.push_back(std::filesystem::path::preferred_separator);
22
+ path.append(name);
23
+ paths.append(py::cast(path));
30
24
  }
31
- );
32
- m.def(
33
- "__dir__",
34
- [attrs, m]() {
35
- py::set names;
36
- // Add the variables defined in the module
37
- py::object dict = m.attr("__dict__");
38
- for (auto it = dict.begin(); it != dict.end(); it++) {
39
- names.add(*it);
40
- }
41
- // Add the deferred variables
42
- for (const auto& [name, _] : attrs) {
43
- names.add(py::str(name));
44
- }
45
- // Return as list
46
- return py::module::import("builtins").attr("list")(names);
47
- }
48
- );
49
- }
50
-
51
- inline std::pair<std::string, std::function<py::object()>> deferred_package_path(py::module m_parent, py::module m, std::string name) {
52
- auto getter = [m_parent, m, name]() {
53
- std::string path = m_parent.attr("__path__").attr("__getitem__")(0).cast<std::string>();
54
- path.push_back(std::filesystem::path::preferred_separator);
55
- path.append(name);
56
- py::list __path__;
57
- __path__.append(py::cast(path));
58
- return __path__;
59
- };
60
- return std::make_pair("__path__", getter);
25
+ }
26
+ m.attr("__path__") = paths;
61
27
  }
62
28
 
63
- inline std::pair<std::string, std::function<py::object()>> deferred_import(std::string module_name, std::string name) {
64
- auto getter = [module_name, name]() {
65
- return py::module::import(module_name.c_str()).attr(name.c_str());
66
- };
67
- return std::make_pair(name, getter);
29
+ inline module def_subpackage(py::module m_parent, std::string name) {
30
+ auto m = m_parent.def_submodule(name.c_str());
31
+ def_package_path(m_parent, m, name);
32
+ return m;
68
33
  }
69
34
  }
@@ -0,0 +1,51 @@
1
+ #pragma once
2
+ #include <pybind11/pybind11.h>
3
+ #include <pybind11/detail/descr.h>
4
+ #include <vector>
5
+
6
+ namespace py = pybind11;
7
+
8
+ namespace Amulet {
9
+ namespace pybind11 {
10
+ namespace detail {
11
+ template<size_t N>
12
+ struct FixedString {
13
+ char buf[N + 1]{};
14
+ constexpr FixedString(char const* s) {
15
+ for (unsigned i = 0; i != N; ++i) buf[i] = s[i];
16
+ }
17
+ };
18
+ template<unsigned N>
19
+ FixedString(char const (&)[N])->FixedString<N - 1>;
20
+ }
21
+
22
+ // Type hint for a native python object.
23
+ namespace type_hints {
24
+ template <detail::FixedString T>
25
+ class PyObjectStr : public py::object {
26
+ PYBIND11_OBJECT_DEFAULT(PyObjectStr, object, PyObject_Type)
27
+ using object::object;
28
+ };
29
+
30
+ template <typename cppT>
31
+ class PyObjectCpp : public py::object {
32
+ PYBIND11_OBJECT_DEFAULT(PyObjectCpp, object, PyObject_Type)
33
+ using object::object;
34
+ };
35
+ }
36
+ }
37
+ }
38
+
39
+ namespace pybind11 {
40
+ namespace detail {
41
+ template <Amulet::pybind11::detail::FixedString T>
42
+ struct handle_type_name<Amulet::pybind11::type_hints::PyObjectStr<T>> {
43
+ static constexpr auto name = pybind11::detail::const_name(T.buf);
44
+ };
45
+
46
+ template <typename cppT>
47
+ struct handle_type_name<Amulet::pybind11::type_hints::PyObjectCpp<cppT>> {
48
+ static constexpr auto name = make_caster<cppT>::name;
49
+ };
50
+ }
51
+ }
amulet/pybind11/types.hpp CHANGED
@@ -1,16 +1,24 @@
1
1
  #pragma once
2
2
  #include <pybind11/pybind11.h>
3
3
 
4
- namespace pybind11 {
5
- namespace types {
6
- class NotImplementedType : public object {
7
- PYBIND11_OBJECT_DEFAULT(NotImplementedType, object, PyObject_Type)
4
+ namespace py = pybind11;
5
+
6
+ namespace Amulet {
7
+ namespace pybind11 {
8
+ namespace types {
9
+ class NotImplementedType : public py::object {
10
+ PYBIND11_OBJECT_DEFAULT(NotImplementedType, object, PyObject_Type)
8
11
  using object::object;
9
- };
12
+ };
13
+ }
14
+
10
15
  }
16
+ }
17
+
18
+ namespace pybind11 {
11
19
  namespace detail {
12
20
  template <>
13
- struct handle_type_name<types::NotImplementedType> {
21
+ struct handle_type_name<Amulet::pybind11::types::NotImplementedType> {
14
22
  static constexpr auto name = const_name("types.NotImplementedType");
15
23
  };
16
24
  }
@@ -0,0 +1,7 @@
1
+ #pragma once
2
+ #include <pybind11/pybind11.h>
3
+ #include <vector>
4
+
5
+ namespace pybind11 {
6
+
7
+ }
@@ -0,0 +1,62 @@
1
+ from typing import Iterable, Union
2
+
3
+ from amulet.resource_pack.abc import (
4
+ BaseResourcePack,
5
+ BaseResourcePackManager,
6
+ )
7
+ from amulet.resource_pack.java import (
8
+ JavaResourcePack,
9
+ JavaResourcePackManager,
10
+ )
11
+ from amulet.resource_pack.bedrock import (
12
+ BedrockResourcePack,
13
+ BedrockResourcePackManager,
14
+ )
15
+ from .unknown_resource_pack import UnknownResourcePack
16
+
17
+
18
+ def load_resource_pack(resource_pack_path: str) -> BaseResourcePack:
19
+ if JavaResourcePack.is_valid(resource_pack_path):
20
+ return JavaResourcePack(resource_pack_path)
21
+ elif BedrockResourcePack.is_valid(resource_pack_path):
22
+ return BedrockResourcePack(resource_pack_path)
23
+ else:
24
+ return UnknownResourcePack(resource_pack_path)
25
+
26
+
27
+ def load_resource_pack_manager(
28
+ resource_packs: Iterable[Union[str, BaseResourcePack]], load: bool = True
29
+ ) -> BaseResourcePackManager:
30
+ resource_packs_out: list[BaseResourcePack] = []
31
+ for resource_pack in resource_packs:
32
+ if isinstance(resource_pack, str):
33
+ resource_pack = load_resource_pack(resource_pack)
34
+ if (
35
+ not isinstance(resource_pack, UnknownResourcePack)
36
+ and resource_pack.valid_pack
37
+ ):
38
+ if resource_packs_out:
39
+ if isinstance(resource_pack, resource_packs_out[0].__class__):
40
+ resource_packs_out.append(resource_pack)
41
+ else:
42
+ resource_packs_out.append(resource_pack)
43
+
44
+ resource_packs = resource_packs_out
45
+ if resource_packs:
46
+ if isinstance(resource_packs[0], JavaResourcePack):
47
+ return JavaResourcePackManager(
48
+ [pack for pack in resource_packs if isinstance(pack, JavaResourcePack)],
49
+ load,
50
+ )
51
+ elif isinstance(resource_packs[0], BedrockResourcePack):
52
+ return BedrockResourcePackManager(
53
+ [
54
+ pack
55
+ for pack in resource_packs
56
+ if isinstance(pack, BedrockResourcePack)
57
+ ],
58
+ load,
59
+ )
60
+
61
+ raise NotImplementedError
62
+ # return UnknownResourcePackManager()
@@ -0,0 +1,2 @@
1
+ from .resource_pack import BaseResourcePack
2
+ from .resource_pack_manager import BaseResourcePackManager
@@ -0,0 +1,38 @@
1
+ from amulet.img import missing_pack_icon_path
2
+
3
+
4
+ class BaseResourcePack:
5
+ """The base class that all resource packs must inherit from. Defines the base api."""
6
+
7
+ def __init__(self, root_dir: str):
8
+ self._valid_pack = False
9
+ self._root_dir = root_dir
10
+ self._pack_description = ""
11
+ self._pack_icon = missing_pack_icon_path
12
+
13
+ def __repr__(self) -> str:
14
+ raise NotImplementedError
15
+
16
+ @staticmethod
17
+ def is_valid(pack_path: str) -> bool:
18
+ raise NotImplementedError
19
+
20
+ @property
21
+ def valid_pack(self) -> bool:
22
+ """bool - does the pack meet the minimum requirements to be a resource pack"""
23
+ return self._valid_pack
24
+
25
+ @property
26
+ def root_dir(self) -> str:
27
+ """str - the root directory of the pack"""
28
+ return self._root_dir
29
+
30
+ @property
31
+ def pack_description(self) -> str:
32
+ """str - the description as described in the pack"""
33
+ return self._pack_description
34
+
35
+ @property
36
+ def pack_icon(self) -> str:
37
+ """str - path to the pack icon"""
38
+ return self._pack_icon
@@ -0,0 +1,87 @@
1
+ from typing import Optional, Iterator, TypeVar, Generic
2
+ import json
3
+ import copy
4
+
5
+ from amulet.block import Block, BlockStack
6
+ from amulet.mesh.block import BlockMesh
7
+ from amulet.resource_pack.abc.resource_pack import BaseResourcePack
8
+ from amulet.img import missing_no_icon_path
9
+ from amulet.mesh.block.missing_block import get_missing_block
10
+
11
+ PackT = TypeVar("PackT", bound=BaseResourcePack)
12
+
13
+
14
+ class BaseResourcePackManager(Generic[PackT]):
15
+ """The base class that all resource pack managers must inherit from. Defines the base api."""
16
+
17
+ def __init__(self) -> None:
18
+ self._packs: list[PackT] = []
19
+ self._missing_block: Optional[BlockMesh] = None
20
+ self._texture_is_transparent: dict[str, tuple[float, bool]] = {}
21
+ self._cached_models: dict[BlockStack, BlockMesh] = {}
22
+
23
+ @property
24
+ def pack_paths(self) -> list[str]:
25
+ return [pack.root_dir for pack in self._packs]
26
+
27
+ def _unload(self) -> None:
28
+ """Clear all loaded resources."""
29
+ self._texture_is_transparent.clear()
30
+ self._cached_models.clear()
31
+
32
+ def _load_transparency_cache(self, path: str) -> None:
33
+ try:
34
+ with open(path) as f:
35
+ self._texture_is_transparent = json.load(f)
36
+ except:
37
+ pass
38
+
39
+ def _load_iter(self) -> Iterator[float]:
40
+ """Load resources."""
41
+ raise NotImplementedError
42
+
43
+ def reload(self) -> Iterator[float]:
44
+ """Unload and reload resources"""
45
+ self._unload()
46
+ yield from self._load_iter()
47
+
48
+ @property
49
+ def missing_no(self) -> str:
50
+ """The path to the missing_no image"""
51
+ return missing_no_icon_path
52
+
53
+ @property
54
+ def missing_block(self) -> BlockMesh:
55
+ if self._missing_block is None:
56
+ self._missing_block = get_missing_block(self)
57
+ return self._missing_block
58
+
59
+ @property
60
+ def textures(self) -> tuple[str, ...]:
61
+ """Returns a tuple of all the texture paths in the resource pack."""
62
+ raise NotImplementedError
63
+
64
+ def get_texture_path(self, namespace: Optional[str], relative_path: str) -> str:
65
+ """Get the absolute texture path from the namespace and relative path pair"""
66
+ raise NotImplementedError
67
+
68
+ def get_block_model(self, block_stack: BlockStack) -> BlockMesh:
69
+ """Get a model for a block state.
70
+ The block should already be in the resource pack format"""
71
+ if block_stack not in self._cached_models:
72
+ if len(block_stack) == 1:
73
+ self._cached_models[block_stack] = self._get_model(
74
+ block_stack.base_block
75
+ )
76
+ else:
77
+ self._cached_models[block_stack] = BlockMesh.merge(
78
+ (self._get_model(block_stack.base_block),)
79
+ + tuple(
80
+ self._get_model(block_) for block_ in block_stack.extra_blocks
81
+ )
82
+ )
83
+
84
+ return copy.deepcopy(self._cached_models[block_stack])
85
+
86
+ def _get_model(self, block: Block) -> BlockMesh:
87
+ raise NotImplementedError
@@ -0,0 +1,2 @@
1
+ from .resource_pack import BedrockResourcePack
2
+ from .resource_pack_manager import BedrockResourcePackManager
@@ -0,0 +1,31 @@
1
+ import importlib
2
+ import pkgutil
3
+
4
+ from .base_blockshape import BaseBlockShape
5
+
6
+ BlockShapeClasses: dict[str, BaseBlockShape] = {}
7
+ _class_names = set()
8
+
9
+
10
+ def _load_blockshape(module_name: str) -> None:
11
+ blockshape_module = importlib.import_module(module_name)
12
+ if hasattr(blockshape_module, "BlockShape"):
13
+ blockshape = getattr(blockshape_module, "BlockShape")
14
+ if isinstance(blockshape, BaseBlockShape):
15
+ if blockshape.blockshape in BlockShapeClasses:
16
+ print(f"Name conflict with blockshape {blockshape.blockshape}")
17
+ if blockshape.__class__.__name__ in _class_names:
18
+ print(f"Duplicate class name {blockshape.__class__.__name__}")
19
+ else:
20
+ _class_names.add(blockshape.__class__.__name__)
21
+ BlockShapeClasses[blockshape.blockshape] = blockshape
22
+
23
+
24
+ def _load_blockshapes() -> None:
25
+ package_prefix = __name__ + "."
26
+
27
+ for _, name, _ in pkgutil.walk_packages(__path__, package_prefix):
28
+ _load_blockshape(name)
29
+
30
+
31
+ _load_blockshapes()
@@ -0,0 +1,35 @@
1
+ from amulet.block import Block
2
+ from amulet.mesh.block.block_mesh import BlockMesh, Transparency
3
+ from amulet.resource_pack.bedrock.blockshapes.base_blockshape import (
4
+ BaseBlockShape,
5
+ )
6
+
7
+
8
+ class Air(BaseBlockShape):
9
+ @property
10
+ def blockshape(self) -> str:
11
+ return "air"
12
+
13
+ def is_valid(self, block: Block) -> bool:
14
+ """Does the given block have the correct properties to use this blockshape"""
15
+ return True
16
+
17
+ def texture_index(self, block: Block, aux_value: int) -> int:
18
+ """The texture index to use within the list for the given Block"""
19
+ return 0
20
+
21
+ def get_block_model(
22
+ self,
23
+ block: Block,
24
+ down: str,
25
+ up: str,
26
+ north: str,
27
+ east: str,
28
+ south: str,
29
+ west: str,
30
+ transparency: tuple[bool, bool, bool, bool, bool, bool],
31
+ ) -> BlockMesh:
32
+ return BlockMesh(3, {}, {}, {}, {}, {}, (), Transparency.Partial)
33
+
34
+
35
+ BlockShape = Air()
@@ -0,0 +1,29 @@
1
+ from amulet.block import Block
2
+ from amulet.mesh.block import BlockMesh
3
+
4
+
5
+ class BaseBlockShape:
6
+ @property
7
+ def blockshape(self) -> str:
8
+ raise NotImplementedError
9
+
10
+ def is_valid(self, block: Block) -> bool:
11
+ """Does the given block have the correct properties to use this blockshape"""
12
+ raise NotImplementedError
13
+
14
+ def texture_index(self, block: Block, aux_value: int) -> int:
15
+ """The texture index to use within the list for the given Block"""
16
+ raise NotImplementedError
17
+
18
+ def get_block_model(
19
+ self,
20
+ block: Block,
21
+ down: str,
22
+ up: str,
23
+ north: str,
24
+ east: str,
25
+ south: str,
26
+ west: str,
27
+ transparency: tuple[bool, bool, bool, bool, bool, bool],
28
+ ) -> BlockMesh:
29
+ raise NotImplementedError