amulet-core 2.0a5__cp311-cp311-macosx_10_9_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-311-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,223 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import NamedTuple
4
+ import threading
5
+ from bisect import bisect_left, bisect_right
6
+
7
+
8
+ class NoValidSector(Exception):
9
+ """An error for when there is no sector large enough and the region cannot be resized."""
10
+
11
+ pass
12
+
13
+
14
+ class Sector(NamedTuple):
15
+ start: int
16
+ stop: int
17
+
18
+ @property
19
+ def length(self) -> int:
20
+ return self.stop - self.start
21
+
22
+ def intersects(self, other: Sector) -> bool:
23
+ """Do the two sectors intersect each other."""
24
+ return not (other.stop <= self.start or self.stop <= other.start)
25
+
26
+ def contains(self, other: Sector) -> bool:
27
+ """Is the other sector entirely within this sector."""
28
+ return self.start <= other.start and other.stop <= self.stop
29
+
30
+ def neighbours(self, other: Sector) -> bool:
31
+ """Do the two sectors neighbour but not intersect."""
32
+ return other.stop == self.start or self.stop == other.start
33
+
34
+ def split(self, other: Sector) -> list[Sector]:
35
+ """
36
+ Split this sector around another sector.
37
+ The other sector must be contained within this sector
38
+
39
+ :param other: The other sector to split around.
40
+ :return: A list of 0-2 sectors
41
+ """
42
+ sectors = []
43
+ if self.start < other.start:
44
+ sectors.append(Sector(self.start, other.start))
45
+ if other.stop < self.stop:
46
+ sectors.append(Sector(other.stop, self.stop))
47
+ return sectors
48
+
49
+
50
+ class SectorManager:
51
+ """A class to manage a sequence of memory."""
52
+
53
+ def __init__(self, start: int, stop: int, resizable: bool = True):
54
+ """
55
+ :param start: The start of the memory region
56
+ :param stop: The end of the memory region
57
+ :param resizable: Can the region be resized
58
+ """
59
+ if stop < start:
60
+ raise ValueError("stop must be at least start")
61
+ self._lock = threading.RLock()
62
+ self._stop = stop
63
+ self._resizable = resizable
64
+
65
+ # A list of free sectors ordered by start location
66
+ self._free_start = [Sector(start, stop)]
67
+ # A list of free sectors ordered by (length, start).
68
+ # This makes it easier to find the first sector large enough
69
+ self._free_size = [Sector(start, stop)]
70
+
71
+ # A set of reserved sectors
72
+ self._reserved: set[Sector] = set()
73
+
74
+ @property
75
+ def sectors(self) -> list[Sector]:
76
+ """A list of reserved sectors. Ordered by their start location."""
77
+ with self._lock:
78
+ return list(sorted(self._reserved, key=lambda i: i.start))
79
+
80
+ def reserve_space(self, length: int) -> Sector:
81
+ """
82
+ Find and reserve a memory location large enough to fit the requested memory.
83
+
84
+ :param length: The length of the memory region to reserve
85
+ :return: The index of the start of the reserved memory region
86
+ """
87
+ if not length:
88
+ raise ValueError("Cannot reserve a sector with zero length.")
89
+ with self._lock:
90
+ # find the index of the first element with a larger or equal length prioritising the ones closer to the start
91
+ index = bisect_left(
92
+ self._free_size, (length, 0), key=lambda k: (k.length, k.start)
93
+ )
94
+ if index < len(self._free_size):
95
+ # if there exists a section large enough to fit the length
96
+ free_sector = self._free_size.pop(index)
97
+ start_index = self._free_start.index(free_sector)
98
+ sector = Sector(free_sector.start, free_sector.start + length)
99
+ if free_sector.length > length:
100
+ free_sector = Sector(sector.stop, free_sector.stop)
101
+ self._add_size_sector(free_sector)
102
+ self._free_start[start_index] = free_sector
103
+ else:
104
+ del self._free_start[start_index]
105
+ self._reserved.add(sector)
106
+ return sector
107
+ elif self._resizable:
108
+ sector = Sector(self._stop, self._stop + length)
109
+ self._stop = sector.stop
110
+ self._reserved.add(sector)
111
+ return sector
112
+ else:
113
+ raise NoValidSector(
114
+ "There is not enough contiguous space to allocate the length."
115
+ )
116
+
117
+ def reserve(self, sector: Sector) -> None:
118
+ """
119
+ Mark a section as reserved.
120
+ If you don't know exactly where the sector is use `reserve_space` to find and reserve a new sector
121
+
122
+ :param sector: The sector to reserve
123
+ """
124
+ if not sector.length:
125
+ raise ValueError("Cannot reserve a sector with zero length.")
126
+ with self._lock:
127
+ if sector.start >= self._stop and (
128
+ not self._free_start or self._free_start[-1].stop != self._stop
129
+ ):
130
+ if self._resizable:
131
+ # if the last sector has been reserved or did not exist then create a new one
132
+ s = Sector(self._stop, sector.stop)
133
+ self._free_start.append(s)
134
+ self._add_size_sector(s)
135
+ self._stop = sector.stop
136
+ else:
137
+ raise NoValidSector("The sector starts outside of the region.")
138
+
139
+ # Get the index of the segment with the latest start point that is
140
+ # less than or equal to the start point of the sector being reserved.
141
+ index = (
142
+ bisect_right(self._free_start, sector.start, key=lambda k: k.start) - 1
143
+ )
144
+
145
+ if index < 0:
146
+ raise NoValidSector(
147
+ "No free sectors that start at or before the one being reserved."
148
+ )
149
+
150
+ free_sector = self._free_start[index]
151
+
152
+ if sector.stop <= free_sector.stop:
153
+ # The sector fits within the contained sector
154
+ # remove the contained sector from the lists
155
+ del self._free_start[index]
156
+ self._free_size.remove(free_sector)
157
+ elif free_sector.stop == self._stop:
158
+ if self._resizable:
159
+ # The sector is the last one and the memory region is resizable
160
+ del self._free_start[index]
161
+ self._free_size.remove(free_sector)
162
+ free_sector = Sector(free_sector.start, sector.stop)
163
+ self._stop = sector.stop
164
+ else:
165
+ raise NoValidSector(
166
+ "The sector is outside the defined region and the region is not resizable."
167
+ )
168
+ else:
169
+ raise NoValidSector("The requested sector is not free to be reserved.")
170
+
171
+ # split around the reserved sector
172
+ sectors = free_sector.split(sector)
173
+ # add the results back
174
+ self._free_start[index:index] = sectors
175
+ for s in sectors:
176
+ self._add_size_sector(s)
177
+ self._reserved.add(sector)
178
+
179
+ def _add_size_sector(self, sector: Sector) -> None:
180
+ self._free_size.insert(
181
+ bisect_left(
182
+ self._free_size,
183
+ (sector.length, sector.start),
184
+ key=lambda k: (k.length, k.start),
185
+ ),
186
+ sector,
187
+ )
188
+
189
+ def free(self, sector: Sector) -> None:
190
+ """
191
+ Free a reserved sector.
192
+ The sector must match exactly a sector previously reserved.
193
+
194
+ :param sector: The sector to free
195
+ """
196
+ with self._lock:
197
+ if sector not in self._reserved:
198
+ raise ValueError("Sector was not reserved")
199
+ # remove the sector from the reserved storage
200
+ self._reserved.remove(sector)
201
+
202
+ # Add it back to the free storage
203
+ # find the position where it would be placed in the list ordered by start location
204
+ index = bisect_right(self._free_start, sector.start, key=lambda k: k.start)
205
+
206
+ # merge with the right neighbour
207
+ if (
208
+ index < len(self._free_start)
209
+ and self._free_start[index].start == sector.stop
210
+ ):
211
+ right_sector = self._free_start.pop(index)
212
+ self._free_size.remove(right_sector)
213
+ sector = Sector(sector.start, right_sector.stop)
214
+
215
+ # merge with the left neighbour
216
+ if index > 0 and self._free_start[index - 1].stop == sector.start:
217
+ left_sector = self._free_start.pop(index - 1)
218
+ self._free_size.remove(left_sector)
219
+ sector = Sector(left_sector.start, sector.stop)
220
+ index -= 1
221
+
222
+ self._free_start.insert(index, sector)
223
+ self._add_size_sector(sector)
@@ -0,0 +1,142 @@
1
+ from __future__ import annotations
2
+
3
+ import threading as threading
4
+ import typing
5
+ from typing import NamedTuple
6
+
7
+ from _bisect import bisect_left, bisect_right
8
+
9
+ __all__ = [
10
+ "NamedTuple",
11
+ "NoValidSector",
12
+ "Sector",
13
+ "SectorManager",
14
+ "bisect_left",
15
+ "bisect_right",
16
+ "threading",
17
+ ]
18
+
19
+ class NoValidSector(Exception):
20
+ """
21
+ An error for when there is no sector large enough and the region cannot be resized.
22
+ """
23
+
24
+ class Sector(tuple):
25
+ """
26
+ Sector(start, stop)
27
+ """
28
+
29
+ __slots__: typing.ClassVar[tuple] = tuple()
30
+ _field_defaults: typing.ClassVar[dict] = {}
31
+ _fields: typing.ClassVar[tuple] = ("start", "stop")
32
+ @staticmethod
33
+ def __new__(_cls, start: ForwardRef("int"), stop: ForwardRef("int")):
34
+ """
35
+ Create new instance of Sector(start, stop)
36
+ """
37
+
38
+ @classmethod
39
+ def _make(cls, iterable):
40
+ """
41
+ Make a new Sector object from a sequence or iterable
42
+ """
43
+
44
+ def __getnewargs__(self):
45
+ """
46
+ Return self as a plain tuple. Used by copy and pickle.
47
+ """
48
+
49
+ def __repr__(self):
50
+ """
51
+ Return a nicely formatted representation string
52
+ """
53
+
54
+ def _asdict(self):
55
+ """
56
+ Return a new dict which maps field names to their values.
57
+ """
58
+
59
+ def _replace(self, **kwds):
60
+ """
61
+ Return a new Sector object replacing specified fields with new values
62
+ """
63
+
64
+ def contains(self, other: Sector) -> bool:
65
+ """
66
+ Is the other sector entirely within this sector.
67
+ """
68
+
69
+ def intersects(self, other: Sector) -> bool:
70
+ """
71
+ Do the two sectors intersect each other.
72
+ """
73
+
74
+ def neighbours(self, other: Sector) -> bool:
75
+ """
76
+ Do the two sectors neighbour but not intersect.
77
+ """
78
+
79
+ def split(self, other: Sector) -> list[Sector]:
80
+ """
81
+
82
+ Split this sector around another sector.
83
+ The other sector must be contained within this sector
84
+
85
+ :param other: The other sector to split around.
86
+ :return: A list of 0-2 sectors
87
+
88
+ """
89
+
90
+ @property
91
+ def length(self) -> int: ...
92
+
93
+ class SectorManager:
94
+ """
95
+ A class to manage a sequence of memory.
96
+ """
97
+
98
+ def __init__(self, start: int, stop: int, resizable: bool = True):
99
+ """
100
+
101
+ :param start: The start of the memory region
102
+ :param stop: The end of the memory region
103
+ :param resizable: Can the region be resized
104
+
105
+ """
106
+
107
+ def _add_size_sector(self, sector: Sector) -> None: ...
108
+ def free(self, sector: Sector) -> None:
109
+ """
110
+
111
+ Free a reserved sector.
112
+ The sector must match exactly a sector previously reserved.
113
+
114
+ :param sector: The sector to free
115
+
116
+ """
117
+
118
+ def reserve(self, sector: Sector) -> None:
119
+ """
120
+
121
+ Mark a section as reserved.
122
+ If you don't know exactly where the sector is use `reserve_space` to find and reserve a new sector
123
+
124
+ :param sector: The sector to reserve
125
+
126
+ """
127
+
128
+ def reserve_space(self, length: int) -> Sector:
129
+ """
130
+
131
+ Find and reserve a memory location large enough to fit the requested memory.
132
+
133
+ :param length: The length of the memory region to reserve
134
+ :return: The index of the start of the reserved memory region
135
+
136
+ """
137
+
138
+ @property
139
+ def sectors(self) -> list[Sector]:
140
+ """
141
+ A list of reserved sectors. Ordered by their start location.
142
+ """
@@ -0,0 +1,81 @@
1
+ from __future__ import annotations
2
+
3
+ import amulet.biome
4
+ import amulet.block
5
+ import amulet.chunk
6
+ import amulet.chunk_components
7
+ import amulet.level.java.chunk_components
8
+
9
+ __all__ = [
10
+ "JavaChunk",
11
+ "JavaChunk0",
12
+ "JavaChunk1444",
13
+ "JavaChunk1466",
14
+ "JavaChunk2203",
15
+ "JavaChunkNA",
16
+ ]
17
+
18
+ class JavaChunk(amulet.chunk.Chunk):
19
+ pass
20
+
21
+ class JavaChunk0(
22
+ JavaChunk,
23
+ amulet.level.java.chunk_components.JavaRawChunkComponent,
24
+ amulet.level.java.chunk_components.DataVersionComponent,
25
+ amulet.chunk_components.BlockComponent,
26
+ ):
27
+ def __init__(
28
+ self,
29
+ data_version: int,
30
+ default_block: amulet.block.BlockStack,
31
+ default_biome: amulet.biome.Biome,
32
+ ) -> None: ...
33
+
34
+ class JavaChunk1444(
35
+ JavaChunk,
36
+ amulet.level.java.chunk_components.JavaRawChunkComponent,
37
+ amulet.level.java.chunk_components.DataVersionComponent,
38
+ amulet.chunk_components.BlockComponent,
39
+ ):
40
+ def __init__(
41
+ self,
42
+ data_version: int,
43
+ default_block: amulet.block.BlockStack,
44
+ default_biome: amulet.biome.Biome,
45
+ ) -> None: ...
46
+
47
+ class JavaChunk1466(
48
+ JavaChunk,
49
+ amulet.level.java.chunk_components.JavaRawChunkComponent,
50
+ amulet.level.java.chunk_components.DataVersionComponent,
51
+ amulet.chunk_components.BlockComponent,
52
+ ):
53
+ def __init__(
54
+ self,
55
+ data_version: int,
56
+ default_block: amulet.block.BlockStack,
57
+ default_biome: amulet.biome.Biome,
58
+ ) -> None: ...
59
+
60
+ class JavaChunk2203(
61
+ JavaChunk,
62
+ amulet.level.java.chunk_components.JavaRawChunkComponent,
63
+ amulet.level.java.chunk_components.DataVersionComponent,
64
+ amulet.chunk_components.BlockComponent,
65
+ ):
66
+ def __init__(
67
+ self,
68
+ data_version: int,
69
+ default_block: amulet.block.BlockStack,
70
+ default_biome: amulet.biome.Biome,
71
+ ) -> None: ...
72
+
73
+ class JavaChunkNA(
74
+ JavaChunk,
75
+ amulet.level.java.chunk_components.JavaRawChunkComponent,
76
+ amulet.level.java.chunk_components.DataVersionComponent,
77
+ amulet.chunk_components.BlockComponent,
78
+ ):
79
+ def __init__(
80
+ self, default_block: amulet.block.BlockStack, default_biome: amulet.biome.Biome
81
+ ) -> None: ...
@@ -0,0 +1,260 @@
1
+ # from typing import Self, TypeAlias, cast
2
+ # from types import UnionType
3
+ #
4
+ # import numpy
5
+ #
6
+ # from amulet.version import VersionRange, VersionNumber
7
+ # from amulet.block import BlockStack, Block
8
+ # from amulet.biome import Biome
9
+ #
10
+ # from amulet.chunk import Chunk, ComponentDataMapping
11
+ # from amulet.chunk.components.height_2d import Height2DComponent
12
+ # from amulet.chunk.components.biome import (
13
+ # Biome2DComponent,
14
+ # Biome2DComponentData,
15
+ # Biome3DComponent,
16
+ # Biome3DComponentData,
17
+ # )
18
+ # from amulet.chunk.components.block import BlockComponent, BlockComponentData
19
+ # from amulet.chunk.components.block_entity import (
20
+ # BlockEntityComponent,
21
+ # BlockEntityComponentData,
22
+ # )
23
+ # from amulet.chunk.components.entity import EntityComponent, EntityComponentData
24
+ # from amulet.level.java.chunk.components.raw_chunk import RawChunkComponent
25
+ # from amulet.level.java.chunk.components.data_version import DataVersionComponent
26
+ # from amulet.level.java.chunk.components.legacy_version import LegacyVersionComponent
27
+ # from amulet.level.java.chunk.components.status import StatusComponent
28
+ # from amulet.level.java.chunk.components.light_populated import LightPopulatedComponent
29
+ # from amulet.level.java.chunk.components.terrain_populated import (
30
+ # TerrainPopulatedComponent,
31
+ # )
32
+ # from amulet.level.java.chunk.components.named_height_2d import (
33
+ # NamedHeight2DComponent,
34
+ # NamedHeight2DData,
35
+ # )
36
+ # from amulet.level.java.chunk.components.last_update import LastUpdateComponent
37
+ #
38
+ #
39
+ # def _get_components(
40
+ # data_version: int, default_block: BlockStack, default_biome: Biome
41
+ # ) -> ComponentDataMapping:
42
+ # components: ComponentDataMapping = {} # type: ignore
43
+ #
44
+ # version_range = VersionRange(
45
+ # "java", VersionNumber(data_version), VersionNumber(data_version)
46
+ # )
47
+ #
48
+ # components[RawChunkComponent] = None
49
+ # components[DataVersionComponent] = data_version
50
+ # components[LastUpdateComponent] = 0
51
+ #
52
+ # if data_version == -1:
53
+ # components[LegacyVersionComponent] = 1
54
+ # if data_version >= 3454:
55
+ # components[StatusComponent] = "minecraft:full"
56
+ # elif data_version >= 1912:
57
+ # components[StatusComponent] = "full"
58
+ # elif data_version >= 1444:
59
+ # components[StatusComponent] = "postprocessed"
60
+ # else:
61
+ # components[TerrainPopulatedComponent] = True
62
+ # components[LightPopulatedComponent] = True
63
+ #
64
+ # components[BlockComponent] = BlockComponentData(
65
+ # version_range, (16, 16, 16), default_block
66
+ # )
67
+ # components[BlockEntityComponent] = BlockEntityComponentData(version_range)
68
+ # components[EntityComponent] = EntityComponentData(version_range)
69
+ #
70
+ # if data_version >= 2203:
71
+ # components[Biome3DComponent] = Biome3DComponentData(
72
+ # version_range, (4, 4, 4), default_biome
73
+ # )
74
+ # else:
75
+ # components[Biome2DComponent] = Biome2DComponentData(
76
+ # version_range, (16, 16), default_biome
77
+ # )
78
+ #
79
+ # if data_version >= 1908:
80
+ # components[NamedHeight2DComponent] = NamedHeight2DData(
81
+ # (16, 16),
82
+ # {
83
+ # key: numpy.zeros((16, 16), dtype=numpy.int64)
84
+ # for key in (
85
+ # "WORLD_SURFACE_WG",
86
+ # "OCEAN_FLOOR_WG",
87
+ # "MOTION_BLOCKING",
88
+ # "MOTION_BLOCKING_NO_LEAVES",
89
+ # "OCEAN_FLOOR",
90
+ # "WORLD_SURFACE",
91
+ # )
92
+ # },
93
+ # )
94
+ # if data_version >= 1503:
95
+ # components[NamedHeight2DComponent] = NamedHeight2DData(
96
+ # (16, 16),
97
+ # {
98
+ # key: numpy.zeros((16, 16), dtype=numpy.int64)
99
+ # for key in (
100
+ # "WORLD_SURFACE_WG",
101
+ # "OCEAN_FLOOR_WG",
102
+ # "MOTION_BLOCKING",
103
+ # "MOTION_BLOCKING_NO_LEAVES",
104
+ # "OCEAN_FLOOR",
105
+ # "LIGHT_BLOCKING",
106
+ # "WORLD_SURFACE",
107
+ # )
108
+ # },
109
+ # )
110
+ # if data_version >= 1484:
111
+ # components[NamedHeight2DComponent] = NamedHeight2DData(
112
+ # (16, 16),
113
+ # {
114
+ # key: numpy.zeros((16, 16), dtype=numpy.int64)
115
+ # for key in (
116
+ # "WORLD_SURFACE_WG",
117
+ # "OCEAN_FLOOR_WG",
118
+ # "MOTION_BLOCKING",
119
+ # "MOTION_BLOCKING_NO_LEAVES",
120
+ # "OCEAN_FLOOR",
121
+ # "LIGHT_BLOCKING",
122
+ # )
123
+ # },
124
+ # )
125
+ # if data_version >= 1466:
126
+ # components[NamedHeight2DComponent] = NamedHeight2DData(
127
+ # (16, 16),
128
+ # {
129
+ # key: numpy.zeros((16, 16), dtype=numpy.int64)
130
+ # for key in ("LIQUID", "SOLID", "LIGHT", "RAIN")
131
+ # },
132
+ # )
133
+ # else:
134
+ # components[Height2DComponent] = numpy.zeros((16, 16), dtype=numpy.int64)
135
+ #
136
+ # return components
137
+ #
138
+ #
139
+ # class JavaChunkNA(Chunk):
140
+ # components = frozenset(
141
+ # _get_components(
142
+ # -1,
143
+ # BlockStack(Block("java", VersionNumber(-1), "", "")),
144
+ # Biome("java", VersionNumber(-1), "", ""),
145
+ # )
146
+ # )
147
+ #
148
+ # @classmethod
149
+ # def new(cls, default_block: BlockStack, default_biome: Biome) -> Self:
150
+ # self = cls.from_component_data(
151
+ # _get_components(-1, default_block, default_biome)
152
+ # )
153
+ # return self
154
+ #
155
+ #
156
+ # class JavaChunk0(Chunk):
157
+ # """Added DataVersion"""
158
+ #
159
+ # components = frozenset(
160
+ # _get_components(
161
+ # 0,
162
+ # BlockStack(Block("java", VersionNumber(0), "", "")),
163
+ # Biome("java", VersionNumber(0), "", ""),
164
+ # )
165
+ # )
166
+ #
167
+ # @classmethod
168
+ # def new(
169
+ # cls, data_version: int, default_block: BlockStack, default_biome: Biome
170
+ # ) -> Self:
171
+ # if not 0 <= data_version < 1444:
172
+ # raise ValueError("data version must be between 0 and 1443")
173
+ # self = cls.from_component_data(
174
+ # _get_components(data_version, default_block, default_biome)
175
+ # )
176
+ # return self
177
+ #
178
+ #
179
+ # class JavaChunk1444(Chunk):
180
+ # """
181
+ # Moved TerrainPopulated and LightPopulated to Status
182
+ # Made blocks paletted
183
+ # Added more tick tags
184
+ # Added structures tag
185
+ # """
186
+ #
187
+ # components = frozenset(
188
+ # _get_components(
189
+ # 1444,
190
+ # BlockStack(Block("java", VersionNumber(1444), "", "")),
191
+ # Biome("java", VersionNumber(1444), "", ""),
192
+ # )
193
+ # )
194
+ #
195
+ # @classmethod
196
+ # def new(
197
+ # cls, data_version: int, default_block: BlockStack, default_biome: Biome
198
+ # ) -> Self:
199
+ # if not 1444 <= data_version < 1466:
200
+ # raise ValueError("data version must be between 1444 and 1465")
201
+ # self = cls.from_component_data(
202
+ # _get_components(data_version, default_block, default_biome)
203
+ # )
204
+ # return self
205
+ #
206
+ #
207
+ # class JavaChunk1466(Chunk):
208
+ # """
209
+ # Added multiple height maps. Now stored in a compound.
210
+ # """
211
+ #
212
+ # components = frozenset(
213
+ # _get_components(
214
+ # 1466,
215
+ # BlockStack(Block("java", VersionNumber(1466), "", "")),
216
+ # Biome("java", VersionNumber(1466), "", ""),
217
+ # )
218
+ # )
219
+ #
220
+ # @classmethod
221
+ # def new(
222
+ # cls, data_version: int, default_block: BlockStack, default_biome: Biome
223
+ # ) -> Self:
224
+ # if not 1466 <= data_version < 2203:
225
+ # raise ValueError("data version must be between 1466 and 2202")
226
+ # self = cls.from_component_data(
227
+ # _get_components(data_version, default_block, default_biome)
228
+ # )
229
+ # return self
230
+ #
231
+ #
232
+ # class JavaChunk2203(Chunk):
233
+ # """
234
+ # Made biomes 3D
235
+ # """
236
+ #
237
+ # components = frozenset(
238
+ # _get_components(
239
+ # 2203,
240
+ # BlockStack(Block("java", VersionNumber(2203), "", "")),
241
+ # Biome("java", VersionNumber(2203), "", ""),
242
+ # )
243
+ # )
244
+ #
245
+ # @classmethod
246
+ # def new(
247
+ # cls, data_version: int, default_block: BlockStack, default_biome: Biome
248
+ # ) -> Self:
249
+ # if not 2203 <= data_version:
250
+ # raise ValueError("data version must be at least 2203")
251
+ # self = cls.from_component_data(
252
+ # _get_components(data_version, default_block, default_biome)
253
+ # )
254
+ # return self
255
+ #
256
+ #
257
+ # # TODO: Improve this if python/mypy#11673 gets fixed.
258
+ # JavaChunk: TypeAlias = cast(
259
+ # UnionType, JavaChunkNA | JavaChunk0 | JavaChunk1444 | JavaChunk1466 | JavaChunk2203
260
+ # )