amulet-core 2.0a8__cp311-cp311-win_amd64.whl → 2.0.1.0.1297307203.19.43.34808.0a1__cp311-cp311-win_amd64.whl

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

Potentially problematic release.


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

Files changed (271) hide show
  1. amulet/core/__init__.py +36 -0
  2. amulet/core/__pyinstaller/hook-amulet.core.py +4 -0
  3. amulet/core/_amulet_core.cp311-win_amd64.pyd +0 -0
  4. amulet/core/_amulet_core.pyi +7 -0
  5. amulet/{_version.py → core/_version.py} +3 -3
  6. amulet/core/amulet_core.dll +0 -0
  7. amulet/core/amulet_core.lib +0 -0
  8. amulet/core/amulet_coreConfig.cmake +18 -0
  9. amulet/{biome.pyi → core/biome/__init__.pyi} +3 -3
  10. amulet/core/biome/biome.hpp +53 -0
  11. amulet/{block.pyi → core/block/__init__.pyi} +25 -26
  12. amulet/core/block/block.hpp +156 -0
  13. amulet/{block_entity.pyi → core/block_entity/__init__.pyi} +7 -7
  14. amulet/core/block_entity/block_entity.hpp +84 -0
  15. amulet/{errors.py → core/chunk/__init__.pyi} +37 -33
  16. amulet/core/chunk/chunk.hpp +126 -0
  17. amulet/core/chunk/component/__init__.pyi +18 -0
  18. amulet/core/chunk/component/biome_3d_component.hpp +96 -0
  19. amulet/core/chunk/component/block_component.hpp +101 -0
  20. amulet/core/chunk/component/block_component.pyi +28 -0
  21. amulet/core/chunk/component/block_entity_component.hpp +119 -0
  22. amulet/core/chunk/component/section_array_map.hpp +129 -0
  23. amulet/{chunk_components.pyi → core/chunk/component/section_array_map.pyi} +4 -24
  24. amulet/core/dll.hpp +21 -0
  25. amulet/core/entity/__init__.pyi +105 -0
  26. amulet/core/entity/entity.hpp +100 -0
  27. amulet/{palette → core/palette}/__init__.pyi +2 -2
  28. amulet/core/palette/biome_palette.hpp +65 -0
  29. amulet/{palette → core/palette}/biome_palette.pyi +8 -8
  30. amulet/core/palette/block_palette.hpp +71 -0
  31. amulet/{palette → core/palette}/block_palette.pyi +12 -10
  32. amulet/core/selection/__init__.pyi +8 -0
  33. amulet/core/selection/box.hpp +86 -0
  34. amulet/core/selection/box.pyi +215 -0
  35. amulet/core/selection/group.hpp +80 -0
  36. amulet/core/selection/group.pyi +213 -0
  37. amulet/{version.pyi → core/version/__init__.pyi} +58 -10
  38. amulet/core/version/version.hpp +204 -0
  39. {amulet_core-2.0a8.dist-info → amulet_core-2.0.1.0.1297307203.19.43.34808.0a1.dist-info}/METADATA +25 -20
  40. amulet_core-2.0.1.0.1297307203.19.43.34808.0a1.dist-info/RECORD +45 -0
  41. {amulet_core-2.0a8.dist-info → amulet_core-2.0.1.0.1297307203.19.43.34808.0a1.dist-info}/WHEEL +1 -1
  42. amulet_core-2.0.1.0.1297307203.19.43.34808.0a1.dist-info/entry_points.txt +2 -0
  43. amulet/__init__.cp311-win_amd64.pyd +0 -0
  44. amulet/__init__.py.cpp +0 -45
  45. amulet/__init__.pyi +0 -30
  46. amulet/__pyinstaller/hook-amulet.py +0 -4
  47. amulet/_init.py +0 -26
  48. amulet/biome.cpp +0 -36
  49. amulet/biome.hpp +0 -43
  50. amulet/biome.py.cpp +0 -122
  51. amulet/block.cpp +0 -435
  52. amulet/block.hpp +0 -119
  53. amulet/block.py.cpp +0 -377
  54. amulet/block_entity.cpp +0 -12
  55. amulet/block_entity.hpp +0 -56
  56. amulet/block_entity.py.cpp +0 -115
  57. amulet/chunk.cpp +0 -16
  58. amulet/chunk.hpp +0 -100
  59. amulet/chunk.py.cpp +0 -80
  60. amulet/chunk.pyi +0 -28
  61. amulet/chunk_components/biome_3d_component.cpp +0 -5
  62. amulet/chunk_components/biome_3d_component.hpp +0 -79
  63. amulet/chunk_components/block_component.cpp +0 -41
  64. amulet/chunk_components/block_component.hpp +0 -88
  65. amulet/chunk_components/block_entity_component.cpp +0 -5
  66. amulet/chunk_components/block_entity_component.hpp +0 -147
  67. amulet/chunk_components/section_array_map.cpp +0 -129
  68. amulet/chunk_components/section_array_map.hpp +0 -147
  69. amulet/collections/eq.py.hpp +0 -37
  70. amulet/collections/hash.py.hpp +0 -27
  71. amulet/collections/holder.py.hpp +0 -37
  72. amulet/collections/iterator.py.hpp +0 -80
  73. amulet/collections/mapping.py.hpp +0 -199
  74. amulet/collections/mutable_mapping.py.hpp +0 -226
  75. amulet/collections/sequence.py.hpp +0 -163
  76. amulet/collections.pyi +0 -40
  77. amulet/data_types.py +0 -29
  78. amulet/entity.py +0 -182
  79. amulet/game/__init__.py +0 -7
  80. amulet/game/_game.py +0 -152
  81. amulet/game/_universal/__init__.py +0 -1
  82. amulet/game/_universal/_biome.py +0 -17
  83. amulet/game/_universal/_block.py +0 -47
  84. amulet/game/_universal/_version.py +0 -68
  85. amulet/game/abc/__init__.py +0 -22
  86. amulet/game/abc/_block_specification.py +0 -150
  87. amulet/game/abc/biome.py +0 -213
  88. amulet/game/abc/block.py +0 -331
  89. amulet/game/abc/game_version_container.py +0 -25
  90. amulet/game/abc/json_interface.py +0 -27
  91. amulet/game/abc/version.py +0 -44
  92. amulet/game/bedrock/__init__.py +0 -1
  93. amulet/game/bedrock/_biome.py +0 -35
  94. amulet/game/bedrock/_block.py +0 -42
  95. amulet/game/bedrock/_version.py +0 -165
  96. amulet/game/java/__init__.py +0 -2
  97. amulet/game/java/_biome.py +0 -35
  98. amulet/game/java/_block.py +0 -60
  99. amulet/game/java/_version.py +0 -176
  100. amulet/game/translate/__init__.py +0 -12
  101. amulet/game/translate/_functions/__init__.py +0 -15
  102. amulet/game/translate/_functions/_code_functions/__init__.py +0 -0
  103. amulet/game/translate/_functions/_code_functions/_text.py +0 -553
  104. amulet/game/translate/_functions/_code_functions/banner_pattern.py +0 -67
  105. amulet/game/translate/_functions/_code_functions/bedrock_chest_connection.py +0 -152
  106. amulet/game/translate/_functions/_code_functions/bedrock_moving_block_pos.py +0 -88
  107. amulet/game/translate/_functions/_code_functions/bedrock_sign.py +0 -152
  108. amulet/game/translate/_functions/_code_functions/bedrock_skull_rotation.py +0 -16
  109. amulet/game/translate/_functions/_code_functions/custom_name.py +0 -146
  110. amulet/game/translate/_functions/_frozen.py +0 -66
  111. amulet/game/translate/_functions/_state.py +0 -54
  112. amulet/game/translate/_functions/_typing.py +0 -98
  113. amulet/game/translate/_functions/abc.py +0 -123
  114. amulet/game/translate/_functions/carry_nbt.py +0 -160
  115. amulet/game/translate/_functions/carry_properties.py +0 -80
  116. amulet/game/translate/_functions/code.py +0 -143
  117. amulet/game/translate/_functions/map_block_name.py +0 -66
  118. amulet/game/translate/_functions/map_nbt.py +0 -111
  119. amulet/game/translate/_functions/map_properties.py +0 -93
  120. amulet/game/translate/_functions/multiblock.py +0 -112
  121. amulet/game/translate/_functions/new_block.py +0 -42
  122. amulet/game/translate/_functions/new_entity.py +0 -43
  123. amulet/game/translate/_functions/new_nbt.py +0 -206
  124. amulet/game/translate/_functions/new_properties.py +0 -64
  125. amulet/game/translate/_functions/sequence.py +0 -51
  126. amulet/game/translate/_functions/walk_input_nbt.py +0 -331
  127. amulet/game/translate/_translator.py +0 -433
  128. amulet/img/__init__.py +0 -10
  129. amulet/img/missing_no.png +0 -0
  130. amulet/img/missing_pack.png +0 -0
  131. amulet/img/missing_world.png +0 -0
  132. amulet/io/binary_reader.hpp +0 -45
  133. amulet/io/binary_writer.hpp +0 -30
  134. amulet/item.py +0 -75
  135. amulet/level/__init__.pyi +0 -23
  136. amulet/level/_load.py +0 -100
  137. amulet/level/abc/__init__.py +0 -12
  138. amulet/level/abc/_chunk_handle.py +0 -358
  139. amulet/level/abc/_dimension.py +0 -86
  140. amulet/level/abc/_history/__init__.py +0 -1
  141. amulet/level/abc/_history/_cache.py +0 -224
  142. amulet/level/abc/_history/_history_manager.py +0 -291
  143. amulet/level/abc/_level/__init__.py +0 -5
  144. amulet/level/abc/_level/_compactable_level.py +0 -10
  145. amulet/level/abc/_level/_creatable_level.py +0 -28
  146. amulet/level/abc/_level/_disk_level.py +0 -17
  147. amulet/level/abc/_level/_level.py +0 -449
  148. amulet/level/abc/_level/_loadable_level.py +0 -42
  149. amulet/level/abc/_player_storage.py +0 -7
  150. amulet/level/abc/_raw_level.py +0 -187
  151. amulet/level/abc/_registry.py +0 -40
  152. amulet/level/java/__init__.pyi +0 -16
  153. amulet/level/java/_chunk_handle.py +0 -17
  154. amulet/level/java/_dimension.py +0 -20
  155. amulet/level/java/_level.py +0 -184
  156. amulet/level/java/_raw/__init__.pyi +0 -15
  157. amulet/level/java/_raw/_chunk.pyi +0 -23
  158. amulet/level/java/_raw/_constant.py +0 -9
  159. amulet/level/java/_raw/_data_pack/__init__.py +0 -2
  160. amulet/level/java/_raw/_data_pack/data_pack.py +0 -241
  161. amulet/level/java/_raw/_data_pack/data_pack_manager.py +0 -77
  162. amulet/level/java/_raw/_dimension.py +0 -86
  163. amulet/level/java/_raw/_level.py +0 -507
  164. amulet/level/java/_raw/_typing.py +0 -3
  165. amulet/level/java/_raw/java_chunk_decode.cpp +0 -531
  166. amulet/level/java/_raw/java_chunk_decode.hpp +0 -23
  167. amulet/level/java/_raw/java_chunk_encode.cpp +0 -25
  168. amulet/level/java/_raw/java_chunk_encode.hpp +0 -23
  169. amulet/level/java/anvil/__init__.py +0 -2
  170. amulet/level/java/anvil/_dimension.py +0 -170
  171. amulet/level/java/anvil/_region.py +0 -421
  172. amulet/level/java/anvil/_sector_manager.py +0 -223
  173. amulet/level/java/chunk.pyi +0 -81
  174. amulet/level/java/chunk_/_chunk.py +0 -260
  175. amulet/level/java/chunk_/components/inhabited_time.py +0 -12
  176. amulet/level/java/chunk_/components/last_update.py +0 -12
  177. amulet/level/java/chunk_/components/legacy_version.py +0 -12
  178. amulet/level/java/chunk_/components/light_populated.py +0 -12
  179. amulet/level/java/chunk_/components/named_height_2d.py +0 -37
  180. amulet/level/java/chunk_/components/status.py +0 -11
  181. amulet/level/java/chunk_/components/terrain_populated.py +0 -12
  182. amulet/level/java/chunk_components/data_version_component.cpp +0 -32
  183. amulet/level/java/chunk_components/data_version_component.hpp +0 -31
  184. amulet/level/java/chunk_components/java_raw_chunk_component.cpp +0 -56
  185. amulet/level/java/chunk_components/java_raw_chunk_component.hpp +0 -45
  186. amulet/level/java/chunk_components.pyi +0 -22
  187. amulet/level/java/java_chunk.cpp +0 -170
  188. amulet/level/java/java_chunk.hpp +0 -141
  189. amulet/level/java/long_array.hpp +0 -175
  190. amulet/level/java/long_array.pyi +0 -39
  191. amulet/level/temporary_level/__init__.py +0 -1
  192. amulet/level/temporary_level/_level.py +0 -16
  193. amulet/mesh/__init__.py +0 -0
  194. amulet/mesh/block/__init__.pyi +0 -301
  195. amulet/mesh/block/_cube.py +0 -198
  196. amulet/mesh/block/_missing_block.py +0 -20
  197. amulet/mesh/block/block_mesh.cpp +0 -107
  198. amulet/mesh/block/block_mesh.hpp +0 -207
  199. amulet/mesh/util.py +0 -17
  200. amulet/palette/biome_palette.hpp +0 -85
  201. amulet/palette/block_palette.cpp +0 -32
  202. amulet/palette/block_palette.hpp +0 -93
  203. amulet/player.py +0 -62
  204. amulet/pybind11/collections.hpp +0 -118
  205. amulet/pybind11/numpy.hpp +0 -26
  206. amulet/pybind11/py_module.hpp +0 -34
  207. amulet/pybind11/type_hints.hpp +0 -51
  208. amulet/pybind11/types.hpp +0 -25
  209. amulet/pybind11/typing.hpp +0 -7
  210. amulet/resource_pack/__init__.py +0 -63
  211. amulet/resource_pack/abc/__init__.py +0 -2
  212. amulet/resource_pack/abc/resource_pack.py +0 -38
  213. amulet/resource_pack/abc/resource_pack_manager.py +0 -85
  214. amulet/resource_pack/java/__init__.py +0 -2
  215. amulet/resource_pack/java/download_resources.py +0 -212
  216. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_black.png +0 -0
  217. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_blue.png +0 -0
  218. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_brown.png +0 -0
  219. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_cyan.png +0 -0
  220. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_gray.png +0 -0
  221. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_green.png +0 -0
  222. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_light_blue.png +0 -0
  223. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_light_gray.png +0 -0
  224. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_lime.png +0 -0
  225. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_magenta.png +0 -0
  226. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_orange.png +0 -0
  227. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_pink.png +0 -0
  228. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_purple.png +0 -0
  229. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_red.png +0 -0
  230. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_white.png +0 -0
  231. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_yellow.png +0 -0
  232. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/barrier.png +0 -0
  233. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/end_portal.png +0 -0
  234. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/grass.png +0 -0
  235. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/lava.png +0 -0
  236. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/structure_void.png +0 -0
  237. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/water.png +0 -0
  238. amulet/resource_pack/java/java_vanilla_fix/pack.png +0 -0
  239. amulet/resource_pack/java/resource_pack.py +0 -44
  240. amulet/resource_pack/java/resource_pack_manager.py +0 -563
  241. amulet/resource_pack/unknown_resource_pack.py +0 -10
  242. amulet/selection/__init__.py +0 -2
  243. amulet/selection/abstract_selection.py +0 -342
  244. amulet/selection/box.py +0 -852
  245. amulet/selection/group.py +0 -481
  246. amulet/utils/__init__.pyi +0 -23
  247. amulet/utils/call_spec/__init__.py +0 -24
  248. amulet/utils/call_spec/_call_spec.py +0 -257
  249. amulet/utils/cast.py +0 -10
  250. amulet/utils/comment_json.py +0 -188
  251. amulet/utils/format_utils.py +0 -41
  252. amulet/utils/generator.py +0 -18
  253. amulet/utils/matrix.py +0 -243
  254. amulet/utils/numpy.hpp +0 -36
  255. amulet/utils/numpy.pyi +0 -11
  256. amulet/utils/numpy_helpers.py +0 -19
  257. amulet/utils/shareable_lock.py +0 -335
  258. amulet/utils/signal/__init__.py +0 -10
  259. amulet/utils/signal/_signal.py +0 -228
  260. amulet/utils/task_manager.py +0 -235
  261. amulet/utils/typed_property.py +0 -111
  262. amulet/utils/weakref.py +0 -70
  263. amulet/utils/world_utils.py +0 -102
  264. amulet/version.cpp +0 -136
  265. amulet/version.hpp +0 -142
  266. amulet/version.py.cpp +0 -281
  267. amulet_core-2.0a8.dist-info/RECORD +0 -241
  268. amulet_core-2.0a8.dist-info/entry_points.txt +0 -2
  269. /amulet/{__pyinstaller → core/__pyinstaller}/__init__.py +0 -0
  270. /amulet/{py.typed → core/py.typed} +0 -0
  271. {amulet_core-2.0a8.dist-info → amulet_core-2.0.1.0.1297307203.19.43.34808.0a1.dist-info}/top_level.txt +0 -0
amulet/game/_game.py DELETED
@@ -1,152 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import traceback
4
- from functools import cache
5
- from typing import overload, Literal, TYPE_CHECKING
6
- from collections.abc import Sequence
7
- from threading import RLock
8
- import pickle
9
- import os
10
- import glob
11
- import json
12
- import gzip
13
-
14
- from amulet.version import VersionNumber
15
-
16
-
17
- if TYPE_CHECKING:
18
- from .abc import GameVersion
19
- from ._universal import UniversalVersion
20
- from .java import JavaGameVersion
21
- from .bedrock import BedrockGameVersion
22
-
23
-
24
- _versions: dict[str, list[GameVersion]] | None = None
25
- _lock = RLock()
26
-
27
-
28
- def _compile_raw_versions() -> None:
29
- global _versions
30
- with _lock:
31
- json_path = os.environ.get("AMULET_GAME_VERSION_JSON_PATH")
32
- if json_path is None:
33
- raise RuntimeError("Could not find game version data.")
34
- from .java import JavaGameVersion
35
- from .bedrock import BedrockGameVersion
36
- from ._universal import UniversalVersion
37
-
38
- _versions = {}
39
- _versions.setdefault("universal", []).append(
40
- UniversalVersion.from_json(os.path.join(json_path, "versions", "universal"))
41
- )
42
- for init_path in glob.glob(
43
- os.path.join(glob.escape(json_path), "versions", "*", "__init__.json")
44
- ):
45
- version_path = os.path.dirname(init_path)
46
-
47
- with open(os.path.join(version_path, "__init__.json")) as f:
48
- init = json.load(f)
49
-
50
- platform = init["platform"]
51
- if platform == "bedrock":
52
- _versions.setdefault("bedrock", []).append(
53
- BedrockGameVersion.from_json(version_path)
54
- )
55
- elif platform == "java":
56
- _versions.setdefault("java", []).append(
57
- JavaGameVersion.from_json(version_path)
58
- )
59
- elif platform == "universal":
60
- pass
61
- else:
62
- raise RuntimeError
63
- with open(
64
- os.path.join(os.path.dirname(__file__), "versions.pkl.gz"), "wb"
65
- ) as pkl:
66
- pkl.write(gzip.compress(pickle.dumps(_versions)))
67
-
68
-
69
- def _get_versions() -> dict[str, list[GameVersion]]:
70
- global _versions
71
- with _lock:
72
- if _versions is None:
73
- pkl_path = os.path.join(os.path.dirname(__file__), "versions.pkl.gz")
74
- if os.path.isfile(pkl_path):
75
- try:
76
- with open(pkl_path, "rb") as pkl:
77
- _versions = pickle.loads(gzip.decompress(pkl.read()))
78
- except:
79
- traceback.print_exc()
80
-
81
- if _versions is None:
82
- _compile_raw_versions()
83
-
84
- assert _versions is not None
85
- return _versions
86
-
87
-
88
- def game_platforms() -> list[str]:
89
- """
90
- Get a list of all the platforms there are Version classes for.
91
- These are currently 'java' and 'bedrock'
92
- """
93
- return list(_get_versions().keys())
94
-
95
-
96
- @overload
97
- def game_versions(platform: Literal["java"]) -> Sequence[JavaGameVersion]: ...
98
-
99
-
100
- @overload
101
- def game_versions(platform: Literal["bedrock"]) -> Sequence[BedrockGameVersion]: ...
102
-
103
-
104
- @overload
105
- def game_versions(platform: str) -> Sequence[GameVersion]: ...
106
-
107
-
108
- def game_versions(platform: str) -> Sequence[GameVersion]:
109
- """
110
- Get all known version classes for the platform.
111
-
112
- :param platform: The platform name (use :attr:`platforms` to get the valid platforms)
113
- :return: The version classes for the platform
114
- :raises KeyError: If the platform is not present.
115
- """
116
- if platform not in _get_versions():
117
- raise KeyError(f'The requested platform "{platform}" is not present')
118
- return tuple(_get_versions()[platform])
119
-
120
-
121
- @overload
122
- def get_game_version(
123
- platform: Literal["java"], version_number: VersionNumber
124
- ) -> JavaGameVersion: ...
125
-
126
-
127
- @overload
128
- def get_game_version(
129
- platform: Literal["bedrock"], version_number: VersionNumber
130
- ) -> BedrockGameVersion: ...
131
-
132
-
133
- @overload
134
- def get_game_version(platform: str, version_number: VersionNumber) -> GameVersion: ...
135
-
136
-
137
- @cache # type: ignore
138
- def get_game_version(platform: str, version_number: VersionNumber) -> GameVersion:
139
- """
140
- Get a Version class for the requested platform and version number
141
-
142
- :param platform: The platform name (use ``TranslationManager.platforms`` to get the valid platforms)
143
- :param version_number: The version number or DataVersion (use ``TranslationManager.version_numbers`` to get version numbers for a given platforms)
144
- :return: The Version class for the given inputs.
145
- :raises KeyError: If it does not exist.
146
- """
147
- if platform not in _get_versions():
148
- raise KeyError(f'The requested platform "{platform}" is not present')
149
- for version in _get_versions()[platform]:
150
- if version.supports_version(platform, version_number):
151
- return version
152
- raise KeyError(f"Version {platform}, {version_number} is not supported")
@@ -1 +0,0 @@
1
- from ._version import UniversalVersion
@@ -1,17 +0,0 @@
1
- from amulet.biome import Biome
2
- from amulet.game.abc import BiomeData
3
- from amulet.version import VersionNumber
4
-
5
-
6
- class UniversalBiomeData(BiomeData):
7
- def to_universal(self, biome: Biome) -> Biome:
8
- if not self._game_version.supports_version(biome.platform, biome.version):
9
- raise ValueError("The block is not compatible with this version")
10
- return biome
11
-
12
- def from_universal(
13
- self, target_platform: str, target_version: VersionNumber, biome: Biome
14
- ) -> Biome:
15
- if not self._game_version.supports_version(biome.platform, biome.version):
16
- raise ValueError("The block is not compatible with this version")
17
- return biome
@@ -1,47 +0,0 @@
1
- from typing import Callable
2
-
3
- from amulet.data_types import BlockCoordinates
4
- from amulet.block import Block
5
- from amulet.block_entity import BlockEntity
6
- from amulet.entity import Entity
7
-
8
- from amulet.game.abc import BlockData
9
- from amulet.version import VersionNumber
10
-
11
-
12
- class UniversalBlockData(BlockData):
13
- def to_universal(
14
- self,
15
- block: Block,
16
- block_entity: BlockEntity | None,
17
- extra: (
18
- tuple[
19
- BlockCoordinates,
20
- Callable[[BlockCoordinates], tuple[Block, BlockEntity | None]],
21
- ]
22
- | None
23
- ),
24
- ) -> tuple[Block, BlockEntity | None, bool]:
25
- # Converting universal to universal so just return as is
26
- if not self._game_version.supports_version(block.platform, block.version):
27
- raise ValueError("The block is not compatible with this version")
28
- return block, block_entity, False
29
-
30
- def from_universal(
31
- self,
32
- target_platform: str,
33
- target_version: VersionNumber,
34
- block: Block,
35
- block_entity: BlockEntity | None,
36
- extra: (
37
- tuple[
38
- BlockCoordinates,
39
- Callable[[BlockCoordinates], tuple[Block, BlockEntity | None]],
40
- ]
41
- | None
42
- ),
43
- ) -> tuple[Block, BlockEntity | None, bool] | tuple[Entity, None, bool]:
44
- # Converting universal to universal so just return as is
45
- if not self._game_version.supports_version(block.platform, block.version):
46
- raise ValueError("The block is not compatible with this version")
47
- return block, block_entity, False
@@ -1,68 +0,0 @@
1
- from __future__ import annotations
2
- from typing import Self
3
- import os
4
- import json
5
-
6
- from amulet.game.abc import GameVersion, load_json_block_spec, load_json_biome_data
7
- from amulet.version import VersionNumber
8
-
9
- from ._block import UniversalBlockData
10
- from ._biome import UniversalBiomeData
11
-
12
-
13
- class UniversalVersion(GameVersion):
14
- _block: UniversalBlockData
15
- _biome: UniversalBiomeData
16
-
17
- @classmethod
18
- def from_json(cls, version_path: str) -> Self:
19
- with open(os.path.join(version_path, "__init__.json")) as f:
20
- init = json.load(f)
21
- assert init["platform"] == "universal"
22
-
23
- block_format = init["block_format"]
24
-
25
- self = cls()
26
-
27
- # Load the block specification and translations
28
- block_spec = load_json_block_spec(version_path, block_format)
29
-
30
- self._block = UniversalBlockData(
31
- self,
32
- block_spec,
33
- )
34
-
35
- biomes, _, _ = load_json_biome_data(version_path)
36
- biomes_namespace = dict[str, list[str]]()
37
- for namespace, base_name in biomes:
38
- biomes_namespace.setdefault(namespace, []).append(base_name)
39
-
40
- self._biome = UniversalBiomeData(self, biomes_namespace)
41
-
42
- return self
43
-
44
- def __repr__(self) -> str:
45
- return f"UniversalVersion()"
46
-
47
- def supports_version(self, platform: str, version: VersionNumber) -> bool:
48
- return platform == "universal"
49
-
50
- @property
51
- def platform(self) -> str:
52
- return "universal"
53
-
54
- @property
55
- def min_version(self) -> VersionNumber:
56
- return VersionNumber(1)
57
-
58
- @property
59
- def max_version(self) -> VersionNumber:
60
- return VersionNumber(1)
61
-
62
- @property
63
- def block(self) -> UniversalBlockData:
64
- return self._block
65
-
66
- @property
67
- def biome(self) -> UniversalBiomeData:
68
- return self._biome
@@ -1,22 +0,0 @@
1
- from .json_interface import JSONInterface, JSONCompatible, JSONDict, JSONList
2
- from .version import GameVersion
3
- from .block import (
4
- BlockData,
5
- DatabaseBlockData,
6
- BlockDataNumericalComponent,
7
- BlockTranslationError,
8
- )
9
- from .biome import (
10
- BiomeData,
11
- DatabaseBiomeData,
12
- BiomeDataNumericalComponent,
13
- BiomeTranslationError,
14
- load_json_biome_data,
15
- )
16
- from ._block_specification import (
17
- BlockSpec,
18
- NBTSpec,
19
- PropertySpec,
20
- PropertyValueSpec,
21
- load_json_block_spec,
22
- )
@@ -1,150 +0,0 @@
1
- from typing import Self
2
- from types import MappingProxyType
3
- from collections.abc import Mapping, Iterator, Hashable
4
- from dataclasses import dataclass, field
5
- import os
6
- import json
7
- import glob
8
- from concurrent.futures import ThreadPoolExecutor
9
-
10
- from amulet_nbt import read_snbt
11
- from amulet.block import PropertyValueType
12
-
13
- from .json_interface import JSONInterface, JSONDict, JSONCompatible
14
-
15
-
16
- def immutable_from_snbt(snbt: str) -> PropertyValueType:
17
- val = read_snbt(snbt)
18
- assert isinstance(val, PropertyValueType)
19
- return val
20
-
21
-
22
- @dataclass(frozen=True)
23
- class PropertyValueSpec:
24
- default: PropertyValueType
25
- states: tuple[PropertyValueType, ...]
26
-
27
-
28
- class PropertySpec(Mapping[str, PropertyValueSpec], Hashable):
29
- _properties: Mapping[str, PropertyValueSpec]
30
- _hash: int | None
31
-
32
- def __init__(
33
- self, properties: Mapping[str, PropertyValueSpec] = MappingProxyType({})
34
- ):
35
- self._properties = dict(properties)
36
- self._hash = None
37
-
38
- def __getitem__(self, name: str) -> PropertyValueSpec:
39
- return self._properties[name]
40
-
41
- def __len__(self) -> int:
42
- return len(self._properties)
43
-
44
- def __iter__(self) -> Iterator[str]:
45
- yield from self._properties
46
-
47
- def __hash__(self) -> int:
48
- if self._hash is None:
49
- self._hash = hash(frozenset(self._properties.items()))
50
- return self._hash
51
-
52
-
53
- @dataclass(frozen=True)
54
- class NBTSpec:
55
- namespace: str
56
- base_name: str
57
- snbt: str
58
-
59
-
60
- @dataclass(frozen=True)
61
- class BlockSpec(JSONInterface):
62
- properties: PropertySpec = field(default_factory=PropertySpec)
63
- nbt: NBTSpec | None = None
64
-
65
- @classmethod
66
- def from_json(cls, obj: JSONCompatible) -> Self:
67
- assert isinstance(obj, dict)
68
- properties = obj.get("properties", {})
69
- default_properties = obj.get("defaults", {})
70
- assert isinstance(properties, dict) and isinstance(default_properties, dict)
71
- assert properties.keys() == default_properties.keys()
72
-
73
- properties_data = {}
74
- for name, values in properties.items():
75
- assert isinstance(values, list)
76
- default_str = default_properties[name]
77
- assert isinstance(default_str, str)
78
- default_nbt = immutable_from_snbt(default_str)
79
-
80
- states: list[PropertyValueType] = []
81
- for val_str in values:
82
- assert isinstance(val_str, str)
83
- val_nbt = immutable_from_snbt(val_str)
84
- states.append(val_nbt)
85
-
86
- properties_data[name] = PropertyValueSpec(default_nbt, tuple(states))
87
-
88
- if "nbt_identifier" in obj:
89
- nbt_id_raw = obj["nbt_identifier"]
90
- assert isinstance(nbt_id_raw, list)
91
- namespace, base_name = nbt_id_raw
92
- assert isinstance(namespace, str) and isinstance(base_name, str)
93
-
94
- snbt = obj["snbt"]
95
- assert isinstance(snbt, str)
96
- nbt = NBTSpec(namespace, base_name, snbt)
97
- else:
98
- nbt = None
99
- assert "snbt" not in obj
100
-
101
- assert not set(obj.keys()).difference(
102
- ("properties", "defaults", "nbt_identifier", "snbt")
103
- ), obj.keys()
104
-
105
- return cls(PropertySpec(properties_data), nbt)
106
-
107
- def to_json(self) -> JSONDict:
108
- spec: JSONDict = {}
109
- if self.properties:
110
- spec["properties"] = properties = {}
111
- spec["defaults"] = defaults = {}
112
- for name, state in self.properties.items():
113
- properties[name] = [val.to_snbt() for val in state.states]
114
- defaults[name] = state.default.to_snbt()
115
- if self.nbt is not None:
116
- spec["nbt_identifier"] = [self.nbt.namespace, self.nbt.base_name]
117
- spec["snbt"] = self.nbt.snbt
118
- return spec
119
-
120
-
121
- def _read_glob(path: str) -> str:
122
- with open(path) as f:
123
- return f.read()
124
-
125
-
126
- def load_json_block_spec(
127
- version_path: str, block_format: str
128
- ) -> dict[str, dict[str, BlockSpec]]:
129
- """Load all block specification files for the given version."""
130
- block_spec = dict[str, dict[str, BlockSpec]]()
131
- paths = glob.glob(
132
- os.path.join(
133
- glob.escape(version_path),
134
- "block",
135
- block_format,
136
- "specification",
137
- "*",
138
- "*",
139
- "*.json",
140
- )
141
- )
142
- with ThreadPoolExecutor() as e:
143
- for file_path, data in zip(paths, e.map(_read_glob, paths)):
144
- *_, namespace, _, base_name = os.path.splitext(os.path.normpath(file_path))[
145
- 0
146
- ].split(os.sep)
147
- block_spec.setdefault(namespace, {})[base_name] = BlockSpec.from_json(
148
- json.loads(data)
149
- )
150
- return block_spec
amulet/game/abc/biome.py DELETED
@@ -1,213 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from typing import TYPE_CHECKING
4
- from abc import ABC, abstractmethod
5
- from collections.abc import Mapping, Collection
6
- import os
7
- import json
8
-
9
- from amulet.biome import Biome
10
- from amulet.version import VersionNumber
11
- from amulet.game import get_game_version
12
-
13
- from .game_version_container import GameVersionContainer
14
-
15
-
16
- if TYPE_CHECKING:
17
- from .version import GameVersion
18
-
19
-
20
- class BiomeTranslationError(Exception):
21
- """An exception raised if the biome could not be translated."""
22
-
23
-
24
- class BiomeData(GameVersionContainer, ABC):
25
- _biomes: Mapping[str, Collection[str]]
26
-
27
- def __init__(
28
- self, game_version: GameVersion, biomes: Mapping[str, Collection[str]]
29
- ):
30
- super().__init__(game_version)
31
- self._biomes = {
32
- namespace: tuple(base_names) for namespace, base_names in biomes.items()
33
- }
34
-
35
- def __getstate__(self) -> dict:
36
- state = super().__getstate__()
37
- state["_biomes"] = self._biomes
38
- return state
39
-
40
- def __setstate__(self, state: dict) -> None:
41
- super().__setstate__(state)
42
- self._biomes = state["_biomes"]
43
-
44
- def namespaces(self) -> Collection[str]:
45
- """An iterable of all the valid biome namespaces."""
46
- return self._biomes.keys()
47
-
48
- def base_names(self, namespace: str) -> Collection[str]:
49
- """An iterable of all valid base names for the given namespace."""
50
- return self._biomes[namespace]
51
-
52
- def translate(
53
- self, target_platform: str, target_version: VersionNumber, biome: Biome
54
- ) -> Biome:
55
- """Translate a biome from this version to the target version specified.
56
-
57
- :param target_platform: The game platform to convert to.
58
- :param target_version: The game version number to convert to.
59
- :param biome: The biome to translate.
60
- :return: The biome converted to the output version.
61
- :raises:
62
- ValueError: The arguments are incorrect. You did something wrong.
63
- BlockTranslationError: The translator is not aware of the biome. You should handle a sensible default.
64
- """
65
- target_game_version = get_game_version(target_platform, target_version)
66
- universal_biome = self.to_universal(biome)
67
- return target_game_version.biome.from_universal(
68
- target_platform, target_version, universal_biome
69
- )
70
-
71
- @abstractmethod
72
- def to_universal(self, biome: Biome) -> Biome:
73
- """Convert a biome to the universal format.
74
-
75
- This method should be considered private.
76
-
77
- :meta private:
78
- :param biome: The biome to translate.
79
- :return: The biome converted to the universal version.
80
- :raises:
81
- ValueError: The arguments are incorrect. You did something wrong.
82
- BlockTranslationError: The translator is not aware of the biome. You should handle a sensible default.
83
- """
84
- raise NotImplementedError
85
-
86
- @abstractmethod
87
- def from_universal(
88
- self, target_platform: str, target_version: VersionNumber, biome: Biome
89
- ) -> Biome:
90
- """Convert a biome from the universal format.
91
-
92
- This method should be considered private.
93
-
94
- :meta private:
95
- :param target_platform: The game platform to convert to.
96
- :param target_version: The game version number to convert to.
97
- :param biome: The biome to translate.
98
- :return: The biome converted to this version.
99
- :raises:
100
- ValueError: The arguments are incorrect. You did something wrong.
101
- BlockTranslationError: The translator is not aware of the biome. You should handle a sensible default.
102
- """
103
- raise NotImplementedError
104
-
105
-
106
- class DatabaseBiomeData(BiomeData):
107
- _to_universal: Mapping[tuple[str, str], Biome]
108
- _from_universal: Mapping[Biome, tuple[str, str]]
109
-
110
- def __init__(
111
- self,
112
- game_version: GameVersion,
113
- biomes: Mapping[str, Collection[str]],
114
- to_universal: Mapping[tuple[str, str], Biome],
115
- from_universal: Mapping[Biome, tuple[str, str]],
116
- ):
117
- super().__init__(game_version, biomes)
118
- self._to_universal = to_universal
119
- self._from_universal = from_universal
120
-
121
- def __getstate__(self) -> dict:
122
- state = super().__getstate__()
123
- state["_to_universal"] = self._to_universal
124
- state["_from_universal"] = self._from_universal
125
- return state
126
-
127
- def __setstate__(self, state: dict) -> None:
128
- super().__setstate__(state)
129
- self._to_universal = state["_to_universal"]
130
- self._from_universal = state["_from_universal"]
131
-
132
- def to_universal(self, biome: Biome) -> Biome:
133
- if not self._game_version.supports_version(biome.platform, biome.version):
134
- raise ValueError("The biome is not compatible with this version")
135
-
136
- try:
137
- return self._to_universal[(biome.namespace, biome.base_name)]
138
- except KeyError:
139
- raise BiomeTranslationError(
140
- f"Biome {biome} does not exist in version {self._game_version.platform} {self._game_version.min_version}"
141
- )
142
-
143
- def from_universal(
144
- self, target_platform: str, target_version: VersionNumber, biome: Biome
145
- ) -> Biome:
146
- if not self._game_version.supports_version(target_platform, target_version):
147
- raise ValueError("The target version is not compatible with this version")
148
-
149
- if biome.platform != "universal":
150
- raise ValueError("The source biome is not in the universal format")
151
-
152
- try:
153
- namespace, base_name = self._from_universal[biome]
154
- except KeyError:
155
- raise BiomeTranslationError(
156
- f"Biome {biome} does not exist in version {self._game_version.platform} {self._game_version.min_version}"
157
- )
158
- else:
159
- return Biome(target_platform, target_version, namespace, base_name)
160
-
161
-
162
- class BiomeDataNumericalComponent(ABC):
163
- @abstractmethod
164
- def numerical_id_to_namespace_id(self, numerical_id: int) -> tuple[str, str]:
165
- """Convert the numerical id to its namespace id"""
166
- raise NotImplementedError
167
-
168
- @abstractmethod
169
- def namespace_id_to_numerical_id(self, namespace: str, base_name: str) -> int:
170
- raise NotImplementedError
171
-
172
-
173
- def load_json_biome_data(
174
- version_path: str,
175
- ) -> tuple[
176
- dict[tuple[str, str], int | None],
177
- dict[tuple[str, str], tuple[str, str]],
178
- dict[tuple[str, str], tuple[str, str]],
179
- ]:
180
- with open(os.path.join(version_path, "__biome_data__.json")) as f:
181
- data = json.load(f)
182
-
183
- biomes = dict[tuple[str, str], int | None]()
184
- to_universal = dict[tuple[str, str], tuple[str, str]]()
185
- from_universal = dict[tuple[str, str], tuple[str, str]]()
186
-
187
- for biome_str, biome_int in data["int_map"].items():
188
- assert isinstance(biome_str, str)
189
- assert isinstance(biome_int, int) or biome_int is None
190
- namespace, base_name = biome_str.split(":", 1)
191
- biomes[(namespace, base_name)] = biome_int
192
-
193
- for biome_str, universal_biome_str in data["version2universal"].items():
194
- assert isinstance(biome_str, str)
195
- assert isinstance(universal_biome_str, str)
196
- namespace, base_name = biome_str.split(":", 1)
197
- universal_namespace, universal_base_name = biome_str.split(":", 1)
198
- to_universal[(namespace, base_name)] = (
199
- universal_namespace,
200
- universal_base_name,
201
- )
202
-
203
- for universal_biome_str, biome_str in data["universal2version"].items():
204
- assert isinstance(biome_str, str)
205
- assert isinstance(universal_biome_str, str)
206
- namespace, base_name = biome_str.split(":", 1)
207
- universal_namespace, universal_base_name = biome_str.split(":", 1)
208
- from_universal[(universal_namespace, universal_base_name)] = (
209
- namespace,
210
- base_name,
211
- )
212
-
213
- return biomes, to_universal, from_universal