amulet-core 2.0a5__cp312-cp312-macosx_10_13_universal2.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 (210) hide show
  1. amulet/__init__.cpython-312-darwin.so +0 -0
  2. amulet/__init__.pyi +30 -0
  3. amulet/__pyinstaller/__init__.py +2 -0
  4. amulet/__pyinstaller/hook-amulet.py +4 -0
  5. amulet/_init.py +28 -0
  6. amulet/_version.py +21 -0
  7. amulet/biome.cpp +36 -0
  8. amulet/biome.hpp +43 -0
  9. amulet/biome.pyi +77 -0
  10. amulet/block.cpp +435 -0
  11. amulet/block.hpp +119 -0
  12. amulet/block.pyi +273 -0
  13. amulet/block_entity.cpp +12 -0
  14. amulet/block_entity.hpp +56 -0
  15. amulet/block_entity.pyi +80 -0
  16. amulet/chunk.cpp +16 -0
  17. amulet/chunk.hpp +99 -0
  18. amulet/chunk.pyi +30 -0
  19. amulet/chunk_/components/biome.py +155 -0
  20. amulet/chunk_/components/block_entity.py +117 -0
  21. amulet/chunk_/components/entity.py +64 -0
  22. amulet/chunk_/components/height_2d.py +16 -0
  23. amulet/chunk_components.pyi +95 -0
  24. amulet/collections.pyi +37 -0
  25. amulet/data_types.py +29 -0
  26. amulet/entity.py +180 -0
  27. amulet/errors.py +63 -0
  28. amulet/game/__init__.py +7 -0
  29. amulet/game/_game.py +152 -0
  30. amulet/game/_universal/__init__.py +1 -0
  31. amulet/game/_universal/_biome.py +17 -0
  32. amulet/game/_universal/_block.py +47 -0
  33. amulet/game/_universal/_version.py +68 -0
  34. amulet/game/abc/__init__.py +22 -0
  35. amulet/game/abc/_block_specification.py +150 -0
  36. amulet/game/abc/biome.py +213 -0
  37. amulet/game/abc/block.py +331 -0
  38. amulet/game/abc/game_version_container.py +25 -0
  39. amulet/game/abc/json_interface.py +27 -0
  40. amulet/game/abc/version.py +44 -0
  41. amulet/game/bedrock/__init__.py +1 -0
  42. amulet/game/bedrock/_biome.py +35 -0
  43. amulet/game/bedrock/_block.py +42 -0
  44. amulet/game/bedrock/_version.py +165 -0
  45. amulet/game/java/__init__.py +2 -0
  46. amulet/game/java/_biome.py +35 -0
  47. amulet/game/java/_block.py +60 -0
  48. amulet/game/java/_version.py +176 -0
  49. amulet/game/translate/__init__.py +12 -0
  50. amulet/game/translate/_functions/__init__.py +15 -0
  51. amulet/game/translate/_functions/_code_functions/__init__.py +0 -0
  52. amulet/game/translate/_functions/_code_functions/_text.py +553 -0
  53. amulet/game/translate/_functions/_code_functions/banner_pattern.py +67 -0
  54. amulet/game/translate/_functions/_code_functions/bedrock_chest_connection.py +152 -0
  55. amulet/game/translate/_functions/_code_functions/bedrock_moving_block_pos.py +88 -0
  56. amulet/game/translate/_functions/_code_functions/bedrock_sign.py +152 -0
  57. amulet/game/translate/_functions/_code_functions/bedrock_skull_rotation.py +16 -0
  58. amulet/game/translate/_functions/_code_functions/custom_name.py +146 -0
  59. amulet/game/translate/_functions/_frozen.py +66 -0
  60. amulet/game/translate/_functions/_state.py +54 -0
  61. amulet/game/translate/_functions/_typing.py +98 -0
  62. amulet/game/translate/_functions/abc.py +116 -0
  63. amulet/game/translate/_functions/carry_nbt.py +160 -0
  64. amulet/game/translate/_functions/carry_properties.py +80 -0
  65. amulet/game/translate/_functions/code.py +143 -0
  66. amulet/game/translate/_functions/map_block_name.py +66 -0
  67. amulet/game/translate/_functions/map_nbt.py +111 -0
  68. amulet/game/translate/_functions/map_properties.py +93 -0
  69. amulet/game/translate/_functions/multiblock.py +112 -0
  70. amulet/game/translate/_functions/new_block.py +42 -0
  71. amulet/game/translate/_functions/new_entity.py +43 -0
  72. amulet/game/translate/_functions/new_nbt.py +206 -0
  73. amulet/game/translate/_functions/new_properties.py +64 -0
  74. amulet/game/translate/_functions/sequence.py +51 -0
  75. amulet/game/translate/_functions/walk_input_nbt.py +331 -0
  76. amulet/game/translate/_translator.py +433 -0
  77. amulet/item.py +75 -0
  78. amulet/level/__init__.pyi +27 -0
  79. amulet/level/_load.py +100 -0
  80. amulet/level/abc/__init__.py +12 -0
  81. amulet/level/abc/_chunk_handle.py +335 -0
  82. amulet/level/abc/_dimension.py +86 -0
  83. amulet/level/abc/_history/__init__.py +1 -0
  84. amulet/level/abc/_history/_cache.py +224 -0
  85. amulet/level/abc/_history/_history_manager.py +291 -0
  86. amulet/level/abc/_level/__init__.py +5 -0
  87. amulet/level/abc/_level/_compactable_level.py +10 -0
  88. amulet/level/abc/_level/_creatable_level.py +29 -0
  89. amulet/level/abc/_level/_disk_level.py +17 -0
  90. amulet/level/abc/_level/_level.py +453 -0
  91. amulet/level/abc/_level/_loadable_level.py +42 -0
  92. amulet/level/abc/_player_storage.py +7 -0
  93. amulet/level/abc/_raw_level.py +187 -0
  94. amulet/level/abc/_registry.py +40 -0
  95. amulet/level/bedrock/__init__.py +2 -0
  96. amulet/level/bedrock/_chunk_handle.py +19 -0
  97. amulet/level/bedrock/_dimension.py +22 -0
  98. amulet/level/bedrock/_level.py +187 -0
  99. amulet/level/bedrock/_raw/__init__.py +5 -0
  100. amulet/level/bedrock/_raw/_actor_counter.py +53 -0
  101. amulet/level/bedrock/_raw/_chunk.py +54 -0
  102. amulet/level/bedrock/_raw/_chunk_decode.py +668 -0
  103. amulet/level/bedrock/_raw/_chunk_encode.py +602 -0
  104. amulet/level/bedrock/_raw/_constant.py +9 -0
  105. amulet/level/bedrock/_raw/_dimension.py +343 -0
  106. amulet/level/bedrock/_raw/_level.py +463 -0
  107. amulet/level/bedrock/_raw/_level_dat.py +90 -0
  108. amulet/level/bedrock/_raw/_typing.py +6 -0
  109. amulet/level/bedrock/_raw/leveldb_chunk_versions.py +83 -0
  110. amulet/level/bedrock/chunk/__init__.py +1 -0
  111. amulet/level/bedrock/chunk/_chunk.py +126 -0
  112. amulet/level/bedrock/chunk/components/__init__.py +0 -0
  113. amulet/level/bedrock/chunk/components/chunk_version.py +12 -0
  114. amulet/level/bedrock/chunk/components/finalised_state.py +13 -0
  115. amulet/level/bedrock/chunk/components/raw_chunk.py +15 -0
  116. amulet/level/construction/__init__.py +0 -0
  117. amulet/level/java/__init__.pyi +21 -0
  118. amulet/level/java/_chunk_handle.py +17 -0
  119. amulet/level/java/_chunk_handle.pyi +15 -0
  120. amulet/level/java/_dimension.py +20 -0
  121. amulet/level/java/_dimension.pyi +13 -0
  122. amulet/level/java/_level.py +184 -0
  123. amulet/level/java/_level.pyi +120 -0
  124. amulet/level/java/_raw/__init__.pyi +19 -0
  125. amulet/level/java/_raw/_chunk.pyi +23 -0
  126. amulet/level/java/_raw/_chunk_decode.py +561 -0
  127. amulet/level/java/_raw/_chunk_encode.py +463 -0
  128. amulet/level/java/_raw/_constant.py +9 -0
  129. amulet/level/java/_raw/_constant.pyi +20 -0
  130. amulet/level/java/_raw/_data_pack/__init__.py +2 -0
  131. amulet/level/java/_raw/_data_pack/__init__.pyi +8 -0
  132. amulet/level/java/_raw/_data_pack/data_pack.py +241 -0
  133. amulet/level/java/_raw/_data_pack/data_pack.pyi +197 -0
  134. amulet/level/java/_raw/_data_pack/data_pack_manager.py +77 -0
  135. amulet/level/java/_raw/_data_pack/data_pack_manager.pyi +75 -0
  136. amulet/level/java/_raw/_dimension.py +86 -0
  137. amulet/level/java/_raw/_dimension.pyi +72 -0
  138. amulet/level/java/_raw/_level.py +507 -0
  139. amulet/level/java/_raw/_level.pyi +238 -0
  140. amulet/level/java/_raw/_typing.py +3 -0
  141. amulet/level/java/_raw/_typing.pyi +5 -0
  142. amulet/level/java/anvil/__init__.py +2 -0
  143. amulet/level/java/anvil/__init__.pyi +11 -0
  144. amulet/level/java/anvil/_dimension.py +170 -0
  145. amulet/level/java/anvil/_dimension.pyi +109 -0
  146. amulet/level/java/anvil/_region.py +421 -0
  147. amulet/level/java/anvil/_region.pyi +197 -0
  148. amulet/level/java/anvil/_sector_manager.py +223 -0
  149. amulet/level/java/anvil/_sector_manager.pyi +142 -0
  150. amulet/level/java/chunk.pyi +81 -0
  151. amulet/level/java/chunk_/_chunk.py +260 -0
  152. amulet/level/java/chunk_/components/inhabited_time.py +12 -0
  153. amulet/level/java/chunk_/components/last_update.py +12 -0
  154. amulet/level/java/chunk_/components/legacy_version.py +12 -0
  155. amulet/level/java/chunk_/components/light_populated.py +12 -0
  156. amulet/level/java/chunk_/components/named_height_2d.py +37 -0
  157. amulet/level/java/chunk_/components/status.py +11 -0
  158. amulet/level/java/chunk_/components/terrain_populated.py +12 -0
  159. amulet/level/java/chunk_components.pyi +22 -0
  160. amulet/level/java/long_array.pyi +38 -0
  161. amulet/level/java_forge/__init__.py +0 -0
  162. amulet/level/mcstructure/__init__.py +0 -0
  163. amulet/level/nbt/__init__.py +0 -0
  164. amulet/level/schematic/__init__.py +0 -0
  165. amulet/level/sponge_schematic/__init__.py +0 -0
  166. amulet/level/temporary_level/__init__.py +1 -0
  167. amulet/level/temporary_level/_level.py +16 -0
  168. amulet/palette/__init__.pyi +8 -0
  169. amulet/palette/biome_palette.pyi +45 -0
  170. amulet/palette/block_palette.pyi +45 -0
  171. amulet/player.py +64 -0
  172. amulet/py.typed +0 -0
  173. amulet/selection/__init__.py +2 -0
  174. amulet/selection/abstract_selection.py +342 -0
  175. amulet/selection/box.py +852 -0
  176. amulet/selection/group.py +481 -0
  177. amulet/utils/__init__.pyi +28 -0
  178. amulet/utils/call_spec/__init__.py +24 -0
  179. amulet/utils/call_spec/__init__.pyi +53 -0
  180. amulet/utils/call_spec/_call_spec.py +262 -0
  181. amulet/utils/call_spec/_call_spec.pyi +272 -0
  182. amulet/utils/format_utils.py +41 -0
  183. amulet/utils/generator.py +18 -0
  184. amulet/utils/matrix.py +243 -0
  185. amulet/utils/matrix.pyi +177 -0
  186. amulet/utils/numpy.pyi +11 -0
  187. amulet/utils/numpy_helpers.py +19 -0
  188. amulet/utils/shareable_lock.py +335 -0
  189. amulet/utils/shareable_lock.pyi +190 -0
  190. amulet/utils/signal/__init__.py +10 -0
  191. amulet/utils/signal/__init__.pyi +25 -0
  192. amulet/utils/signal/_signal.py +228 -0
  193. amulet/utils/signal/_signal.pyi +84 -0
  194. amulet/utils/task_manager.py +235 -0
  195. amulet/utils/task_manager.pyi +168 -0
  196. amulet/utils/typed_property.py +111 -0
  197. amulet/utils/typing.py +4 -0
  198. amulet/utils/typing.pyi +6 -0
  199. amulet/utils/weakref.py +70 -0
  200. amulet/utils/weakref.pyi +50 -0
  201. amulet/utils/world_utils.py +102 -0
  202. amulet/utils/world_utils.pyi +109 -0
  203. amulet/version.cpp +136 -0
  204. amulet/version.hpp +142 -0
  205. amulet/version.pyi +94 -0
  206. amulet_core-2.0a5.dist-info/METADATA +103 -0
  207. amulet_core-2.0a5.dist-info/RECORD +210 -0
  208. amulet_core-2.0a5.dist-info/WHEEL +5 -0
  209. amulet_core-2.0a5.dist-info/entry_points.txt +2 -0
  210. amulet_core-2.0a5.dist-info/top_level.txt +1 -0
@@ -0,0 +1,155 @@
1
+ # from __future__ import annotations
2
+ #
3
+ # from typing import Union, Iterable
4
+ # from collections.abc import Mapping
5
+ #
6
+ # import numpy
7
+ # from numpy.typing import ArrayLike
8
+ #
9
+ # from amulet.version import VersionRange
10
+ # from amulet.biome import Biome
11
+ # from amulet.palette import BiomePalette
12
+ # from amulet.chunk.components.sub_chunk_array import SubChunkArrayContainer
13
+ # from amulet.utils.typed_property import TypedProperty
14
+ #
15
+ # from .abc import ChunkComponent
16
+ #
17
+ #
18
+ # class Biome2DComponentData:
19
+ # _array: numpy.ndarray
20
+ #
21
+ # def __init__(
22
+ # self,
23
+ # version_range: VersionRange,
24
+ # array_shape: tuple[int, int],
25
+ # default_biome: Biome,
26
+ # ):
27
+ # if (
28
+ # not isinstance(array_shape, tuple)
29
+ # and len(array_shape) == 2
30
+ # and all(isinstance(s, int) for s in array_shape)
31
+ # ):
32
+ # raise TypeError
33
+ #
34
+ # self._array_shape = array_shape
35
+ # self._palette = BiomePalette(version_range)
36
+ # self._palette.biome_to_index(default_biome)
37
+ # self._set_biome(0)
38
+ #
39
+ # def __getstate__(self) -> tuple[tuple[int, int], BiomePalette, numpy.ndarray]:
40
+ # return self._array_shape, self._palette, self._array
41
+ #
42
+ # def __setstate__(
43
+ # self, state: tuple[tuple[int, int], BiomePalette, numpy.ndarray]
44
+ # ) -> None:
45
+ # self._array_shape, self._palette, self._array = state
46
+ #
47
+ # @property
48
+ # def array_shape(self) -> tuple[int, int]:
49
+ # return self._array_shape
50
+ #
51
+ # @TypedProperty[numpy.ndarray, Union[int, ArrayLike]]
52
+ # def array(self) -> numpy.ndarray:
53
+ # return self._array
54
+ #
55
+ # @array.setter
56
+ # def _set_biome(
57
+ # self,
58
+ # array: Union[int, ArrayLike],
59
+ # ) -> None:
60
+ # if isinstance(array, int):
61
+ # self._array = numpy.full(self._array_shape, array, dtype=numpy.uint32)
62
+ # else:
63
+ # array = numpy.asarray(array)
64
+ # if not isinstance(array, numpy.ndarray):
65
+ # raise TypeError
66
+ # if array.shape != self._array_shape or array.dtype != numpy.uint32:
67
+ # raise ValueError
68
+ # self._array = numpy.array(array)
69
+ #
70
+ # @property
71
+ # def palette(self) -> BiomePalette:
72
+ # return self._palette
73
+ #
74
+ #
75
+ # class Biome2DComponent(ChunkComponent[Biome2DComponentData, Biome2DComponentData]):
76
+ # storage_key = b"b2d"
77
+ #
78
+ # @staticmethod
79
+ # def fix_set_data(
80
+ # old_obj: Biome2DComponentData, new_obj: Biome2DComponentData
81
+ # ) -> Biome2DComponentData:
82
+ # if not isinstance(new_obj, Biome2DComponentData):
83
+ # raise TypeError
84
+ # assert isinstance(old_obj, Biome2DComponentData)
85
+ # if (
86
+ # old_obj.array.shape != new_obj.array.shape
87
+ # or old_obj.array_shape != new_obj.array_shape
88
+ # ):
89
+ # raise ValueError("New array shape does not match old array shape.")
90
+ # elif old_obj.palette.version_range != new_obj.palette.version_range:
91
+ # raise ValueError("New version range does not match old version range.")
92
+ # return new_obj
93
+ #
94
+ #
95
+ # class Biome3DComponentData:
96
+ # def __init__(
97
+ # self,
98
+ # version_range: VersionRange,
99
+ # array_shape: tuple[int, int, int],
100
+ # default_biome: Biome,
101
+ # ):
102
+ # self._palette = BiomePalette(version_range)
103
+ # self._palette.biome_to_index(default_biome)
104
+ # self._sections = SubChunkArrayContainer(array_shape, 0)
105
+ #
106
+ # def __getstate__(self) -> tuple[BiomePalette, SubChunkArrayContainer]:
107
+ # return self._palette, self._sections
108
+ #
109
+ # def __setstate__(self, state: tuple[BiomePalette, SubChunkArrayContainer]) -> None:
110
+ # self._palette, self._sections = state
111
+ #
112
+ # @TypedProperty[
113
+ # SubChunkArrayContainer,
114
+ # SubChunkArrayContainer
115
+ # | Mapping[int, numpy.ndarray]
116
+ # | Iterable[tuple[int, numpy.ndarray]],
117
+ # ]
118
+ # def sections(self) -> SubChunkArrayContainer:
119
+ # return self._sections
120
+ #
121
+ # @sections.setter
122
+ # def _set_biome(
123
+ # self,
124
+ # sections: (
125
+ # SubChunkArrayContainer
126
+ # | Mapping[int, numpy.ndarray]
127
+ # | Iterable[tuple[int, numpy.ndarray]]
128
+ # ),
129
+ # ) -> None:
130
+ # if sections is not self._sections:
131
+ # self._sections.clear()
132
+ # self._sections.update(sections)
133
+ # if isinstance(sections, SubChunkArrayContainer):
134
+ # self._sections.default_array = sections.default_array
135
+ #
136
+ # @property
137
+ # def palette(self) -> BiomePalette:
138
+ # return self._palette
139
+ #
140
+ #
141
+ # class Biome3DComponent(ChunkComponent[Biome3DComponentData, Biome3DComponentData]):
142
+ # storage_key = b"b3d"
143
+ #
144
+ # @staticmethod
145
+ # def fix_set_data(
146
+ # old_obj: Biome3DComponentData, new_obj: Biome3DComponentData
147
+ # ) -> Biome3DComponentData:
148
+ # if not isinstance(new_obj, Biome3DComponentData):
149
+ # raise TypeError
150
+ # assert isinstance(old_obj, Biome3DComponentData)
151
+ # if old_obj.sections.array_shape != new_obj.sections.array_shape:
152
+ # raise ValueError("New array shape does not match old array shape.")
153
+ # elif old_obj.palette.version_range != new_obj.palette.version_range:
154
+ # raise ValueError("New version range does not match old version range.")
155
+ # return new_obj
@@ -0,0 +1,117 @@
1
+ # from __future__ import annotations
2
+ #
3
+ # from collections.abc import MutableMapping
4
+ # from typing import Iterator, Any
5
+ #
6
+ # from amulet.data_types import BlockCoordinates
7
+ # from amulet.block_entity import BlockEntity
8
+ # from amulet.version import VersionRange, VersionRangeContainer
9
+ #
10
+ # from .abc import ChunkComponent, UnloadedComponent
11
+ #
12
+ #
13
+ # class BlockEntityComponentData(
14
+ # VersionRangeContainer, MutableMapping[BlockCoordinates, BlockEntity]
15
+ # ):
16
+ # """
17
+ # A MutableMapping that can only store :class:`BlockEntity` instances
18
+ # under the absolute coordinate of the block entity ``Tuple[int, int, int]``
19
+ # """
20
+ #
21
+ # _block_entities: dict[BlockCoordinates, BlockEntity]
22
+ #
23
+ # def __init__(
24
+ # self,
25
+ # version_range: VersionRange,
26
+ # ) -> None:
27
+ # super().__init__(version_range)
28
+ # self._block_entities = {}
29
+ #
30
+ # def __getstate__(self) -> tuple[VersionRange, dict[BlockCoordinates, BlockEntity]]: # type: ignore[override]
31
+ # return (
32
+ # super().__getstate__(),
33
+ # self._block_entities,
34
+ # )
35
+ #
36
+ # def __setstate__(self, state: tuple[VersionRange, dict[BlockCoordinates, BlockEntity]]) -> None: # type: ignore[override]
37
+ # super().__setstate__(state[0])
38
+ # self._block_entities = state[1]
39
+ #
40
+ # def __setitem__(
41
+ # self, coordinate: BlockCoordinates, block_entity: BlockEntity
42
+ # ) -> None:
43
+ # """
44
+ # Set the :class:`BlockEntity` at ``coordinate``.
45
+ #
46
+ # >>> block_entities: BlockEntityComponentData
47
+ # >>> x = y = z = 0
48
+ # >>> block_entities[(x, y, z)] = block_entity
49
+ #
50
+ # :param coordinate: The coordinate to set the block entity at.
51
+ # :param block_entity: The block entity to set at the specified coordinate.
52
+ # """
53
+ # if (
54
+ # not isinstance(coordinate, tuple)
55
+ # and len(coordinate) == 3
56
+ # and all(isinstance(c, int) for c in coordinate)
57
+ # ):
58
+ # raise TypeError
59
+ # if not isinstance(block_entity, BlockEntity):
60
+ # raise TypeError
61
+ # if not self.version_range.contains(block_entity.platform, block_entity.version):
62
+ # raise ValueError(
63
+ # f"block entity {block_entity} is incompatible with {self.version_range}"
64
+ # )
65
+ # self._block_entities[coordinate] = block_entity
66
+ #
67
+ # def __delitem__(self, coordinate: BlockCoordinates) -> None:
68
+ # """
69
+ # Remove the :class:`BlockEntity` at ``coordinate``.
70
+ #
71
+ # :param coordinate: The coordinate to remove the block entity from.
72
+ # """
73
+ # del self._block_entities[coordinate]
74
+ #
75
+ # def __getitem__(self, coordinate: BlockCoordinates) -> BlockEntity:
76
+ # """
77
+ # Get the :class:`BlockEntity` at ``coordinate``.
78
+ #
79
+ # >>> block_entities: BlockEntityComponentData
80
+ # >>> x = y = z = 0
81
+ # >>> block_entity = block_entities[(x, y, z)]
82
+ #
83
+ # :param coordinate: The coordinate to find the block entity at.
84
+ # :return: The block entity at the specified coordinate.
85
+ # :raises:
86
+ # KeyError if there is no BlockEntity at the given coordinate.
87
+ # """
88
+ # return self._block_entities[coordinate]
89
+ #
90
+ # def __len__(self) -> int:
91
+ # return len(self._block_entities)
92
+ #
93
+ # def __iter__(self) -> Iterator[BlockCoordinates]:
94
+ # yield from self._block_entities
95
+ #
96
+ # def __repr__(self) -> str:
97
+ # return (
98
+ # f"BlockEntityContainer({self.version_range!r}) # {len(self)} block entities"
99
+ # )
100
+ #
101
+ #
102
+ # class BlockEntityComponent(
103
+ # ChunkComponent[BlockEntityComponentData, BlockEntityComponentData]
104
+ # ):
105
+ # storage_key = b"be"
106
+ #
107
+ # @staticmethod
108
+ # def fix_set_data(
109
+ # old_obj: BlockEntityComponentData | UnloadedComponent,
110
+ # new_obj: BlockEntityComponentData,
111
+ # ) -> BlockEntityComponentData:
112
+ # if not isinstance(new_obj, BlockEntityComponentData):
113
+ # raise TypeError
114
+ # assert isinstance(old_obj, BlockEntityComponentData)
115
+ # if old_obj.version_range != new_obj.version_range:
116
+ # raise ValueError("New version range does not match old version range.")
117
+ # return new_obj
@@ -0,0 +1,64 @@
1
+ # from __future__ import annotations
2
+ # from typing import Iterator, Any
3
+ # from collections.abc import MutableSet
4
+ #
5
+ # from amulet.entity import Entity
6
+ # from amulet.version import VersionRange, VersionRangeContainer
7
+ # from .abc import ChunkComponent
8
+ #
9
+ #
10
+ # class EntityComponentData(VersionRangeContainer, MutableSet[Entity]):
11
+ # _entities: set[Entity]
12
+ #
13
+ # def __init__(self, version_range: VersionRange):
14
+ # super().__init__(version_range)
15
+ # self._entities = set()
16
+ #
17
+ # def __getstate__(self) -> tuple[VersionRange, set[Entity]]: # type: ignore[override]
18
+ # return (
19
+ # super().__getstate__(),
20
+ # self._entities,
21
+ # )
22
+ #
23
+ # def __setstate__(self, state: tuple[VersionRange, set[Entity]]) -> None: # type: ignore[override]
24
+ # super().__setstate__(state[0])
25
+ # self._entities = state[1]
26
+ #
27
+ # def add(self, entity: Entity) -> None:
28
+ # if not isinstance(entity, Entity):
29
+ # raise TypeError("Expected an Entity")
30
+ # if not self.version_range.contains(entity.platform, entity.version):
31
+ # raise ValueError(
32
+ # f"entity {entity} is incompatible with {self.version_range}"
33
+ # )
34
+ # self._entities.add(entity)
35
+ #
36
+ # def discard(self, entity: Entity) -> None:
37
+ # self._entities.discard(entity)
38
+ #
39
+ # def __contains__(self, entity: object) -> bool:
40
+ # return entity in self._entities
41
+ #
42
+ # def __len__(self) -> int:
43
+ # return len(self._entities)
44
+ #
45
+ # def __iter__(self) -> Iterator[Entity]:
46
+ # yield from self._entities
47
+ #
48
+ # def __repr__(self) -> str:
49
+ # return f"EntityContainer({self.version_range!r}) # {len(self)} entities"
50
+ #
51
+ #
52
+ # class EntityComponent(ChunkComponent[EntityComponentData, EntityComponentData]):
53
+ # storage_key = b"e"
54
+ #
55
+ # @staticmethod
56
+ # def fix_set_data(
57
+ # old_obj: EntityComponentData, new_obj: EntityComponentData
58
+ # ) -> EntityComponentData:
59
+ # if not isinstance(new_obj, EntityComponentData):
60
+ # raise TypeError
61
+ # assert isinstance(old_obj, EntityComponentData)
62
+ # if old_obj.version_range != new_obj.version_range:
63
+ # raise ValueError("New version range does not match old version range.")
64
+ # return new_obj
@@ -0,0 +1,16 @@
1
+ # import numpy
2
+ # from numpy.typing import ArrayLike
3
+ # from .abc import ChunkComponent
4
+ #
5
+ #
6
+ # class Height2DComponent(ChunkComponent[numpy.ndarray, ArrayLike]):
7
+ # storage_key = b"h2d"
8
+ #
9
+ # @staticmethod
10
+ # def fix_set_data(old_obj: numpy.ndarray, new_obj: ArrayLike) -> numpy.ndarray:
11
+ # new_obj = numpy.asarray(new_obj, numpy.int64)
12
+ # if not isinstance(new_obj, numpy.ndarray):
13
+ # raise TypeError
14
+ # if new_obj.shape != old_obj.shape or new_obj.dtype != numpy.int64:
15
+ # raise ValueError
16
+ # return new_obj
@@ -0,0 +1,95 @@
1
+ from __future__ import annotations
2
+
3
+ import types
4
+ import typing
5
+
6
+ import amulet.block
7
+ import amulet.collections
8
+ import amulet.palette.block_palette
9
+ import amulet.version
10
+ import numpy
11
+ import typing_extensions
12
+
13
+ __all__ = ["BlockComponent", "BlockComponentData", "IndexArray3D", "SectionArrayMap"]
14
+
15
+ class BlockComponent:
16
+ ComponentID: typing.ClassVar[str] = "Amulet::BlockComponent"
17
+ block: BlockComponentData
18
+
19
+ class BlockComponentData:
20
+ def __init__(
21
+ self,
22
+ version_range: amulet.version.VersionRange,
23
+ array_shape: tuple[int, int, int],
24
+ default_block: amulet.block.BlockStack,
25
+ ) -> None: ...
26
+ @property
27
+ def palette(self) -> amulet.palette.block_palette.BlockPalette: ...
28
+ @property
29
+ def sections(self) -> SectionArrayMap: ...
30
+
31
+ class IndexArray3D:
32
+ """
33
+ A 3D index array.
34
+ """
35
+
36
+ def __buffer__(self, flags):
37
+ """
38
+ Return a buffer object that exposes the underlying memory of the object.
39
+ """
40
+
41
+ @typing.overload
42
+ def __init__(self, shape: tuple[int, int, int]) -> None: ...
43
+ @typing.overload
44
+ def __init__(self, shape: tuple[int, int, int], value: int) -> None: ...
45
+ @typing.overload
46
+ def __init__(self, other: IndexArray3D) -> None: ...
47
+ @typing.overload
48
+ def __init__(self, arg0: typing_extensions.Buffer) -> None: ...
49
+ def __release_buffer__(self, buffer):
50
+ """
51
+ Release the buffer object that exposes the underlying memory of the object.
52
+ """
53
+
54
+ @property
55
+ def shape(self) -> tuple[int, int, int]: ...
56
+ @property
57
+ def size(self) -> int: ...
58
+
59
+ class SectionArrayMap:
60
+ """
61
+ A container of sub-chunk arrays.
62
+ """
63
+
64
+ def __contains__(self, arg0: int) -> bool: ...
65
+ def __delitem__(self, arg0: int) -> None: ...
66
+ def __eq__(self, arg0: typing.Any) -> bool | types.NotImplementedType: ...
67
+ def __getitem__(self, arg0: int) -> typing.Any: ...
68
+ def __hash__(self) -> int: ...
69
+ def __init__(
70
+ self,
71
+ array_shape: tuple[int, int, int],
72
+ default_array: int | IndexArray3D | typing_extensions.Buffer,
73
+ ) -> None: ...
74
+ def __iter__(self) -> amulet.collections.Iterator: ...
75
+ def __len__(self) -> int: ...
76
+ def __setitem__(
77
+ self, arg0: int, arg1: IndexArray3D | typing_extensions.Buffer
78
+ ) -> None: ...
79
+ def get(self, arg0: typing.Any, arg1: typing.Any) -> typing.Any: ...
80
+ def items(self) -> typing.Any: ...
81
+ def keys(self) -> typing.Any: ...
82
+ def pop(self, key: typing.Any, default: typing.Any = ...) -> typing.Any: ...
83
+ def popitem(self) -> tuple[typing.Any, typing.Any]: ...
84
+ def populate(self, arg0: int) -> None: ...
85
+ def setdefault(self, arg0: typing.Any, arg1: typing.Any) -> typing.Any: ...
86
+ def update(self, other: typing.Any = (), **kwargs) -> None: ...
87
+ def values(self) -> typing.Any: ...
88
+ @property
89
+ def array_shape(self) -> tuple[int, int, int]: ...
90
+ @property
91
+ def default_array(self) -> int | numpy.ndarray: ...
92
+ @default_array.setter
93
+ def default_array(
94
+ self, arg1: int | IndexArray3D | typing_extensions.Buffer
95
+ ) -> None: ...
amulet/collections.pyi ADDED
@@ -0,0 +1,37 @@
1
+ from __future__ import annotations
2
+
3
+ import types
4
+ import typing
5
+
6
+ __all__ = ["Holder", "Iterator", "Mapping", "MutableMapping"]
7
+
8
+ class Holder:
9
+ """
10
+ A utility class for keeping smart pointers alive.
11
+ """
12
+
13
+ class Iterator:
14
+ def __iter__(self: typing.Iterator) -> typing.Iterator: ...
15
+ def __next__(self: typing.Iterator) -> typing.Any: ...
16
+
17
+ class Mapping:
18
+ def __contains__(self, arg0: typing.Any) -> bool: ...
19
+ def __eq__(self, arg0: typing.Any) -> bool | types.NotImplementedType: ...
20
+ def __getitem__(self, arg0: typing.Any) -> typing.Any: ...
21
+ def __hash__(self) -> int: ...
22
+ def __iter__(self) -> typing.Iterator: ...
23
+ def __len__(self) -> int: ...
24
+ def __repr__(self) -> str: ...
25
+ def get(self, arg0: typing.Any, arg1: typing.Any) -> typing.Any: ...
26
+ def items(self) -> typing.Any: ...
27
+ def keys(self) -> typing.Any: ...
28
+ def values(self) -> typing.Any: ...
29
+
30
+ class MutableMapping(Mapping):
31
+ def __delitem__(self, arg0: typing.Any) -> None: ...
32
+ def __setitem__(self, arg0: typing.Any, arg1: typing.Any) -> None: ...
33
+ def clear(self) -> None: ...
34
+ def pop(self, key: typing.Any, default: typing.Any = ...) -> typing.Any: ...
35
+ def popitem(self) -> tuple[typing.Any, typing.Any]: ...
36
+ def setdefault(self, arg0: typing.Any, arg1: typing.Any) -> typing.Any: ...
37
+ def update(self, other: typing.Any = (), **kwargs) -> None: ...
amulet/data_types.py ADDED
@@ -0,0 +1,29 @@
1
+ from typing import TypeAlias
2
+ import numpy
3
+
4
+ #: The type for a dimension identifier
5
+ DimensionId: TypeAlias = str
6
+
7
+ #: The data type for the x and z coordinates of a region file. Note these are no the same as block coordinates.
8
+ RegionCoordinates: TypeAlias = tuple[int, int]
9
+
10
+ #: The data type for the x and z coordinate of a chunk. Note these are no the same as block coordinates.
11
+ ChunkCoordinates: TypeAlias = tuple[int, int]
12
+
13
+ #: The data type for the x, y and z coordinates of a sub-chunk within the world. Note these are no the same as block coordinates.
14
+ SubChunkCoordinates: TypeAlias = tuple[int, int, int]
15
+
16
+ #: The data type for the x, y and z location of a block within the world.
17
+ BlockCoordinates: TypeAlias = tuple[int, int, int]
18
+
19
+ #: The data type for the x, y and z location of a block within the world in the form of a numpy array.
20
+ BlockCoordinatesArray: TypeAlias = numpy.ndarray # NDArray[(3, ), int]
21
+
22
+ #: The data type for the x, y and z location of a point within the world.
23
+ PointCoordinates: TypeAlias = tuple[float, float, float]
24
+
25
+ #: The data type for the x, y and z location of a point within the world in the form of a numpy array.
26
+ PointCoordinatesArray: TypeAlias = numpy.ndarray # NDArray[(3, ), numpy.float]
27
+
28
+ #: The data type for a tuple containing three floats. Use :data:`PointCoordinates` for x, y, z float coordinates.
29
+ FloatTriplet: TypeAlias = tuple[float, float, float]
amulet/entity.py ADDED
@@ -0,0 +1,180 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any
4
+ from amulet_nbt import NamedTag
5
+ from amulet.version import PlatformVersionContainer, VersionNumber
6
+ from amulet.data_types import PointCoordinates
7
+
8
+
9
+ class Entity(PlatformVersionContainer):
10
+ """
11
+ A class to contain all the data to define an Entity.
12
+ """
13
+
14
+ __slots__ = (
15
+ "_namespace",
16
+ "_base_name",
17
+ "_x",
18
+ "_y",
19
+ "_z",
20
+ "_nbt",
21
+ )
22
+
23
+ def __init__(
24
+ self,
25
+ platform: str,
26
+ version: VersionNumber,
27
+ namespace: str,
28
+ base_name: str,
29
+ x: float,
30
+ y: float,
31
+ z: float,
32
+ nbt: NamedTag,
33
+ ) -> None:
34
+ """
35
+ Constructs a :class:`Entity` instance.
36
+
37
+ :param platform: The platform the entity is defined in.
38
+ :param version: The version the entity is defined in.
39
+ :param namespace: The namespace of the entity eg "minecraft"
40
+ :param base_name: The base name of the entity eg "creeper"
41
+ :param x: The x coordinate of the entity
42
+ :param y: The y coordinate of the entity
43
+ :param z: The z coordinate of the entity
44
+ :param nbt: The NBT stored with the entity
45
+ """
46
+ super().__init__(platform, version)
47
+ self._namespace = str(namespace)
48
+ self._base_name = str(base_name)
49
+ self._x = float(x)
50
+ self._y = float(y)
51
+ self._z = float(z)
52
+ if not isinstance(nbt, NamedTag):
53
+ raise TypeError(f"nbt must be an NamedTag. Got {nbt}")
54
+ self._nbt = nbt
55
+
56
+ def __getstate__(self) -> tuple[tuple[str, VersionNumber], tuple[str, str, float, float, float, NamedTag]]: # type: ignore[override]
57
+ return (
58
+ super().__getstate__(),
59
+ (
60
+ self._namespace,
61
+ self._base_name,
62
+ self._x,
63
+ self._y,
64
+ self._z,
65
+ self._nbt,
66
+ ),
67
+ )
68
+
69
+ def __setstate__(self, state: tuple[tuple[str, VersionNumber], tuple[str, str, float, float, float, NamedTag]]) -> None: # type: ignore[override]
70
+ super().__setstate__(state[0])
71
+ (
72
+ self._namespace,
73
+ self._base_name,
74
+ self._x,
75
+ self._y,
76
+ self._z,
77
+ self._nbt,
78
+ ) = state[1]
79
+
80
+ def __eq__(self, other: Any) -> bool:
81
+ if not isinstance(other, Entity):
82
+ return NotImplemented
83
+ return self.__getstate__() == other.__getstate__()
84
+
85
+ def __hash__(self) -> int:
86
+ return id(self)
87
+
88
+ def __repr__(self) -> str:
89
+ return f"Entity({self.platform!r}, {self.version!r}, {self._namespace!r}, {self._base_name!r}, {self._x}, {self._y}, {self._z}, {self._nbt!r})"
90
+
91
+ @property
92
+ def namespaced_name(self) -> str:
93
+ """
94
+ The namespace:base_name of the entity represented by the object (eg: `minecraft:creeper`)
95
+
96
+ If the given namespace is an empty string it will just return the base name.
97
+
98
+ :return: namespace:base_name of the entity
99
+ """
100
+ return f"{self._namespace}:{self._base_name}"
101
+
102
+ @property
103
+ def namespace(self) -> str:
104
+ """
105
+ The namespace of the entity represented by the Entity object (eg: `minecraft`)
106
+
107
+ :return: The namespace of the entity
108
+ """
109
+ return self._namespace
110
+
111
+ @namespace.setter
112
+ def namespace(self, value: str) -> None:
113
+ self._namespace = value
114
+
115
+ @property
116
+ def base_name(self) -> str:
117
+ """
118
+ The base name of the entity represented by the Entity object (eg: `creeper`, `pig`)
119
+
120
+ :return: The base name of the entity
121
+ """
122
+ return self._base_name
123
+
124
+ @base_name.setter
125
+ def base_name(self, value: str) -> None:
126
+ self._base_name = value
127
+
128
+ @property
129
+ def x(self) -> float:
130
+ """The x location of the Entity."""
131
+ return self._x
132
+
133
+ @x.setter
134
+ def x(self, value: float) -> None:
135
+ self._x = float(value)
136
+
137
+ @property
138
+ def y(self) -> float:
139
+ """The y location of the Entity."""
140
+ return self._y
141
+
142
+ @y.setter
143
+ def y(self, value: float) -> None:
144
+ self._y = float(value)
145
+
146
+ @property
147
+ def z(self) -> float:
148
+ """The z location of the Entity."""
149
+ return self._z
150
+
151
+ @z.setter
152
+ def z(self, value: float) -> None:
153
+ self._z = float(value)
154
+
155
+ @property
156
+ def location(self) -> PointCoordinates:
157
+ """The location of the Entity."""
158
+ return self._x, self._y, self._z
159
+
160
+ @location.setter
161
+ def location(self, location: PointCoordinates) -> None:
162
+ self.x, self.y, self.z = location
163
+
164
+ @property
165
+ def nbt(self) -> NamedTag:
166
+ """
167
+ The NBT behind the object
168
+
169
+ :getter: Get the NBT data stored in the object
170
+ :setter: Set the NBT data stored in the object
171
+
172
+ :return: A NamedTag
173
+ """
174
+ return self._nbt
175
+
176
+ @nbt.setter
177
+ def nbt(self, value: NamedTag) -> None:
178
+ if not isinstance(value, NamedTag):
179
+ raise TypeError
180
+ self._nbt = value