amulet-core 2.0a8__cp312-cp312-win_amd64.whl → 2.0.1a2.post250529084747__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.1a2.post250529084747.dist-info}/METADATA +25 -20
  40. amulet_core-2.0.1a2.post250529084747.dist-info/RECORD +45 -0
  41. {amulet_core-2.0a8.dist-info → amulet_core-2.0.1a2.post250529084747.dist-info}/WHEEL +1 -1
  42. amulet_core-2.0.1a2.post250529084747.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.1a2.post250529084747.dist-info}/top_level.txt +0 -0
@@ -1,40 +0,0 @@
1
- from typing import overload
2
- from collections.abc import Mapping, Iterator
3
-
4
-
5
- class IdRegistry(Mapping[int, tuple[str, str]]):
6
- def __init__(self) -> None:
7
- self._str_to_int: dict[tuple[str, str], int] = {}
8
- self._int_to_str: dict[int, tuple[str, str]] = {}
9
-
10
- def numerical_id_to_namespace_id(self, index: int) -> tuple[str, str]:
11
- return self._int_to_str[index]
12
-
13
- def namespace_id_to_numerical_id(self, namespace: str, base_name: str) -> int:
14
- return self._str_to_int[(namespace, base_name)]
15
-
16
- def register(self, index: int, block_id: tuple[str, str]) -> None:
17
- if block_id in self._str_to_int:
18
- raise RuntimeError(f"id {block_id} has already been registered")
19
- if index in self._int_to_str:
20
- raise RuntimeError(f"index {index} has already been registered")
21
- self._str_to_int[block_id] = index
22
- self._int_to_str[index] = block_id
23
-
24
- @overload
25
- def __getitem__(self, key: int) -> tuple[str, str]: ...
26
-
27
- @overload
28
- def __getitem__(self, key: tuple[str, str]) -> int: ...
29
-
30
- def __getitem__(self, key: int | tuple[str, str]) -> int | tuple[str, str]:
31
- if isinstance(key, int):
32
- return self._int_to_str[key]
33
- else:
34
- return self._str_to_int[key]
35
-
36
- def __len__(self) -> int:
37
- return len(self._int_to_str)
38
-
39
- def __iter__(self) -> Iterator[int]:
40
- yield from self._int_to_str
@@ -1,16 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from amulet.level.java._level import JavaLevel
4
-
5
- from . import (
6
- _chunk_handle,
7
- _dimension,
8
- _level,
9
- _raw,
10
- anvil,
11
- chunk,
12
- chunk_components,
13
- long_array,
14
- )
15
-
16
- __all__ = ["JavaLevel", "anvil", "chunk", "chunk_components", "long_array"]
@@ -1,17 +0,0 @@
1
- from __future__ import annotations
2
- from typing import TYPE_CHECKING
3
-
4
- from amulet.level.abc import ChunkHandle
5
- from ..abc._chunk_handle import ChunkT
6
- from .chunk import JavaChunk
7
-
8
- if TYPE_CHECKING:
9
- from ._level import JavaLevel
10
- from ._raw import JavaRawDimension
11
-
12
-
13
- class JavaChunkHandle(ChunkHandle["JavaLevel", "JavaRawDimension", JavaChunk]):
14
- @staticmethod
15
- def _validate_chunk(chunk: ChunkT) -> None:
16
- if not isinstance(chunk, JavaChunk):
17
- raise TypeError
@@ -1,20 +0,0 @@
1
- from typing import TYPE_CHECKING
2
-
3
- from amulet.level.abc import Dimension
4
- from ._chunk_handle import JavaChunkHandle
5
-
6
- if TYPE_CHECKING:
7
- from ._level import JavaLevel
8
- from ._raw import JavaRawDimension
9
-
10
-
11
- class JavaDimension(Dimension["JavaLevel", "JavaRawDimension", JavaChunkHandle]):
12
- def _create_chunk_handle(self, cx: int, cz: int) -> JavaChunkHandle:
13
- return JavaChunkHandle(
14
- self._l_ref,
15
- self._chunk_history,
16
- self._chunk_data_history,
17
- self.dimension_id,
18
- cx,
19
- cz,
20
- )
@@ -1,184 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from typing import Any, Type, Callable
4
- import os
5
- import logging
6
-
7
- from PIL import Image
8
- from amulet_nbt import (
9
- read_nbt,
10
- )
11
-
12
- from amulet.data_types import DimensionId
13
- from amulet.level.abc import (
14
- DiskLevel,
15
- CreatableLevel,
16
- LoadableLevel,
17
- CompactableLevel,
18
- LevelOpenData,
19
- PlayerStorage,
20
- )
21
- from amulet.utils.call_spec import (
22
- StringArg,
23
- IntArg,
24
- CallableArg,
25
- BoolArg,
26
- DirectoryPathArg,
27
- PositionalArgs,
28
- method_spec,
29
- )
30
- from amulet.utils.weakref import DetachableWeakRef
31
- from amulet.level import register_level_class
32
- from amulet.version import VersionNumber, PlatformType
33
-
34
- from ._dimension import JavaDimension
35
- from ._raw import JavaCreateArgsV1, JavaRawLevel, InternalDimensionId
36
- from amulet.chunk import Chunk
37
-
38
- log = logging.getLogger(__name__)
39
-
40
-
41
- class JavaLevelOpenData(LevelOpenData):
42
- back_reference: Callable[[], JavaLevel | None]
43
- detach_back_reference: Callable[[], None]
44
- dimensions: dict[DimensionId | InternalDimensionId, JavaDimension]
45
-
46
- def __init__(self, level: JavaLevel) -> None:
47
- super().__init__()
48
- self.back_reference, self.detach_back_reference = DetachableWeakRef.new(level)
49
- self.dimensions = {}
50
-
51
-
52
- class JavaLevel(
53
- DiskLevel[JavaLevelOpenData, JavaDimension, JavaRawLevel],
54
- CreatableLevel,
55
- LoadableLevel,
56
- CompactableLevel,
57
- ):
58
- __slots__ = ("_raw_level",)
59
-
60
- def __init__(self, _ikwiad: bool = False) -> None:
61
- if not _ikwiad:
62
- raise RuntimeError(
63
- "BedrockRawLevel must be constructed using the create or load classmethod."
64
- )
65
- super().__init__()
66
-
67
- def __init(self, raw: JavaRawLevel) -> None:
68
- self._raw_level = raw
69
- self._raw_level.opened.connect(self.open)
70
- self._raw_level.closed.connect(self.close)
71
-
72
- @classmethod
73
- @method_spec(
74
- CallableArg(
75
- JavaCreateArgsV1,
76
- BoolArg(True),
77
- DirectoryPathArg(),
78
- CallableArg(
79
- VersionNumber,
80
- PositionalArgs(IntArg(min_value=0), (IntArg(1), IntArg(20))),
81
- ),
82
- StringArg("New World"),
83
- )
84
- )
85
- def create(cls, args: JavaCreateArgsV1) -> JavaLevel:
86
- raw = JavaRawLevel.create(args)
87
- self = cls(True)
88
- self.__init(raw)
89
- return self
90
-
91
- @staticmethod
92
- def can_load(token: Any) -> bool:
93
- if (
94
- isinstance(token, str)
95
- and os.path.isdir(token)
96
- and os.path.isfile(os.path.join(token, "level.dat"))
97
- ):
98
- try:
99
- level_dat_root = read_nbt(os.path.join(token, "level.dat")).compound
100
- except Exception:
101
- pass
102
- else:
103
- return "Data" in level_dat_root and "FML" not in level_dat_root
104
- return False
105
-
106
- @classmethod
107
- def load(cls, path: str) -> JavaLevel:
108
- raw = JavaRawLevel.load(path)
109
- self = cls(True)
110
- self.__init(raw)
111
- return self
112
-
113
- def reload(self) -> None:
114
- self.raw.reload()
115
-
116
- def _open(self) -> None:
117
- self.raw.open()
118
- self._open_data = JavaLevelOpenData(self)
119
-
120
- def _close(self) -> None:
121
- self._o.detach_back_reference()
122
- self._open_data = None
123
- self.raw.close()
124
-
125
- def save(self) -> None:
126
- raise NotImplementedError
127
-
128
- @property
129
- def platform(self) -> PlatformType:
130
- return self.raw.platform
131
-
132
- @property
133
- def max_game_version(self) -> VersionNumber:
134
- return self.raw.data_version
135
-
136
- @property
137
- def level_name(self) -> str:
138
- return self.raw.level_name
139
-
140
- @property
141
- def modified_time(self) -> float:
142
- return self.raw.modified_time
143
-
144
- @property
145
- def path(self) -> str:
146
- return self.raw.path
147
-
148
- @property
149
- def thumbnail(self) -> Image.Image:
150
- try:
151
- return Image.open(os.path.join(self.path, "icon.png"))
152
- except Exception:
153
- return super().thumbnail
154
-
155
- def dimension_ids(self) -> frozenset[DimensionId]:
156
- return self.raw.dimension_ids()
157
-
158
- def get_dimension(
159
- self, dimension_id: DimensionId | InternalDimensionId
160
- ) -> JavaDimension:
161
- if dimension_id not in self._o.dimensions:
162
- raw_dimension = self.raw.get_dimension(dimension_id)
163
- self._o.dimensions[raw_dimension.dimension_id] = self._o.dimensions[
164
- raw_dimension.relative_path
165
- ] = JavaDimension(self._o.back_reference, raw_dimension.dimension_id)
166
- return self._o.dimensions[dimension_id]
167
-
168
- @property
169
- def player(self) -> PlayerStorage:
170
- raise NotImplementedError
171
-
172
- @property
173
- def native_chunk_class(self) -> Type[Chunk]:
174
- raise NotImplementedError
175
-
176
- @property
177
- def raw(self) -> JavaRawLevel:
178
- return self._raw_level
179
-
180
- def compact(self) -> None:
181
- self.raw.compact()
182
-
183
-
184
- register_level_class(JavaLevel)
@@ -1,15 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from builtins import str as InternalDimensionId
4
-
5
- from amulet.level.java._raw._dimension import JavaRawDimension
6
- from amulet.level.java._raw._level import JavaCreateArgsV1, JavaRawLevel
7
-
8
- from . import _chunk, _constant, _data_pack, _dimension, _level, _typing
9
-
10
- __all__ = [
11
- "InternalDimensionId",
12
- "JavaCreateArgsV1",
13
- "JavaRawDimension",
14
- "JavaRawLevel",
15
- ]
@@ -1,23 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import typing
4
-
5
- import amulet.level.java.chunk
6
- import amulet_nbt
7
-
8
- __all__ = ["decode_chunk", "encode_chunk"]
9
-
10
- def decode_chunk(
11
- arg0: typing.Any,
12
- arg1: typing.Any,
13
- arg2: dict[str, amulet_nbt.NamedTag],
14
- arg3: int,
15
- arg4: int,
16
- ) -> amulet.level.java.chunk.JavaChunk: ...
17
- def encode_chunk(
18
- arg0: typing.Any,
19
- arg1: typing.Any,
20
- arg2: amulet.level.java.chunk.JavaChunk,
21
- arg3: int,
22
- arg4: int,
23
- ) -> dict[str, amulet_nbt.NamedTag]: ...
@@ -1,9 +0,0 @@
1
- from amulet.selection import SelectionBox, SelectionGroup
2
-
3
- OVERWORLD = "minecraft:overworld"
4
- THE_NETHER = "minecraft:the_nether"
5
- THE_END = "minecraft:the_end"
6
-
7
- DefaultSelection = SelectionGroup(
8
- SelectionBox((-30_000_000, 0, -30_000_000), (30_000_000, 256, 30_000_000))
9
- )
@@ -1,2 +0,0 @@
1
- from .data_pack import DataPack
2
- from .data_pack_manager import DataPackManager
@@ -1,241 +0,0 @@
1
- from __future__ import annotations
2
- from abc import ABC, abstractmethod
3
- from typing import Iterable, Protocol
4
- from types import TracebackType
5
- import os
6
- import json
7
- from zipfile import ZipFile
8
- import re
9
-
10
-
11
- class Readable(Protocol):
12
- def read(self, n: int = -1) -> bytes: ...
13
-
14
- def __enter__(self) -> Readable: ...
15
-
16
- def __exit__(
17
- self,
18
- exc_type: type[BaseException] | None,
19
- exc_val: BaseException | None,
20
- exc_tb: TracebackType | None,
21
- ) -> None: ...
22
-
23
-
24
- class BaseWrapper(ABC):
25
- def __init__(self, path: str):
26
- self._path = path
27
-
28
- @staticmethod
29
- @abstractmethod
30
- def is_valid(path: str) -> bool:
31
- """
32
- Is the given path valid for this class.
33
-
34
- :param path: The path to test.
35
- """
36
-
37
- @property
38
- def path(self) -> str:
39
- """The path to the data."""
40
- return self._path
41
-
42
- @property
43
- @abstractmethod
44
- def all_files(self) -> Iterable[str]:
45
- """
46
- The relative paths of all files contained within.
47
-
48
- :return: An iterable of paths.
49
- """
50
- raise NotImplementedError
51
-
52
- def all_files_match(self, match: str) -> Iterable[str]:
53
- """
54
- The relative paths of all files contained within that match the given regex.
55
-
56
- :param match: The regex string to match again.
57
- :return: An iterable of file paths that match the given regex.
58
- """
59
- re_match = re.compile(match)
60
- return tuple(path for path in self.all_files if re_match.fullmatch(path))
61
-
62
- @abstractmethod
63
- def has_file(self, relative_path: str) -> bool:
64
- """
65
- Does the requested file exist.
66
-
67
- :param relative_path:
68
- :return:
69
- """
70
- raise NotImplementedError
71
-
72
- @abstractmethod
73
- def open(self, relative_path: str) -> Readable:
74
- """
75
- Get the contents of the file.
76
-
77
- :param relative_path:
78
- :return:
79
- """
80
- raise NotImplementedError
81
-
82
- @abstractmethod
83
- def close(self) -> None:
84
- """Close the contents."""
85
- raise NotImplementedError
86
-
87
-
88
- class ZipWrapper(BaseWrapper):
89
- def __init__(self, path: str):
90
- BaseWrapper.__init__(self, path)
91
- self._zip_file = ZipFile(path)
92
-
93
- @staticmethod
94
- def is_valid(path: str) -> bool:
95
- return os.path.isfile(path) and path.endswith(".zip")
96
-
97
- @property
98
- def all_files(self) -> Iterable[str]:
99
- for path in self._zip_file.NameToInfo:
100
- if not path.endswith("/"):
101
- yield path
102
-
103
- def has_file(self, relative_path: str) -> bool:
104
- if relative_path.endswith("/"):
105
- # is a directory
106
- return False
107
- else:
108
- return relative_path in self._zip_file.NameToInfo
109
-
110
- def open(self, name: str) -> Readable:
111
- return self._zip_file.open(name)
112
-
113
- def close(self) -> None:
114
- self._zip_file.close()
115
-
116
-
117
- class DirWrapper(BaseWrapper):
118
- def __init__(self, path: str):
119
- BaseWrapper.__init__(self, path)
120
-
121
- @staticmethod
122
- def is_valid(path: str) -> bool:
123
- return os.path.isdir(path)
124
-
125
- @property
126
- def all_files(self) -> Iterable[str]:
127
- for abs_path, _, files in os.walk(self.path):
128
- rel_path = os.path.normpath(os.path.relpath(abs_path, self.path)).replace(
129
- os.sep, "/"
130
- )
131
- if rel_path == ".":
132
- yield from files
133
- else:
134
- for f in files:
135
- yield f"{rel_path}/{f}"
136
-
137
- def has_file(self, relative_path: str) -> bool:
138
- return os.path.isfile(os.path.join(self.path, relative_path))
139
-
140
- def open(self, relative_path: str) -> Readable:
141
- return open(os.path.join(self.path, relative_path), "rb")
142
-
143
- def close(self) -> None:
144
- pass
145
-
146
-
147
- def _open_wrapper(path: str) -> BaseWrapper:
148
- for cls in (ZipWrapper, DirWrapper):
149
- if cls.is_valid(path):
150
- return cls(path)
151
- raise FileNotFoundError(f"The given path {path} is not valid.")
152
-
153
-
154
- class DataPack:
155
- """The DataPack class wraps a single data pack."""
156
-
157
- def __init__(self, path: str):
158
- self._path = path
159
- self._wrapper = _open_wrapper(path)
160
- self._is_valid = self.is_wrapper_valid(self._wrapper)
161
-
162
- @property
163
- def path(self) -> str:
164
- """The path to the data."""
165
- return self._path
166
-
167
- @staticmethod
168
- def is_path_valid(path: str) -> bool:
169
- """
170
- Check if the given path is a valid data pack.
171
-
172
- :param path: The path to the data pack. Can be a zip file or directory.
173
- :return: True if the path is a valid data pack, False otherwise.
174
- """
175
- try:
176
- wrapper = _open_wrapper(path)
177
- except FileNotFoundError:
178
- return False
179
- is_valid = DataPack.is_wrapper_valid(wrapper)
180
- wrapper.close()
181
- return is_valid
182
-
183
- @property
184
- def is_valid(self) -> bool:
185
- return self._is_valid
186
-
187
- @staticmethod
188
- def is_wrapper_valid(wrapper: BaseWrapper) -> bool:
189
- if wrapper.has_file("pack.mcmeta"):
190
- with wrapper.open("pack.mcmeta") as m:
191
- try:
192
- meta_file = json.load(m)
193
- except json.JSONDecodeError:
194
- pass
195
- else:
196
- if isinstance(meta_file, dict) and isinstance(
197
- meta_file.get("pack", {}).get("pack_format", None), int
198
- ):
199
- # TODO: check the actual value
200
- return True
201
- return False
202
-
203
- @property
204
- def all_files(self) -> Iterable[str]:
205
- """
206
- The relative paths of all files contained within.
207
-
208
- :return: An iterable of paths.
209
- """
210
- return self._wrapper.all_files
211
-
212
- def all_files_match(self, match: str) -> Iterable[str]:
213
- """
214
- The relative paths of all files contained within that match the given regex.
215
-
216
- :param match: The regex string to match again.
217
- :return: An iterable of file paths that match the given regex.
218
- """
219
- return self._wrapper.all_files_match(match)
220
-
221
- def has_file(self, relative_path: str) -> bool:
222
- """
223
- Does the requested file exist.
224
-
225
- :param relative_path:
226
- :return:
227
- """
228
- return self._wrapper.has_file(relative_path)
229
-
230
- def open(self, relative_path: str) -> Readable:
231
- """
232
- Get the contents of the file.
233
-
234
- :param relative_path:
235
- :return:
236
- """
237
- return self._wrapper.open(relative_path)
238
-
239
- def close(self) -> None:
240
- """Close the contents."""
241
- self._wrapper.close()
@@ -1,77 +0,0 @@
1
- from typing import Iterable
2
- from .data_pack import DataPack, Readable
3
-
4
-
5
- class DataPackManager:
6
- """
7
- The DataPackManager class contains one or more data packs.
8
- It manages loading them so that the stacking order is maintained.
9
- """
10
-
11
- def __init__(self, data_packs: Iterable[DataPack]):
12
- """
13
- Construct a new DataPackManager class.
14
-
15
- :param data_packs: The data packs to load from. Later in the list get higher priority.
16
- """
17
- self._data_packs = tuple(
18
- reversed(
19
- tuple(
20
- pack
21
- for pack in data_packs
22
- if isinstance(pack, DataPack) and pack.is_valid
23
- )
24
- )
25
- )
26
-
27
- @property
28
- def all_files(self) -> Iterable[str]:
29
- """
30
- The relative paths of all files contained within.
31
-
32
- :return: An iterable of paths.
33
- """
34
- all_files: set[str] = set()
35
- for pack in self._data_packs:
36
- all_files.update(pack.all_files)
37
- return all_files
38
-
39
- def all_files_match(self, match: str) -> Iterable[str]:
40
- """
41
- The relative paths of all files contained within that match the given regex.
42
-
43
- :param match: The regex string to match again.
44
- :return: An iterable of file paths that match the given regex.
45
- """
46
- all_files: set[str] = set()
47
- for pack in self._data_packs:
48
- all_files.update(pack.all_files_match(match))
49
- return all_files
50
-
51
- def has_file(self, relative_path: str) -> bool:
52
- """
53
- Does the requested file exist.
54
-
55
- :param relative_path:
56
- :return:
57
- """
58
- return any(pack.has_file(relative_path) for pack in self._data_packs)
59
-
60
- def open(self, relative_path: str) -> Readable:
61
- """
62
- Get the contents of the file.
63
-
64
- :param relative_path:
65
- :return:
66
- """
67
- for pack in self._data_packs:
68
- if pack.has_file(relative_path):
69
- return pack.open(relative_path)
70
- raise FileNotFoundError(
71
- f"The requested path {relative_path} could not be found."
72
- )
73
-
74
- def close(self) -> None:
75
- """Close the contents."""
76
- for pack in self._data_packs:
77
- pack.close()