amulet-core 2.0a8__cp312-cp312-win_amd64.whl → 2.0.1.0.1297307203.19.43.34808.0a1__cp312-cp312-win_amd64.whl

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

Potentially problematic release.


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

Files changed (271) hide show
  1. amulet/core/__init__.py +36 -0
  2. amulet/core/__pyinstaller/hook-amulet.core.py +4 -0
  3. amulet/core/_amulet_core.cp312-win_amd64.pyd +0 -0
  4. amulet/core/_amulet_core.pyi +7 -0
  5. amulet/{_version.py → core/_version.py} +3 -3
  6. amulet/core/amulet_core.dll +0 -0
  7. amulet/core/amulet_core.lib +0 -0
  8. amulet/core/amulet_coreConfig.cmake +18 -0
  9. amulet/{biome.pyi → core/biome/__init__.pyi} +3 -3
  10. amulet/core/biome/biome.hpp +53 -0
  11. amulet/{block.pyi → core/block/__init__.pyi} +25 -26
  12. amulet/core/block/block.hpp +156 -0
  13. amulet/{block_entity.pyi → core/block_entity/__init__.pyi} +7 -7
  14. amulet/core/block_entity/block_entity.hpp +84 -0
  15. amulet/{errors.py → core/chunk/__init__.pyi} +37 -33
  16. amulet/core/chunk/chunk.hpp +126 -0
  17. amulet/core/chunk/component/__init__.pyi +18 -0
  18. amulet/core/chunk/component/biome_3d_component.hpp +96 -0
  19. amulet/core/chunk/component/block_component.hpp +101 -0
  20. amulet/core/chunk/component/block_component.pyi +28 -0
  21. amulet/core/chunk/component/block_entity_component.hpp +119 -0
  22. amulet/core/chunk/component/section_array_map.hpp +129 -0
  23. amulet/{chunk_components.pyi → core/chunk/component/section_array_map.pyi} +4 -24
  24. amulet/core/dll.hpp +21 -0
  25. amulet/core/entity/__init__.pyi +105 -0
  26. amulet/core/entity/entity.hpp +100 -0
  27. amulet/{palette → core/palette}/__init__.pyi +2 -2
  28. amulet/core/palette/biome_palette.hpp +65 -0
  29. amulet/{palette → core/palette}/biome_palette.pyi +8 -8
  30. amulet/core/palette/block_palette.hpp +71 -0
  31. amulet/{palette → core/palette}/block_palette.pyi +12 -10
  32. amulet/core/selection/__init__.pyi +8 -0
  33. amulet/core/selection/box.hpp +86 -0
  34. amulet/core/selection/box.pyi +215 -0
  35. amulet/core/selection/group.hpp +80 -0
  36. amulet/core/selection/group.pyi +213 -0
  37. amulet/{version.pyi → core/version/__init__.pyi} +58 -10
  38. amulet/core/version/version.hpp +204 -0
  39. {amulet_core-2.0a8.dist-info → amulet_core-2.0.1.0.1297307203.19.43.34808.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__.cp312-win_amd64.pyd +0 -0
  44. amulet/__init__.py.cpp +0 -45
  45. amulet/__init__.pyi +0 -30
  46. amulet/__pyinstaller/hook-amulet.py +0 -4
  47. amulet/_init.py +0 -26
  48. amulet/biome.cpp +0 -36
  49. amulet/biome.hpp +0 -43
  50. amulet/biome.py.cpp +0 -122
  51. amulet/block.cpp +0 -435
  52. amulet/block.hpp +0 -119
  53. amulet/block.py.cpp +0 -377
  54. amulet/block_entity.cpp +0 -12
  55. amulet/block_entity.hpp +0 -56
  56. amulet/block_entity.py.cpp +0 -115
  57. amulet/chunk.cpp +0 -16
  58. amulet/chunk.hpp +0 -100
  59. amulet/chunk.py.cpp +0 -80
  60. amulet/chunk.pyi +0 -28
  61. amulet/chunk_components/biome_3d_component.cpp +0 -5
  62. amulet/chunk_components/biome_3d_component.hpp +0 -79
  63. amulet/chunk_components/block_component.cpp +0 -41
  64. amulet/chunk_components/block_component.hpp +0 -88
  65. amulet/chunk_components/block_entity_component.cpp +0 -5
  66. amulet/chunk_components/block_entity_component.hpp +0 -147
  67. amulet/chunk_components/section_array_map.cpp +0 -129
  68. amulet/chunk_components/section_array_map.hpp +0 -147
  69. amulet/collections/eq.py.hpp +0 -37
  70. amulet/collections/hash.py.hpp +0 -27
  71. amulet/collections/holder.py.hpp +0 -37
  72. amulet/collections/iterator.py.hpp +0 -80
  73. amulet/collections/mapping.py.hpp +0 -199
  74. amulet/collections/mutable_mapping.py.hpp +0 -226
  75. amulet/collections/sequence.py.hpp +0 -163
  76. amulet/collections.pyi +0 -40
  77. amulet/data_types.py +0 -29
  78. amulet/entity.py +0 -182
  79. amulet/game/__init__.py +0 -7
  80. amulet/game/_game.py +0 -152
  81. amulet/game/_universal/__init__.py +0 -1
  82. amulet/game/_universal/_biome.py +0 -17
  83. amulet/game/_universal/_block.py +0 -47
  84. amulet/game/_universal/_version.py +0 -68
  85. amulet/game/abc/__init__.py +0 -22
  86. amulet/game/abc/_block_specification.py +0 -150
  87. amulet/game/abc/biome.py +0 -213
  88. amulet/game/abc/block.py +0 -331
  89. amulet/game/abc/game_version_container.py +0 -25
  90. amulet/game/abc/json_interface.py +0 -27
  91. amulet/game/abc/version.py +0 -44
  92. amulet/game/bedrock/__init__.py +0 -1
  93. amulet/game/bedrock/_biome.py +0 -35
  94. amulet/game/bedrock/_block.py +0 -42
  95. amulet/game/bedrock/_version.py +0 -165
  96. amulet/game/java/__init__.py +0 -2
  97. amulet/game/java/_biome.py +0 -35
  98. amulet/game/java/_block.py +0 -60
  99. amulet/game/java/_version.py +0 -176
  100. amulet/game/translate/__init__.py +0 -12
  101. amulet/game/translate/_functions/__init__.py +0 -15
  102. amulet/game/translate/_functions/_code_functions/__init__.py +0 -0
  103. amulet/game/translate/_functions/_code_functions/_text.py +0 -553
  104. amulet/game/translate/_functions/_code_functions/banner_pattern.py +0 -67
  105. amulet/game/translate/_functions/_code_functions/bedrock_chest_connection.py +0 -152
  106. amulet/game/translate/_functions/_code_functions/bedrock_moving_block_pos.py +0 -88
  107. amulet/game/translate/_functions/_code_functions/bedrock_sign.py +0 -152
  108. amulet/game/translate/_functions/_code_functions/bedrock_skull_rotation.py +0 -16
  109. amulet/game/translate/_functions/_code_functions/custom_name.py +0 -146
  110. amulet/game/translate/_functions/_frozen.py +0 -66
  111. amulet/game/translate/_functions/_state.py +0 -54
  112. amulet/game/translate/_functions/_typing.py +0 -98
  113. amulet/game/translate/_functions/abc.py +0 -123
  114. amulet/game/translate/_functions/carry_nbt.py +0 -160
  115. amulet/game/translate/_functions/carry_properties.py +0 -80
  116. amulet/game/translate/_functions/code.py +0 -143
  117. amulet/game/translate/_functions/map_block_name.py +0 -66
  118. amulet/game/translate/_functions/map_nbt.py +0 -111
  119. amulet/game/translate/_functions/map_properties.py +0 -93
  120. amulet/game/translate/_functions/multiblock.py +0 -112
  121. amulet/game/translate/_functions/new_block.py +0 -42
  122. amulet/game/translate/_functions/new_entity.py +0 -43
  123. amulet/game/translate/_functions/new_nbt.py +0 -206
  124. amulet/game/translate/_functions/new_properties.py +0 -64
  125. amulet/game/translate/_functions/sequence.py +0 -51
  126. amulet/game/translate/_functions/walk_input_nbt.py +0 -331
  127. amulet/game/translate/_translator.py +0 -433
  128. amulet/img/__init__.py +0 -10
  129. amulet/img/missing_no.png +0 -0
  130. amulet/img/missing_pack.png +0 -0
  131. amulet/img/missing_world.png +0 -0
  132. amulet/io/binary_reader.hpp +0 -45
  133. amulet/io/binary_writer.hpp +0 -30
  134. amulet/item.py +0 -75
  135. amulet/level/__init__.pyi +0 -23
  136. amulet/level/_load.py +0 -100
  137. amulet/level/abc/__init__.py +0 -12
  138. amulet/level/abc/_chunk_handle.py +0 -358
  139. amulet/level/abc/_dimension.py +0 -86
  140. amulet/level/abc/_history/__init__.py +0 -1
  141. amulet/level/abc/_history/_cache.py +0 -224
  142. amulet/level/abc/_history/_history_manager.py +0 -291
  143. amulet/level/abc/_level/__init__.py +0 -5
  144. amulet/level/abc/_level/_compactable_level.py +0 -10
  145. amulet/level/abc/_level/_creatable_level.py +0 -28
  146. amulet/level/abc/_level/_disk_level.py +0 -17
  147. amulet/level/abc/_level/_level.py +0 -449
  148. amulet/level/abc/_level/_loadable_level.py +0 -42
  149. amulet/level/abc/_player_storage.py +0 -7
  150. amulet/level/abc/_raw_level.py +0 -187
  151. amulet/level/abc/_registry.py +0 -40
  152. amulet/level/java/__init__.pyi +0 -16
  153. amulet/level/java/_chunk_handle.py +0 -17
  154. amulet/level/java/_dimension.py +0 -20
  155. amulet/level/java/_level.py +0 -184
  156. amulet/level/java/_raw/__init__.pyi +0 -15
  157. amulet/level/java/_raw/_chunk.pyi +0 -23
  158. amulet/level/java/_raw/_constant.py +0 -9
  159. amulet/level/java/_raw/_data_pack/__init__.py +0 -2
  160. amulet/level/java/_raw/_data_pack/data_pack.py +0 -241
  161. amulet/level/java/_raw/_data_pack/data_pack_manager.py +0 -77
  162. amulet/level/java/_raw/_dimension.py +0 -86
  163. amulet/level/java/_raw/_level.py +0 -507
  164. amulet/level/java/_raw/_typing.py +0 -3
  165. amulet/level/java/_raw/java_chunk_decode.cpp +0 -531
  166. amulet/level/java/_raw/java_chunk_decode.hpp +0 -23
  167. amulet/level/java/_raw/java_chunk_encode.cpp +0 -25
  168. amulet/level/java/_raw/java_chunk_encode.hpp +0 -23
  169. amulet/level/java/anvil/__init__.py +0 -2
  170. amulet/level/java/anvil/_dimension.py +0 -170
  171. amulet/level/java/anvil/_region.py +0 -421
  172. amulet/level/java/anvil/_sector_manager.py +0 -223
  173. amulet/level/java/chunk.pyi +0 -81
  174. amulet/level/java/chunk_/_chunk.py +0 -260
  175. amulet/level/java/chunk_/components/inhabited_time.py +0 -12
  176. amulet/level/java/chunk_/components/last_update.py +0 -12
  177. amulet/level/java/chunk_/components/legacy_version.py +0 -12
  178. amulet/level/java/chunk_/components/light_populated.py +0 -12
  179. amulet/level/java/chunk_/components/named_height_2d.py +0 -37
  180. amulet/level/java/chunk_/components/status.py +0 -11
  181. amulet/level/java/chunk_/components/terrain_populated.py +0 -12
  182. amulet/level/java/chunk_components/data_version_component.cpp +0 -32
  183. amulet/level/java/chunk_components/data_version_component.hpp +0 -31
  184. amulet/level/java/chunk_components/java_raw_chunk_component.cpp +0 -56
  185. amulet/level/java/chunk_components/java_raw_chunk_component.hpp +0 -45
  186. amulet/level/java/chunk_components.pyi +0 -22
  187. amulet/level/java/java_chunk.cpp +0 -170
  188. amulet/level/java/java_chunk.hpp +0 -141
  189. amulet/level/java/long_array.hpp +0 -175
  190. amulet/level/java/long_array.pyi +0 -39
  191. amulet/level/temporary_level/__init__.py +0 -1
  192. amulet/level/temporary_level/_level.py +0 -16
  193. amulet/mesh/__init__.py +0 -0
  194. amulet/mesh/block/__init__.pyi +0 -301
  195. amulet/mesh/block/_cube.py +0 -198
  196. amulet/mesh/block/_missing_block.py +0 -20
  197. amulet/mesh/block/block_mesh.cpp +0 -107
  198. amulet/mesh/block/block_mesh.hpp +0 -207
  199. amulet/mesh/util.py +0 -17
  200. amulet/palette/biome_palette.hpp +0 -85
  201. amulet/palette/block_palette.cpp +0 -32
  202. amulet/palette/block_palette.hpp +0 -93
  203. amulet/player.py +0 -62
  204. amulet/pybind11/collections.hpp +0 -118
  205. amulet/pybind11/numpy.hpp +0 -26
  206. amulet/pybind11/py_module.hpp +0 -34
  207. amulet/pybind11/type_hints.hpp +0 -51
  208. amulet/pybind11/types.hpp +0 -25
  209. amulet/pybind11/typing.hpp +0 -7
  210. amulet/resource_pack/__init__.py +0 -63
  211. amulet/resource_pack/abc/__init__.py +0 -2
  212. amulet/resource_pack/abc/resource_pack.py +0 -38
  213. amulet/resource_pack/abc/resource_pack_manager.py +0 -85
  214. amulet/resource_pack/java/__init__.py +0 -2
  215. amulet/resource_pack/java/download_resources.py +0 -212
  216. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_black.png +0 -0
  217. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_blue.png +0 -0
  218. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_brown.png +0 -0
  219. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_cyan.png +0 -0
  220. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_gray.png +0 -0
  221. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_green.png +0 -0
  222. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_light_blue.png +0 -0
  223. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_light_gray.png +0 -0
  224. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_lime.png +0 -0
  225. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_magenta.png +0 -0
  226. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_orange.png +0 -0
  227. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_pink.png +0 -0
  228. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_purple.png +0 -0
  229. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_red.png +0 -0
  230. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_white.png +0 -0
  231. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_yellow.png +0 -0
  232. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/barrier.png +0 -0
  233. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/end_portal.png +0 -0
  234. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/grass.png +0 -0
  235. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/lava.png +0 -0
  236. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/structure_void.png +0 -0
  237. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/water.png +0 -0
  238. amulet/resource_pack/java/java_vanilla_fix/pack.png +0 -0
  239. amulet/resource_pack/java/resource_pack.py +0 -44
  240. amulet/resource_pack/java/resource_pack_manager.py +0 -563
  241. amulet/resource_pack/unknown_resource_pack.py +0 -10
  242. amulet/selection/__init__.py +0 -2
  243. amulet/selection/abstract_selection.py +0 -342
  244. amulet/selection/box.py +0 -852
  245. amulet/selection/group.py +0 -481
  246. amulet/utils/__init__.pyi +0 -23
  247. amulet/utils/call_spec/__init__.py +0 -24
  248. amulet/utils/call_spec/_call_spec.py +0 -257
  249. amulet/utils/cast.py +0 -10
  250. amulet/utils/comment_json.py +0 -188
  251. amulet/utils/format_utils.py +0 -41
  252. amulet/utils/generator.py +0 -18
  253. amulet/utils/matrix.py +0 -243
  254. amulet/utils/numpy.hpp +0 -36
  255. amulet/utils/numpy.pyi +0 -11
  256. amulet/utils/numpy_helpers.py +0 -19
  257. amulet/utils/shareable_lock.py +0 -335
  258. amulet/utils/signal/__init__.py +0 -10
  259. amulet/utils/signal/_signal.py +0 -228
  260. amulet/utils/task_manager.py +0 -235
  261. amulet/utils/typed_property.py +0 -111
  262. amulet/utils/weakref.py +0 -70
  263. amulet/utils/world_utils.py +0 -102
  264. amulet/version.cpp +0 -136
  265. amulet/version.hpp +0 -142
  266. amulet/version.py.cpp +0 -281
  267. amulet_core-2.0a8.dist-info/RECORD +0 -241
  268. amulet_core-2.0a8.dist-info/entry_points.txt +0 -2
  269. /amulet/{__pyinstaller → core/__pyinstaller}/__init__.py +0 -0
  270. /amulet/{py.typed → core/py.typed} +0 -0
  271. {amulet_core-2.0a8.dist-info → amulet_core-2.0.1.0.1297307203.19.43.34808.0a1.dist-info}/top_level.txt +0 -0
@@ -1,433 +0,0 @@
1
- from __future__ import annotations
2
- from typing import Callable, Union, Sequence, TypeVar, Type, Any, TYPE_CHECKING
3
- import json
4
- import glob
5
- import os
6
- from concurrent.futures import ThreadPoolExecutor
7
-
8
- from amulet_nbt import (
9
- read_nbt,
10
- read_snbt,
11
- NamedTag,
12
- ListTag,
13
- CompoundTag,
14
- AnyNBT,
15
- )
16
-
17
- from amulet.block import Block
18
- from amulet.block_entity import BlockEntity
19
- from amulet.entity import Entity
20
- from amulet.data_types import BlockCoordinates
21
- from amulet.version import VersionNumber
22
-
23
- from ._functions import (
24
- AbstractBaseTranslationFunction,
25
- SrcData,
26
- SrcDataExtra,
27
- StateData,
28
- DstData,
29
- )
30
- from ._functions.abc import translation_function_from_json
31
- from ._functions._typing import NBTPath
32
-
33
- if TYPE_CHECKING:
34
- from amulet.game.abc import GameVersion, BlockSpec
35
-
36
-
37
- # These classes exist to do some pre-translation and post-translation processing.
38
- # They also store the constant data so that it doesn't need to be passed in each time.
39
- # They don't do any caching
40
-
41
-
42
- def create_nbt(
43
- outer_name: str,
44
- outer_type: type[ListTag] | type[CompoundTag],
45
- nbt_list: Sequence[
46
- tuple[
47
- str,
48
- type[ListTag] | type[CompoundTag],
49
- NBTPath,
50
- Union[str, int],
51
- AnyNBT,
52
- ]
53
- ],
54
- default_template: str | None = None,
55
- ) -> NamedTag:
56
- nbt_object: AnyNBT
57
- if default_template is None:
58
- nbt_object = outer_type()
59
- else:
60
- nbt_object = read_snbt(default_template)
61
-
62
- for nbt_entry in nbt_list:
63
- (
64
- element_outer_name,
65
- element_outer_type,
66
- element_nbt_path,
67
- element_data_path,
68
- element_data,
69
- ) = nbt_entry
70
- if outer_name == element_outer_name and issubclass(
71
- outer_type, element_outer_type
72
- ):
73
- nbt_temp: AnyNBT = nbt_object
74
- for path, nbt_type in element_nbt_path:
75
- # if the nested NBT object does not exist then create it
76
- if isinstance(nbt_temp, CompoundTag):
77
- assert isinstance(path, str)
78
- if path not in nbt_temp or not isinstance(nbt_temp[path], nbt_type):
79
- nbt_temp[path] = nbt_type()
80
- nbt_temp = nbt_temp[path]
81
- elif isinstance(nbt_temp, ListTag):
82
- assert isinstance(path, int)
83
- # if the list is a different type to nbt_type replace it with nbt_type
84
- if len(nbt_temp) > 0 and not isinstance(nbt_temp[0], nbt_type):
85
- raise RuntimeError("ListTag elements are the wrong type")
86
-
87
- for _ in range(path + 1 - len(nbt_temp)):
88
- # pad out the list to the length of the index
89
- nbt_temp.append(nbt_type())
90
- # we now should have a ListTag of the same type as nbt_type and length as path
91
- nbt_temp = nbt_temp[path]
92
- else:
93
- raise RuntimeError
94
-
95
- if isinstance(nbt_temp, CompoundTag):
96
- assert isinstance(element_data_path, str)
97
- nbt_temp[element_data_path] = element_data
98
-
99
- elif isinstance(nbt_temp, ListTag):
100
- assert isinstance(element_data_path, int)
101
- # if the list is a different type to data replace it with type(data)
102
- if (
103
- len(nbt_temp) > 0
104
- and nbt_temp[0].list_data_type != element_data.tag_id
105
- ):
106
- raise RuntimeError("ListTag elements are the wrong type")
107
-
108
- for _ in range(element_data_path + 1 - len(nbt_temp)):
109
- # pad out the list to the length of the index
110
- nbt_temp.append(element_data.__class__())
111
- # we now should have a ListTag of the same type as nbt_type and length as data_path
112
- nbt_temp[element_data_path] = element_data
113
-
114
- # TODO:
115
- # elif isinstance(nbt_temp, ByteArrayTag) and isinstance(data, ByteTag):
116
- # # pad to the length of data_path if less than the current length
117
- # # nbt_temp[data_path] = data.value
118
- # elif isinstance(nbt_temp, IntArrayTag) and isinstance(data, IntTag):
119
- # elif isinstance(nbt_temp, LongArrayTag) and isinstance(data, LongTag):
120
-
121
- return NamedTag(nbt_object, outer_name)
122
-
123
-
124
- class BlockToUniversalTranslator:
125
- # Class variables
126
- _instances: dict[BlockToUniversalTranslator, BlockToUniversalTranslator] = {}
127
-
128
- # Instance variables
129
- _src_spec: BlockSpec
130
- _translation: AbstractBaseTranslationFunction
131
- _universal_version: GameVersion
132
- _hash: int | None
133
-
134
- def __new__(
135
- cls,
136
- src_spec: BlockSpec,
137
- translation: AbstractBaseTranslationFunction,
138
- universal_version: GameVersion,
139
- ) -> BlockToUniversalTranslator:
140
- self = super().__new__(cls)
141
- self._src_spec = src_spec
142
- self._translation = translation
143
- self._universal_version = universal_version
144
- self._hash = None
145
- return cls._instances.setdefault(self, self)
146
-
147
- def __reduce__(self) -> Any:
148
- return BlockToUniversalTranslator, (
149
- self._src_spec,
150
- self._translation,
151
- self._universal_version,
152
- )
153
-
154
- def __hash__(self) -> int:
155
- if self._hash is None:
156
- self._hash = hash(
157
- (self._src_spec, self._translation, self._universal_version)
158
- )
159
- return self._hash
160
-
161
- def run(
162
- self,
163
- block: Block,
164
- block_entity: BlockEntity | None,
165
- extra: (
166
- tuple[
167
- BlockCoordinates,
168
- Callable[[BlockCoordinates], tuple[Block, BlockEntity | None]],
169
- ]
170
- | None
171
- ),
172
- ) -> tuple[Block, BlockEntity | None, bool, bool]:
173
- if extra is None:
174
- src_extra = None
175
- else:
176
- coords, get_block = extra
177
- src_extra = SrcDataExtra(coords, get_block)
178
-
179
- block_entity_nbt = None if block_entity is None else block_entity.nbt
180
-
181
- if self._src_spec.nbt is not None and block_entity_nbt is None:
182
- # There should be a block entity
183
- if src_extra is not None:
184
- # Load it from the level
185
- block_entity = src_extra.get_block_callback((0, 0, 0))[1]
186
- if block_entity is not None:
187
- block_entity_nbt = block_entity.nbt
188
- if block_entity_nbt is None:
189
- # If it is still None then load it from the specification
190
- block_entity_nbt = read_nbt(self._src_spec.nbt.snbt)
191
-
192
- src = SrcData(block, block_entity_nbt, src_extra)
193
- state = StateData()
194
- dst = DstData()
195
- self._translation.run(src, state, dst)
196
-
197
- assert dst.cls is Block
198
- assert dst.resource_id is not None
199
- namespace, base_name = dst.resource_id
200
-
201
- dst_spec = self._universal_version.block.get_specification(namespace, base_name)
202
- properties = {k: v.default for k, v in dst_spec.properties.items()}
203
- properties.update(dst.properties)
204
-
205
- dst_block = Block(
206
- "universal", VersionNumber(1), namespace, base_name, properties
207
- )
208
-
209
- if dst_spec.nbt is None:
210
- dst_block_entity = None
211
- else:
212
- dst_block_entity = BlockEntity(
213
- "universal",
214
- VersionNumber(1),
215
- dst_spec.nbt.namespace,
216
- dst_spec.nbt.base_name,
217
- create_nbt(
218
- "",
219
- CompoundTag,
220
- dst.nbt,
221
- dst_spec.nbt.snbt,
222
- ),
223
- )
224
-
225
- return dst_block, dst_block_entity, dst.extra_needed, dst.cacheable
226
-
227
-
228
- class BlockFromUniversalTranslator:
229
- # Class variables
230
- _instances: dict[BlockFromUniversalTranslator, BlockFromUniversalTranslator] = {}
231
-
232
- # Instance variables
233
- _src_spec: BlockSpec
234
- _translation: AbstractBaseTranslationFunction
235
- _target_version: GameVersion
236
- _hash: int | None
237
-
238
- def __new__(
239
- cls,
240
- src_spec: BlockSpec,
241
- translation: AbstractBaseTranslationFunction,
242
- target_version: GameVersion,
243
- ) -> BlockFromUniversalTranslator:
244
- self = super().__new__(cls)
245
- self._src_spec = src_spec
246
- self._translation = translation
247
- self._target_version = target_version
248
- self._hash = None
249
- return cls._instances.setdefault(self, self)
250
-
251
- def __reduce__(self) -> Any:
252
- return BlockFromUniversalTranslator, (
253
- self._src_spec,
254
- self._translation,
255
- self._target_version,
256
- )
257
-
258
- def __hash__(self) -> int:
259
- if self._hash is None:
260
- self._hash = hash((self._src_spec, self._translation, self._target_version))
261
- return self._hash
262
-
263
- def run(
264
- self,
265
- target_platform: str,
266
- target_version: VersionNumber,
267
- block: Block,
268
- block_entity: BlockEntity | None,
269
- extra: (
270
- tuple[
271
- BlockCoordinates,
272
- Callable[[BlockCoordinates], tuple[Block, BlockEntity | None]],
273
- ]
274
- | None
275
- ),
276
- ) -> tuple[Block, BlockEntity | None, bool, bool] | tuple[Entity, None, bool, bool]:
277
- if extra is None:
278
- src_extra = None
279
- else:
280
- coords, get_block = extra
281
- src_extra = SrcDataExtra(coords, get_block)
282
-
283
- block_entity_nbt = None if block_entity is None else block_entity.nbt
284
-
285
- if self._src_spec.nbt is not None and block_entity_nbt is None:
286
- # There should be a block entity
287
- if src_extra is not None:
288
- # Load it from the level
289
- block_entity = src_extra.get_block_callback((0, 0, 0))[1]
290
- if block_entity is not None:
291
- block_entity_nbt = block_entity.nbt
292
- if block_entity_nbt is None:
293
- # If it is still None then load it from the specification
294
- block_entity_nbt = read_nbt(self._src_spec.nbt.snbt)
295
-
296
- src = SrcData(block, block_entity_nbt, src_extra)
297
- state = StateData()
298
- dst = DstData()
299
- self._translation.run(src, state, dst)
300
-
301
- if dst.cls is Block:
302
- assert dst.resource_id is not None
303
- namespace, base_name = dst.resource_id
304
-
305
- dst_spec = self._target_version.block.get_specification(
306
- namespace, base_name
307
- )
308
- properties = {k: v.default for k, v in dst_spec.properties.items()}
309
- properties.update(dst.properties)
310
-
311
- dst_block = Block(
312
- target_platform, target_version, namespace, base_name, properties
313
- )
314
-
315
- if dst_spec.nbt is None:
316
- dst_block_entity = None
317
- else:
318
- dst_block_entity = BlockEntity(
319
- target_platform,
320
- target_version,
321
- dst_spec.nbt.namespace,
322
- dst_spec.nbt.base_name,
323
- create_nbt(
324
- "",
325
- CompoundTag,
326
- dst.nbt,
327
- dst_spec.nbt.snbt,
328
- ),
329
- )
330
-
331
- return dst_block, dst_block_entity, dst.extra_needed, dst.cacheable
332
-
333
- elif dst.cls is Entity:
334
- assert dst.resource_id is not None
335
- namespace, base_name = dst.resource_id
336
-
337
- # dst_spec = self._target_version.block.get_specification(
338
- # namespace, base_name
339
- # )
340
-
341
- dst_entity = Entity(
342
- target_platform,
343
- target_version,
344
- namespace,
345
- base_name,
346
- 0.0,
347
- 0.0,
348
- 0.0,
349
- create_nbt(
350
- "",
351
- CompoundTag,
352
- dst.nbt,
353
- # dst_spec.nbt.snbt,
354
- ),
355
- )
356
-
357
- return dst_entity, None, dst.extra_needed, dst.cacheable
358
-
359
- else:
360
- raise RuntimeError
361
-
362
-
363
- TranslationClsT = TypeVar(
364
- "TranslationClsT", BlockToUniversalTranslator, BlockFromUniversalTranslator
365
- )
366
-
367
-
368
- def _read_file(path: str) -> str:
369
- with open(path) as f:
370
- return f.read()
371
-
372
-
373
- def load_json_block_translations(
374
- version_path: str,
375
- block_format: str,
376
- direction: str,
377
- translation_cls: Type[TranslationClsT],
378
- get_src_spec: Callable[[str, str], BlockSpec],
379
- target_version: GameVersion,
380
- ) -> dict[tuple[str, str], TranslationClsT]:
381
- translations = dict[tuple[str, str], TranslationClsT]()
382
- paths = glob.glob(
383
- os.path.join(
384
- glob.escape(version_path),
385
- "block",
386
- block_format,
387
- direction,
388
- "*",
389
- "*",
390
- "*.json",
391
- )
392
- )
393
- with ThreadPoolExecutor() as e:
394
- for file_path, data in zip(paths, e.map(_read_file, paths)):
395
- *_, namespace, _, base_name = os.path.splitext(os.path.normpath(file_path))[
396
- 0
397
- ].split(os.sep)
398
- translations[(namespace, base_name)] = translation_cls(
399
- get_src_spec(namespace, base_name),
400
- translation_function_from_json(json.loads(data)),
401
- target_version,
402
- )
403
- return translations
404
-
405
-
406
- class EntityToUniversalTranslator:
407
- def run(
408
- self,
409
- entity: Entity,
410
- extra: (
411
- tuple[
412
- BlockCoordinates,
413
- Callable[[BlockCoordinates], tuple[Block, BlockEntity | None]],
414
- ]
415
- | None
416
- ),
417
- ) -> tuple[Block, BlockEntity | None, bool, bool]:
418
- raise NotImplementedError
419
-
420
-
421
- class EntityFromUniversalTranslator:
422
- def run(
423
- self,
424
- entity: Entity | None,
425
- extra: (
426
- tuple[
427
- BlockCoordinates,
428
- Callable[[BlockCoordinates], tuple[Block, BlockEntity | None]],
429
- ]
430
- | None
431
- ),
432
- ) -> tuple[Block, BlockEntity | None, bool] | tuple[Entity, None, bool]:
433
- raise NotImplementedError
amulet/img/__init__.py DELETED
@@ -1,10 +0,0 @@
1
- import os
2
-
3
-
4
- def _get_path(file: str) -> str:
5
- return os.path.abspath(os.path.join(os.path.dirname(__file__), file))
6
-
7
-
8
- missing_no_icon_path = _get_path("missing_no.png")
9
- missing_pack_icon_path = _get_path("missing_pack.png")
10
- missing_world_icon_path = _get_path("missing_world.png")
amulet/img/missing_no.png DELETED
Binary file
Binary file
Binary file
@@ -1,45 +0,0 @@
1
- #pragma once
2
-
3
- #include <string>
4
- #include <cstdint>
5
- #include <cstring>
6
- #include <algorithm>
7
- #include <bit>
8
- #include <functional>
9
- #include <stdexcept>
10
- #include <memory>
11
-
12
- #include <amulet_nbt/io/binary_reader.hpp>
13
-
14
-
15
- namespace Amulet {
16
- class BinaryReader: public AmuletNBT::BinaryReader {
17
-
18
-
19
- public:
20
- BinaryReader(
21
- const std::string& input,
22
- size_t& position
23
- ) : AmuletNBT::BinaryReader(input, position, std::endian::little, [](const std::string& value) {return value; }) {}
24
-
25
- std::string readSizeAndBytes() {
26
- std::uint64_t length;
27
- readNumericInto<std::uint64_t>(length);
28
- // Ensure the buffer is long enough
29
- if (position + length > data.size()) {
30
- throw std::out_of_range("Cannot read string of length " + std::to_string(length) + " at position " + std::to_string(position));
31
- }
32
-
33
- std::string value = data.substr(position, length);
34
- position += length;
35
- return value;
36
- }
37
- };
38
-
39
- template <class T>
40
- std::shared_ptr<T> deserialise(const std::string& data){
41
- size_t position = 0;
42
- BinaryReader reader(data, position);
43
- return T::deserialise(reader);
44
- }
45
- }
@@ -1,30 +0,0 @@
1
- #pragma once
2
-
3
- #include <string>
4
- #include <cstdint>
5
- #include <cstring>
6
- #include <algorithm>
7
- #include <bit>
8
- #include <functional>
9
-
10
- #include <amulet_nbt/io/binary_writer.hpp>
11
-
12
-
13
- namespace Amulet {
14
- class BinaryWriter: public AmuletNBT::BinaryWriter {
15
- public:
16
- BinaryWriter(): AmuletNBT::BinaryWriter(std::endian::little, [](const std::string& value) {return value; }) {}
17
-
18
- void writeSizeAndBytes(const std::string& value) {
19
- writeNumeric<std::uint64_t>(value.size());
20
- data.append(value);
21
- }
22
- };
23
-
24
- template <typename T>
25
- std::string serialise(const T& obj){
26
- BinaryWriter writer;
27
- obj.serialise(writer);
28
- return writer.getBuffer();
29
- }
30
- }
amulet/item.py DELETED
@@ -1,75 +0,0 @@
1
- # from amulet_nbt import CompoundTag, StringTag
2
- #
3
- #
4
- # class Item(CompoundTag):
5
- # """
6
- # {
7
- # "namespace": StringTag,
8
- # "base_name": StringTag,
9
- # "metadata": CompoundTag
10
- # }
11
- # """
12
- #
13
- # def __init__(self, namespace: str, base_name: str, metadata: dict = None) -> None:
14
- # super().__init__(
15
- # {
16
- # "namespace": StringTag(namespace),
17
- # "base_name": StringTag(base_name),
18
- # "metadata": CompoundTag(metadata or {}),
19
- # }
20
- # )
21
- #
22
- # @property
23
- # def namespace(self) -> str:
24
- # return self.get_string("namespace").py_str
25
- #
26
- # @property
27
- # def base_name(self) -> str:
28
- # return self.get_string("base_name").py_str
29
- #
30
- # @property
31
- # def metadata(self) -> CompoundTag:
32
- # return self.get_compound("metadata")
33
- #
34
- #
35
- # class BlockItem(CompoundTag):
36
- # """
37
- # {
38
- # "namespace": StringTag,
39
- # "base_name": StringTag,
40
- # "properties": CompoundTag
41
- # "metadata": CompoundTag
42
- # }
43
- # """
44
- #
45
- # def __init__(
46
- # self,
47
- # namespace: str,
48
- # base_name: str,
49
- # properties: dict = None,
50
- # metadata: dict = None,
51
- # ):
52
- # super().__init__(
53
- # {
54
- # "namespace": StringTag(namespace),
55
- # "base_name": StringTag(base_name),
56
- # "properties": CompoundTag(properties or {}),
57
- # "metadata": CompoundTag(metadata or {}),
58
- # }
59
- # )
60
- #
61
- # @property
62
- # def namespace(self) -> str:
63
- # return self.get_string("namespace").py_str
64
- #
65
- # @property
66
- # def base_name(self) -> str:
67
- # return self.get_string("base_name").py_str
68
- #
69
- # @property
70
- # def properties(self) -> CompoundTag:
71
- # return self.get_compound("properties")
72
- #
73
- # @property
74
- # def metadata(self) -> CompoundTag:
75
- # return self.get_compound("metadata")
amulet/level/__init__.pyi DELETED
@@ -1,23 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from amulet.level._load import (
4
- NoValidLevel,
5
- get_level,
6
- register_level_class,
7
- unregister_level_class,
8
- )
9
- from amulet.level.abc._level._level import Level
10
- from amulet.level.java._level import JavaLevel
11
-
12
- from . import _load, abc, java
13
-
14
- __all__ = [
15
- "JavaLevel",
16
- "Level",
17
- "NoValidLevel",
18
- "abc",
19
- "get_level",
20
- "java",
21
- "register_level_class",
22
- "unregister_level_class",
23
- ]