amulet-core 2.0a8__cp311-cp311-win_amd64.whl → 2.0.1a2.post250529084738__cp311-cp311-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of amulet-core might be problematic. Click here for more details.

Files changed (271) hide show
  1. amulet/core/__init__.py +36 -0
  2. amulet/core/__pyinstaller/hook-amulet.core.py +4 -0
  3. amulet/core/_amulet_core.cp311-win_amd64.pyd +0 -0
  4. amulet/core/_amulet_core.pyi +7 -0
  5. amulet/{_version.py → core/_version.py} +3 -3
  6. amulet/core/amulet_core.dll +0 -0
  7. amulet/core/amulet_core.lib +0 -0
  8. amulet/core/amulet_coreConfig.cmake +18 -0
  9. amulet/{biome.pyi → core/biome/__init__.pyi} +3 -3
  10. amulet/core/biome/biome.hpp +53 -0
  11. amulet/{block.pyi → core/block/__init__.pyi} +25 -26
  12. amulet/core/block/block.hpp +156 -0
  13. amulet/{block_entity.pyi → core/block_entity/__init__.pyi} +7 -7
  14. amulet/core/block_entity/block_entity.hpp +84 -0
  15. amulet/{errors.py → core/chunk/__init__.pyi} +37 -33
  16. amulet/core/chunk/chunk.hpp +126 -0
  17. amulet/core/chunk/component/__init__.pyi +18 -0
  18. amulet/core/chunk/component/biome_3d_component.hpp +96 -0
  19. amulet/core/chunk/component/block_component.hpp +101 -0
  20. amulet/core/chunk/component/block_component.pyi +28 -0
  21. amulet/core/chunk/component/block_entity_component.hpp +119 -0
  22. amulet/core/chunk/component/section_array_map.hpp +129 -0
  23. amulet/{chunk_components.pyi → core/chunk/component/section_array_map.pyi} +4 -24
  24. amulet/core/dll.hpp +21 -0
  25. amulet/core/entity/__init__.pyi +105 -0
  26. amulet/core/entity/entity.hpp +100 -0
  27. amulet/{palette → core/palette}/__init__.pyi +2 -2
  28. amulet/core/palette/biome_palette.hpp +65 -0
  29. amulet/{palette → core/palette}/biome_palette.pyi +8 -8
  30. amulet/core/palette/block_palette.hpp +71 -0
  31. amulet/{palette → core/palette}/block_palette.pyi +12 -10
  32. amulet/core/selection/__init__.pyi +8 -0
  33. amulet/core/selection/box.hpp +86 -0
  34. amulet/core/selection/box.pyi +215 -0
  35. amulet/core/selection/group.hpp +80 -0
  36. amulet/core/selection/group.pyi +213 -0
  37. amulet/{version.pyi → core/version/__init__.pyi} +58 -10
  38. amulet/core/version/version.hpp +204 -0
  39. {amulet_core-2.0a8.dist-info → amulet_core-2.0.1a2.post250529084738.dist-info}/METADATA +25 -20
  40. amulet_core-2.0.1a2.post250529084738.dist-info/RECORD +45 -0
  41. {amulet_core-2.0a8.dist-info → amulet_core-2.0.1a2.post250529084738.dist-info}/WHEEL +1 -1
  42. amulet_core-2.0.1a2.post250529084738.dist-info/entry_points.txt +2 -0
  43. amulet/__init__.cp311-win_amd64.pyd +0 -0
  44. amulet/__init__.py.cpp +0 -45
  45. amulet/__init__.pyi +0 -30
  46. amulet/__pyinstaller/hook-amulet.py +0 -4
  47. amulet/_init.py +0 -26
  48. amulet/biome.cpp +0 -36
  49. amulet/biome.hpp +0 -43
  50. amulet/biome.py.cpp +0 -122
  51. amulet/block.cpp +0 -435
  52. amulet/block.hpp +0 -119
  53. amulet/block.py.cpp +0 -377
  54. amulet/block_entity.cpp +0 -12
  55. amulet/block_entity.hpp +0 -56
  56. amulet/block_entity.py.cpp +0 -115
  57. amulet/chunk.cpp +0 -16
  58. amulet/chunk.hpp +0 -100
  59. amulet/chunk.py.cpp +0 -80
  60. amulet/chunk.pyi +0 -28
  61. amulet/chunk_components/biome_3d_component.cpp +0 -5
  62. amulet/chunk_components/biome_3d_component.hpp +0 -79
  63. amulet/chunk_components/block_component.cpp +0 -41
  64. amulet/chunk_components/block_component.hpp +0 -88
  65. amulet/chunk_components/block_entity_component.cpp +0 -5
  66. amulet/chunk_components/block_entity_component.hpp +0 -147
  67. amulet/chunk_components/section_array_map.cpp +0 -129
  68. amulet/chunk_components/section_array_map.hpp +0 -147
  69. amulet/collections/eq.py.hpp +0 -37
  70. amulet/collections/hash.py.hpp +0 -27
  71. amulet/collections/holder.py.hpp +0 -37
  72. amulet/collections/iterator.py.hpp +0 -80
  73. amulet/collections/mapping.py.hpp +0 -199
  74. amulet/collections/mutable_mapping.py.hpp +0 -226
  75. amulet/collections/sequence.py.hpp +0 -163
  76. amulet/collections.pyi +0 -40
  77. amulet/data_types.py +0 -29
  78. amulet/entity.py +0 -182
  79. amulet/game/__init__.py +0 -7
  80. amulet/game/_game.py +0 -152
  81. amulet/game/_universal/__init__.py +0 -1
  82. amulet/game/_universal/_biome.py +0 -17
  83. amulet/game/_universal/_block.py +0 -47
  84. amulet/game/_universal/_version.py +0 -68
  85. amulet/game/abc/__init__.py +0 -22
  86. amulet/game/abc/_block_specification.py +0 -150
  87. amulet/game/abc/biome.py +0 -213
  88. amulet/game/abc/block.py +0 -331
  89. amulet/game/abc/game_version_container.py +0 -25
  90. amulet/game/abc/json_interface.py +0 -27
  91. amulet/game/abc/version.py +0 -44
  92. amulet/game/bedrock/__init__.py +0 -1
  93. amulet/game/bedrock/_biome.py +0 -35
  94. amulet/game/bedrock/_block.py +0 -42
  95. amulet/game/bedrock/_version.py +0 -165
  96. amulet/game/java/__init__.py +0 -2
  97. amulet/game/java/_biome.py +0 -35
  98. amulet/game/java/_block.py +0 -60
  99. amulet/game/java/_version.py +0 -176
  100. amulet/game/translate/__init__.py +0 -12
  101. amulet/game/translate/_functions/__init__.py +0 -15
  102. amulet/game/translate/_functions/_code_functions/__init__.py +0 -0
  103. amulet/game/translate/_functions/_code_functions/_text.py +0 -553
  104. amulet/game/translate/_functions/_code_functions/banner_pattern.py +0 -67
  105. amulet/game/translate/_functions/_code_functions/bedrock_chest_connection.py +0 -152
  106. amulet/game/translate/_functions/_code_functions/bedrock_moving_block_pos.py +0 -88
  107. amulet/game/translate/_functions/_code_functions/bedrock_sign.py +0 -152
  108. amulet/game/translate/_functions/_code_functions/bedrock_skull_rotation.py +0 -16
  109. amulet/game/translate/_functions/_code_functions/custom_name.py +0 -146
  110. amulet/game/translate/_functions/_frozen.py +0 -66
  111. amulet/game/translate/_functions/_state.py +0 -54
  112. amulet/game/translate/_functions/_typing.py +0 -98
  113. amulet/game/translate/_functions/abc.py +0 -123
  114. amulet/game/translate/_functions/carry_nbt.py +0 -160
  115. amulet/game/translate/_functions/carry_properties.py +0 -80
  116. amulet/game/translate/_functions/code.py +0 -143
  117. amulet/game/translate/_functions/map_block_name.py +0 -66
  118. amulet/game/translate/_functions/map_nbt.py +0 -111
  119. amulet/game/translate/_functions/map_properties.py +0 -93
  120. amulet/game/translate/_functions/multiblock.py +0 -112
  121. amulet/game/translate/_functions/new_block.py +0 -42
  122. amulet/game/translate/_functions/new_entity.py +0 -43
  123. amulet/game/translate/_functions/new_nbt.py +0 -206
  124. amulet/game/translate/_functions/new_properties.py +0 -64
  125. amulet/game/translate/_functions/sequence.py +0 -51
  126. amulet/game/translate/_functions/walk_input_nbt.py +0 -331
  127. amulet/game/translate/_translator.py +0 -433
  128. amulet/img/__init__.py +0 -10
  129. amulet/img/missing_no.png +0 -0
  130. amulet/img/missing_pack.png +0 -0
  131. amulet/img/missing_world.png +0 -0
  132. amulet/io/binary_reader.hpp +0 -45
  133. amulet/io/binary_writer.hpp +0 -30
  134. amulet/item.py +0 -75
  135. amulet/level/__init__.pyi +0 -23
  136. amulet/level/_load.py +0 -100
  137. amulet/level/abc/__init__.py +0 -12
  138. amulet/level/abc/_chunk_handle.py +0 -358
  139. amulet/level/abc/_dimension.py +0 -86
  140. amulet/level/abc/_history/__init__.py +0 -1
  141. amulet/level/abc/_history/_cache.py +0 -224
  142. amulet/level/abc/_history/_history_manager.py +0 -291
  143. amulet/level/abc/_level/__init__.py +0 -5
  144. amulet/level/abc/_level/_compactable_level.py +0 -10
  145. amulet/level/abc/_level/_creatable_level.py +0 -28
  146. amulet/level/abc/_level/_disk_level.py +0 -17
  147. amulet/level/abc/_level/_level.py +0 -449
  148. amulet/level/abc/_level/_loadable_level.py +0 -42
  149. amulet/level/abc/_player_storage.py +0 -7
  150. amulet/level/abc/_raw_level.py +0 -187
  151. amulet/level/abc/_registry.py +0 -40
  152. amulet/level/java/__init__.pyi +0 -16
  153. amulet/level/java/_chunk_handle.py +0 -17
  154. amulet/level/java/_dimension.py +0 -20
  155. amulet/level/java/_level.py +0 -184
  156. amulet/level/java/_raw/__init__.pyi +0 -15
  157. amulet/level/java/_raw/_chunk.pyi +0 -23
  158. amulet/level/java/_raw/_constant.py +0 -9
  159. amulet/level/java/_raw/_data_pack/__init__.py +0 -2
  160. amulet/level/java/_raw/_data_pack/data_pack.py +0 -241
  161. amulet/level/java/_raw/_data_pack/data_pack_manager.py +0 -77
  162. amulet/level/java/_raw/_dimension.py +0 -86
  163. amulet/level/java/_raw/_level.py +0 -507
  164. amulet/level/java/_raw/_typing.py +0 -3
  165. amulet/level/java/_raw/java_chunk_decode.cpp +0 -531
  166. amulet/level/java/_raw/java_chunk_decode.hpp +0 -23
  167. amulet/level/java/_raw/java_chunk_encode.cpp +0 -25
  168. amulet/level/java/_raw/java_chunk_encode.hpp +0 -23
  169. amulet/level/java/anvil/__init__.py +0 -2
  170. amulet/level/java/anvil/_dimension.py +0 -170
  171. amulet/level/java/anvil/_region.py +0 -421
  172. amulet/level/java/anvil/_sector_manager.py +0 -223
  173. amulet/level/java/chunk.pyi +0 -81
  174. amulet/level/java/chunk_/_chunk.py +0 -260
  175. amulet/level/java/chunk_/components/inhabited_time.py +0 -12
  176. amulet/level/java/chunk_/components/last_update.py +0 -12
  177. amulet/level/java/chunk_/components/legacy_version.py +0 -12
  178. amulet/level/java/chunk_/components/light_populated.py +0 -12
  179. amulet/level/java/chunk_/components/named_height_2d.py +0 -37
  180. amulet/level/java/chunk_/components/status.py +0 -11
  181. amulet/level/java/chunk_/components/terrain_populated.py +0 -12
  182. amulet/level/java/chunk_components/data_version_component.cpp +0 -32
  183. amulet/level/java/chunk_components/data_version_component.hpp +0 -31
  184. amulet/level/java/chunk_components/java_raw_chunk_component.cpp +0 -56
  185. amulet/level/java/chunk_components/java_raw_chunk_component.hpp +0 -45
  186. amulet/level/java/chunk_components.pyi +0 -22
  187. amulet/level/java/java_chunk.cpp +0 -170
  188. amulet/level/java/java_chunk.hpp +0 -141
  189. amulet/level/java/long_array.hpp +0 -175
  190. amulet/level/java/long_array.pyi +0 -39
  191. amulet/level/temporary_level/__init__.py +0 -1
  192. amulet/level/temporary_level/_level.py +0 -16
  193. amulet/mesh/__init__.py +0 -0
  194. amulet/mesh/block/__init__.pyi +0 -301
  195. amulet/mesh/block/_cube.py +0 -198
  196. amulet/mesh/block/_missing_block.py +0 -20
  197. amulet/mesh/block/block_mesh.cpp +0 -107
  198. amulet/mesh/block/block_mesh.hpp +0 -207
  199. amulet/mesh/util.py +0 -17
  200. amulet/palette/biome_palette.hpp +0 -85
  201. amulet/palette/block_palette.cpp +0 -32
  202. amulet/palette/block_palette.hpp +0 -93
  203. amulet/player.py +0 -62
  204. amulet/pybind11/collections.hpp +0 -118
  205. amulet/pybind11/numpy.hpp +0 -26
  206. amulet/pybind11/py_module.hpp +0 -34
  207. amulet/pybind11/type_hints.hpp +0 -51
  208. amulet/pybind11/types.hpp +0 -25
  209. amulet/pybind11/typing.hpp +0 -7
  210. amulet/resource_pack/__init__.py +0 -63
  211. amulet/resource_pack/abc/__init__.py +0 -2
  212. amulet/resource_pack/abc/resource_pack.py +0 -38
  213. amulet/resource_pack/abc/resource_pack_manager.py +0 -85
  214. amulet/resource_pack/java/__init__.py +0 -2
  215. amulet/resource_pack/java/download_resources.py +0 -212
  216. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_black.png +0 -0
  217. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_blue.png +0 -0
  218. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_brown.png +0 -0
  219. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_cyan.png +0 -0
  220. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_gray.png +0 -0
  221. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_green.png +0 -0
  222. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_light_blue.png +0 -0
  223. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_light_gray.png +0 -0
  224. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_lime.png +0 -0
  225. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_magenta.png +0 -0
  226. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_orange.png +0 -0
  227. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_pink.png +0 -0
  228. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_purple.png +0 -0
  229. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_red.png +0 -0
  230. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_white.png +0 -0
  231. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_yellow.png +0 -0
  232. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/barrier.png +0 -0
  233. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/end_portal.png +0 -0
  234. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/grass.png +0 -0
  235. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/lava.png +0 -0
  236. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/structure_void.png +0 -0
  237. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/water.png +0 -0
  238. amulet/resource_pack/java/java_vanilla_fix/pack.png +0 -0
  239. amulet/resource_pack/java/resource_pack.py +0 -44
  240. amulet/resource_pack/java/resource_pack_manager.py +0 -563
  241. amulet/resource_pack/unknown_resource_pack.py +0 -10
  242. amulet/selection/__init__.py +0 -2
  243. amulet/selection/abstract_selection.py +0 -342
  244. amulet/selection/box.py +0 -852
  245. amulet/selection/group.py +0 -481
  246. amulet/utils/__init__.pyi +0 -23
  247. amulet/utils/call_spec/__init__.py +0 -24
  248. amulet/utils/call_spec/_call_spec.py +0 -257
  249. amulet/utils/cast.py +0 -10
  250. amulet/utils/comment_json.py +0 -188
  251. amulet/utils/format_utils.py +0 -41
  252. amulet/utils/generator.py +0 -18
  253. amulet/utils/matrix.py +0 -243
  254. amulet/utils/numpy.hpp +0 -36
  255. amulet/utils/numpy.pyi +0 -11
  256. amulet/utils/numpy_helpers.py +0 -19
  257. amulet/utils/shareable_lock.py +0 -335
  258. amulet/utils/signal/__init__.py +0 -10
  259. amulet/utils/signal/_signal.py +0 -228
  260. amulet/utils/task_manager.py +0 -235
  261. amulet/utils/typed_property.py +0 -111
  262. amulet/utils/weakref.py +0 -70
  263. amulet/utils/world_utils.py +0 -102
  264. amulet/version.cpp +0 -136
  265. amulet/version.hpp +0 -142
  266. amulet/version.py.cpp +0 -281
  267. amulet_core-2.0a8.dist-info/RECORD +0 -241
  268. amulet_core-2.0a8.dist-info/entry_points.txt +0 -2
  269. /amulet/{__pyinstaller → core/__pyinstaller}/__init__.py +0 -0
  270. /amulet/{py.typed → core/py.typed} +0 -0
  271. {amulet_core-2.0a8.dist-info → amulet_core-2.0.1a2.post250529084738.dist-info}/top_level.txt +0 -0
@@ -1,51 +0,0 @@
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 DELETED
@@ -1,25 +0,0 @@
1
- #pragma once
2
- #include <pybind11/pybind11.h>
3
-
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)
11
- using object::object;
12
- };
13
- }
14
-
15
- }
16
- }
17
-
18
- namespace pybind11 {
19
- namespace detail {
20
- template <>
21
- struct handle_type_name<Amulet::pybind11::types::NotImplementedType> {
22
- static constexpr auto name = const_name("types.NotImplementedType");
23
- };
24
- }
25
- }
@@ -1,7 +0,0 @@
1
- #pragma once
2
- #include <pybind11/pybind11.h>
3
- #include <vector>
4
-
5
- namespace pybind11 {
6
-
7
- }
@@ -1,63 +0,0 @@
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
-
12
- # from amulet.resource_pack.bedrock import (
13
- # BedrockResourcePack,
14
- # BedrockResourcePackManager,
15
- # )
16
- from .unknown_resource_pack import UnknownResourcePack
17
-
18
-
19
- def load_resource_pack(resource_pack_path: str) -> BaseResourcePack:
20
- if JavaResourcePack.is_valid(resource_pack_path):
21
- return JavaResourcePack(resource_pack_path)
22
- # elif BedrockResourcePack.is_valid(resource_pack_path):
23
- # return BedrockResourcePack(resource_pack_path)
24
- else:
25
- return UnknownResourcePack(resource_pack_path)
26
-
27
-
28
- def load_resource_pack_manager(
29
- resource_packs: Iterable[Union[str, BaseResourcePack]], load: bool = True
30
- ) -> BaseResourcePackManager:
31
- resource_packs_out: list[BaseResourcePack] = []
32
- for resource_pack in resource_packs:
33
- if isinstance(resource_pack, str):
34
- resource_pack = load_resource_pack(resource_pack)
35
- if (
36
- not isinstance(resource_pack, UnknownResourcePack)
37
- and resource_pack.valid_pack
38
- ):
39
- if resource_packs_out:
40
- if isinstance(resource_pack, resource_packs_out[0].__class__):
41
- resource_packs_out.append(resource_pack)
42
- else:
43
- resource_packs_out.append(resource_pack)
44
-
45
- resource_packs = resource_packs_out
46
- if resource_packs:
47
- if isinstance(resource_packs[0], JavaResourcePack):
48
- return JavaResourcePackManager(
49
- [pack for pack in resource_packs if isinstance(pack, JavaResourcePack)],
50
- load,
51
- )
52
- # elif isinstance(resource_packs[0], BedrockResourcePack):
53
- # return BedrockResourcePackManager(
54
- # [
55
- # pack
56
- # for pack in resource_packs
57
- # if isinstance(pack, BedrockResourcePack)
58
- # ],
59
- # load,
60
- # )
61
-
62
- raise NotImplementedError
63
- # return UnknownResourcePackManager()
@@ -1,2 +0,0 @@
1
- from .resource_pack import BaseResourcePack
2
- from .resource_pack_manager import BaseResourcePackManager
@@ -1,38 +0,0 @@
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
@@ -1,85 +0,0 @@
1
- from typing import Optional, Iterator, TypeVar, Generic
2
- import json
3
-
4
- from amulet.block import Block, BlockStack
5
- from amulet.mesh.block import BlockMesh, merge_block_meshes, get_missing_block
6
- from amulet.resource_pack.abc.resource_pack import BaseResourcePack
7
- from amulet.img import missing_no_icon_path
8
-
9
- PackT = TypeVar("PackT", bound=BaseResourcePack)
10
-
11
-
12
- class BaseResourcePackManager(Generic[PackT]):
13
- """The base class that all resource pack managers must inherit from. Defines the base api."""
14
-
15
- def __init__(self) -> None:
16
- self._packs: list[PackT] = []
17
- self._missing_block: Optional[BlockMesh] = None
18
- self._texture_is_transparent: dict[str, tuple[float, bool]] = {}
19
- self._cached_models: dict[BlockStack, BlockMesh] = {}
20
-
21
- @property
22
- def pack_paths(self) -> list[str]:
23
- return [pack.root_dir for pack in self._packs]
24
-
25
- def _unload(self) -> None:
26
- """Clear all loaded resources."""
27
- self._texture_is_transparent.clear()
28
- self._cached_models.clear()
29
-
30
- def _load_transparency_cache(self, path: str) -> None:
31
- try:
32
- with open(path) as f:
33
- self._texture_is_transparent = json.load(f)
34
- except:
35
- pass
36
-
37
- def _load_iter(self) -> Iterator[float]:
38
- """Load resources."""
39
- raise NotImplementedError
40
-
41
- def reload(self) -> Iterator[float]:
42
- """Unload and reload resources"""
43
- self._unload()
44
- yield from self._load_iter()
45
-
46
- @property
47
- def missing_no(self) -> str:
48
- """The path to the missing_no image"""
49
- return missing_no_icon_path
50
-
51
- @property
52
- def missing_block(self) -> BlockMesh:
53
- if self._missing_block is None:
54
- self._missing_block = get_missing_block(self)
55
- return self._missing_block
56
-
57
- @property
58
- def textures(self) -> tuple[str, ...]:
59
- """Returns a tuple of all the texture paths in the resource pack."""
60
- raise NotImplementedError
61
-
62
- def get_texture_path(self, namespace: Optional[str], relative_path: str) -> str:
63
- """Get the absolute texture path from the namespace and relative path pair"""
64
- raise NotImplementedError
65
-
66
- def get_block_model(self, block_stack: BlockStack) -> BlockMesh:
67
- """Get a model for a block state.
68
- The block should already be in the resource pack format"""
69
- if block_stack not in self._cached_models:
70
- if len(block_stack) == 1:
71
- self._cached_models[block_stack] = self._get_model(
72
- block_stack.base_block
73
- )
74
- else:
75
- self._cached_models[block_stack] = merge_block_meshes(
76
- (self._get_model(block_stack.base_block),)
77
- + tuple(
78
- self._get_model(block_) for block_ in block_stack.extra_blocks
79
- )
80
- )
81
-
82
- return self._cached_models[block_stack]
83
-
84
- def _get_model(self, block: Block) -> BlockMesh:
85
- raise NotImplementedError
@@ -1,2 +0,0 @@
1
- from .resource_pack import JavaResourcePack
2
- from .resource_pack_manager import JavaResourcePackManager
@@ -1,212 +0,0 @@
1
- import os
2
- import shutil
3
- import zipfile
4
- import json
5
- from urllib.request import urlopen, Request
6
- import io
7
- from typing import Generator, TypeVar, Any, Optional
8
- import logging
9
-
10
- from amulet.resource_pack import JavaResourcePack
11
-
12
- T = TypeVar("T")
13
-
14
- log = logging.getLogger(__name__)
15
-
16
- launcher_manifest: Optional[dict] = None
17
- INCLUDE_SNAPSHOT = False
18
-
19
-
20
- def get_launcher_manifest() -> dict:
21
- global launcher_manifest
22
- if launcher_manifest is None:
23
- log.info("Downloading java launcher manifest file.")
24
- with urlopen(
25
- "https://launchermeta.mojang.com/mc/game/version_manifest.json", timeout=20
26
- ) as manifest:
27
- launcher_manifest = json.load(manifest)
28
- log.info("Finished downloading java launcher manifest file.")
29
- return launcher_manifest
30
-
31
-
32
- def generator_unpacker(gen: Generator[Any, Any, T]) -> T:
33
- try:
34
- while True:
35
- next(gen)
36
- except StopIteration as e:
37
- return e.value # type: ignore
38
-
39
-
40
- def get_latest() -> JavaResourcePack:
41
- return generator_unpacker(get_latest_iter())
42
-
43
-
44
- def get_latest_iter() -> Generator[float, None, JavaResourcePack]:
45
- """Download the latest resource pack if required.
46
-
47
- :return: The loaded Java resource pack.
48
- :raises:
49
- Exception: If the
50
- """
51
- vanilla_rp_path = os.path.join(
52
- os.environ["CACHE_DIR"], "resource_packs", "java", "vanilla"
53
- )
54
- try:
55
- if INCLUDE_SNAPSHOT:
56
- new_version = get_launcher_manifest()["latest"]["snapshot"]
57
- else:
58
- new_version = get_launcher_manifest()["latest"]["release"]
59
- except Exception as e:
60
- if os.path.isdir(vanilla_rp_path):
61
- log.error(
62
- "Could not download the launcher manifest. The resource pack seems to be present so using that."
63
- )
64
- else:
65
- raise e
66
- else:
67
- has_new_pack = False
68
- if os.path.isfile(os.path.join(vanilla_rp_path, "version")):
69
- with open(os.path.join(vanilla_rp_path, "version")) as f:
70
- old_version = f.read()
71
- has_new_pack = old_version == new_version
72
-
73
- if not has_new_pack:
74
- yield from _remove_and_download_iter(vanilla_rp_path, new_version)
75
- return JavaResourcePack(vanilla_rp_path)
76
-
77
-
78
- _java_vanilla_fix: Optional[JavaResourcePack] = None
79
- _java_vanilla_latest: Optional[JavaResourcePack] = None
80
-
81
-
82
- def get_java_vanilla_fix() -> JavaResourcePack:
83
- global _java_vanilla_fix
84
- if _java_vanilla_fix is None:
85
- _java_vanilla_fix = JavaResourcePack(
86
- os.path.join(os.path.dirname(__file__), "java_vanilla_fix")
87
- )
88
- return _java_vanilla_fix
89
-
90
-
91
- def get_java_vanilla_latest() -> JavaResourcePack:
92
- global _java_vanilla_latest
93
- if _java_vanilla_latest is None:
94
- _java_vanilla_latest = get_latest()
95
- return _java_vanilla_latest
96
-
97
-
98
- def get_java_vanilla_latest_iter() -> Generator[float, None, JavaResourcePack]:
99
- global _java_vanilla_latest
100
- if _java_vanilla_latest is None:
101
- _java_vanilla_latest = yield from get_latest_iter()
102
- return _java_vanilla_latest
103
-
104
-
105
- def _remove_and_download(path: str, version: str) -> None:
106
- for _ in _remove_and_download_iter(path, version):
107
- pass
108
-
109
-
110
- def _remove_and_download_iter(path: str, version: str) -> Generator[float, None, None]:
111
- # try downloading the new resources to a temporary location
112
- temp_path = os.path.join(os.path.dirname(path), "_temp_")
113
- # clear the temporary location
114
- if os.path.isfile(temp_path):
115
- os.remove(temp_path)
116
- elif os.path.isdir(temp_path):
117
- shutil.rmtree(temp_path, ignore_errors=True)
118
-
119
- yield from download_resources_iter(temp_path, version)
120
- if os.path.isdir(path):
121
- shutil.rmtree(path, ignore_errors=True)
122
-
123
- shutil.move(temp_path, path)
124
-
125
- with open(os.path.join(path, "version"), "w") as f:
126
- f.write(version)
127
-
128
-
129
- def download_with_retry(
130
- url: str, chunk_size: int = 4096, attempts: int = 5
131
- ) -> Generator[float, None, bytes]:
132
- content_length_found = 0
133
- content = []
134
-
135
- for _ in range(attempts):
136
- request = Request(url, headers={"Range": f"bytes={content_length_found}-"})
137
- with urlopen(request, timeout=20) as response:
138
- content_length = int(response.headers["content-length"].strip())
139
- while content_length_found < content_length:
140
- chunk = response.read(chunk_size)
141
- if not chunk:
142
- break
143
- content.append(chunk)
144
- content_length_found += len(chunk)
145
- yield min(1.0, content_length_found / content_length)
146
- if content_length == content_length_found:
147
- break
148
- else:
149
- raise RuntimeError(f"Failed to download")
150
- return b"".join(content)
151
-
152
-
153
- def download_resources(path: str, version: str) -> None:
154
- generator_unpacker(download_resources_iter(path, version))
155
-
156
-
157
- def download_resources_iter(
158
- path: str, version: str, chunk_size: int = 4096
159
- ) -> Generator[float, None, None]:
160
- log.info(f"Downloading Java resource pack for version {version}")
161
- version_url = next(
162
- (v["url"] for v in get_launcher_manifest()["versions"] if v["id"] == version),
163
- None,
164
- )
165
- if version_url is None:
166
- raise Exception(f"Could not find Java resource pack for version {version}.")
167
-
168
- try:
169
- with urlopen(version_url, timeout=20) as vm:
170
- version_manifest = json.load(vm)
171
- version_client_url = version_manifest["downloads"]["client"]["url"]
172
-
173
- downloader = download_with_retry(version_client_url)
174
- try:
175
- while True:
176
- yield next(downloader) / 2
177
- except StopIteration as e:
178
- data = e.value
179
-
180
- client = zipfile.ZipFile(io.BytesIO(data))
181
- paths: list[str] = [
182
- fpath for fpath in client.namelist() if fpath.startswith("assets/")
183
- ]
184
- path_count = len(paths)
185
- for path_index, fpath in enumerate(paths):
186
- if not path_index % 30:
187
- yield path_index / (path_count * 2) + 0.5
188
- if fpath.endswith("/"):
189
- continue
190
- os.makedirs(
191
- os.path.dirname(os.path.abspath(os.path.join(path, fpath))),
192
- exist_ok=True,
193
- )
194
- client.extract(fpath, path)
195
- if "pack.mcmeta" in client.namelist():
196
- client.extract("pack.mcmeta", path)
197
- else:
198
- # TODO: work out proper version support for this
199
- with open(os.path.join(path, "pack.mcmeta"), "w") as f:
200
- f.write(
201
- '{"pack": {"description": "The default data for Minecraft","pack_format": 7}}'
202
- )
203
- if "pack.png" in client.namelist():
204
- client.extract("pack.png", path)
205
-
206
- except Exception as e:
207
- log.error(
208
- f"Failed to download and extract the Java resource pack for version {version}.",
209
- exc_info=True,
210
- )
211
- raise e
212
- log.info(f"Finished downloading Java resource pack for version {version}")
@@ -1,44 +0,0 @@
1
- import os
2
- import json
3
-
4
- from amulet.resource_pack.abc import BaseResourcePack
5
-
6
-
7
- class JavaResourcePack(BaseResourcePack):
8
- """A class to hold the bare bones information about the resource pack.
9
- Holds the pack format, description and if the pack is valid.
10
- This information can be used in a viewer to display the packs to the user."""
11
-
12
- def __init__(self, resource_pack_path: str):
13
- super().__init__(resource_pack_path)
14
- meta_path = os.path.join(resource_pack_path, "pack.mcmeta")
15
- self._pack_format = 0
16
- if os.path.isfile(meta_path):
17
- try:
18
- with open(meta_path) as f:
19
- pack_mcmeta = json.load(f)
20
- except json.JSONDecodeError:
21
- pass
22
- else:
23
- if "pack" in pack_mcmeta:
24
- if "description" in pack_mcmeta["pack"]:
25
- self._pack_description = str(pack_mcmeta["pack"]["description"])
26
- if "pack_format" in pack_mcmeta["pack"]:
27
- self._pack_format = pack_mcmeta["pack"]["pack_format"]
28
- self._valid_pack = True
29
-
30
- pack_icon_path = os.path.join(resource_pack_path, "pack.png")
31
- if os.path.isfile(pack_icon_path):
32
- self._pack_icon = pack_icon_path
33
-
34
- @staticmethod
35
- def is_valid(pack_path: str) -> bool:
36
- return os.path.isfile(os.path.join(pack_path, "pack.mcmeta"))
37
-
38
- def __repr__(self) -> str:
39
- return f"JavaResourcePack({self._root_dir})"
40
-
41
- @property
42
- def pack_format(self) -> int:
43
- """int - pack format number"""
44
- return self._pack_format