amulet-core 2.0a6__cp311-cp311-win_amd64.whl → 2.0a7__cp311-cp311-win_amd64.whl

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

Potentially problematic release.


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

Files changed (201) hide show
  1. amulet/__init__.cp311-win_amd64.pyd +0 -0
  2. amulet/__init__.py.cpp +4 -0
  3. amulet/__init__.pyi +0 -2
  4. amulet/_init.py +0 -2
  5. amulet/_version.py +3 -3
  6. amulet/biome.pyi +0 -2
  7. amulet/block.pyi +0 -2
  8. amulet/block_entity.pyi +0 -2
  9. amulet/chunk.pyi +0 -2
  10. amulet/chunk_components.pyi +20 -18
  11. amulet/collections/eq.py.hpp +1 -1
  12. amulet/collections/mapping.py.hpp +18 -11
  13. amulet/collections/mutable_mapping.py.hpp +17 -6
  14. amulet/collections/sequence.py.hpp +5 -6
  15. amulet/collections.pyi +8 -5
  16. amulet/entity.py +22 -20
  17. amulet/game/translate/_functions/_code_functions/_text.py +2 -2
  18. amulet/game/translate/_functions/abc.py +10 -3
  19. amulet/img/__init__.py +10 -0
  20. amulet/img/missing_no.png +0 -0
  21. amulet/img/missing_pack.png +0 -0
  22. amulet/level/__init__.pyi +2 -6
  23. amulet/level/abc/_level/_creatable_level.py +1 -2
  24. amulet/level/abc/_level/_level.py +1 -5
  25. amulet/level/java/__init__.pyi +0 -5
  26. amulet/level/java/_raw/__init__.pyi +0 -4
  27. amulet/level/java/_raw/java_chunk_decode.cpp +2 -4
  28. amulet/level/java/long_array.pyi +2 -1
  29. amulet/mesh/block/__init__.py +1 -0
  30. amulet/mesh/block/block_mesh.py +369 -0
  31. amulet/mesh/block/cube.py +149 -0
  32. amulet/mesh/block/missing_block.py +20 -0
  33. amulet/mesh/util.py +17 -0
  34. amulet/player.py +4 -6
  35. amulet/pybind11/collections.hpp +80 -38
  36. amulet/pybind11/numpy.hpp +26 -0
  37. amulet/pybind11/py_module.hpp +16 -51
  38. amulet/pybind11/type_hints.hpp +51 -0
  39. amulet/pybind11/types.hpp +14 -6
  40. amulet/pybind11/typing.hpp +7 -0
  41. amulet/resource_pack/__init__.py +62 -0
  42. amulet/resource_pack/abc/__init__.py +2 -0
  43. amulet/resource_pack/abc/resource_pack.py +38 -0
  44. amulet/resource_pack/abc/resource_pack_manager.py +87 -0
  45. amulet/resource_pack/bedrock/__init__.py +2 -0
  46. amulet/resource_pack/bedrock/bedrock_vanilla_fix/pack_icon.png +0 -0
  47. amulet/resource_pack/bedrock/bedrock_vanilla_fix/textures/blocks/grass_carried.png +0 -0
  48. amulet/resource_pack/bedrock/bedrock_vanilla_fix/textures/blocks/grass_side_carried.png +0 -0
  49. amulet/resource_pack/bedrock/bedrock_vanilla_fix/textures/blocks/water.png +0 -0
  50. amulet/resource_pack/bedrock/blockshapes/__init__.py +31 -0
  51. amulet/resource_pack/bedrock/blockshapes/air.py +35 -0
  52. amulet/resource_pack/bedrock/blockshapes/base_blockshape.py +29 -0
  53. amulet/resource_pack/bedrock/blockshapes/bubble_column.py +29 -0
  54. amulet/resource_pack/bedrock/blockshapes/cake.py +46 -0
  55. amulet/resource_pack/bedrock/blockshapes/chest.py +54 -0
  56. amulet/resource_pack/bedrock/blockshapes/comparator.py +51 -0
  57. amulet/resource_pack/bedrock/blockshapes/cross_texture.py +186 -0
  58. amulet/resource_pack/bedrock/blockshapes/cross_texture0.py +17 -0
  59. amulet/resource_pack/bedrock/blockshapes/cross_texture_green.py +16 -0
  60. amulet/resource_pack/bedrock/blockshapes/cube.py +38 -0
  61. amulet/resource_pack/bedrock/blockshapes/default.py +14 -0
  62. amulet/resource_pack/bedrock/blockshapes/door.py +38 -0
  63. amulet/resource_pack/bedrock/blockshapes/door1.py +14 -0
  64. amulet/resource_pack/bedrock/blockshapes/door2.py +14 -0
  65. amulet/resource_pack/bedrock/blockshapes/door3.py +14 -0
  66. amulet/resource_pack/bedrock/blockshapes/door4.py +14 -0
  67. amulet/resource_pack/bedrock/blockshapes/door5.py +14 -0
  68. amulet/resource_pack/bedrock/blockshapes/door6.py +14 -0
  69. amulet/resource_pack/bedrock/blockshapes/double_plant.py +40 -0
  70. amulet/resource_pack/bedrock/blockshapes/enchanting_table.py +22 -0
  71. amulet/resource_pack/bedrock/blockshapes/farmland.py +22 -0
  72. amulet/resource_pack/bedrock/blockshapes/fence.py +22 -0
  73. amulet/resource_pack/bedrock/blockshapes/flat.py +55 -0
  74. amulet/resource_pack/bedrock/blockshapes/flat_wall.py +55 -0
  75. amulet/resource_pack/bedrock/blockshapes/furnace.py +44 -0
  76. amulet/resource_pack/bedrock/blockshapes/furnace_lit.py +14 -0
  77. amulet/resource_pack/bedrock/blockshapes/green_cube.py +39 -0
  78. amulet/resource_pack/bedrock/blockshapes/ladder.py +36 -0
  79. amulet/resource_pack/bedrock/blockshapes/lilypad.py +14 -0
  80. amulet/resource_pack/bedrock/blockshapes/partial_block.py +57 -0
  81. amulet/resource_pack/bedrock/blockshapes/piston.py +44 -0
  82. amulet/resource_pack/bedrock/blockshapes/piston_arm.py +72 -0
  83. amulet/resource_pack/bedrock/blockshapes/portal_frame.py +22 -0
  84. amulet/resource_pack/bedrock/blockshapes/pressure_plate.py +29 -0
  85. amulet/resource_pack/bedrock/blockshapes/pumpkin.py +36 -0
  86. amulet/resource_pack/bedrock/blockshapes/pumpkin_carved.py +14 -0
  87. amulet/resource_pack/bedrock/blockshapes/pumpkin_lit.py +14 -0
  88. amulet/resource_pack/bedrock/blockshapes/red_dust.py +14 -0
  89. amulet/resource_pack/bedrock/blockshapes/repeater.py +53 -0
  90. amulet/resource_pack/bedrock/blockshapes/slab.py +33 -0
  91. amulet/resource_pack/bedrock/blockshapes/slab_double.py +15 -0
  92. amulet/resource_pack/bedrock/blockshapes/tree.py +41 -0
  93. amulet/resource_pack/bedrock/blockshapes/turtle_egg.py +15 -0
  94. amulet/resource_pack/bedrock/blockshapes/vine.py +52 -0
  95. amulet/resource_pack/bedrock/blockshapes/wall.py +22 -0
  96. amulet/resource_pack/bedrock/blockshapes/water.py +38 -0
  97. amulet/resource_pack/bedrock/download_resources.py +147 -0
  98. amulet/resource_pack/bedrock/resource_pack.py +40 -0
  99. amulet/resource_pack/bedrock/resource_pack_manager.py +361 -0
  100. amulet/resource_pack/bedrock/sort_blockshapes.py +15 -0
  101. amulet/resource_pack/java/__init__.py +2 -0
  102. amulet/resource_pack/java/download_resources.py +212 -0
  103. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_black.png +0 -0
  104. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_blue.png +0 -0
  105. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_brown.png +0 -0
  106. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_cyan.png +0 -0
  107. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_gray.png +0 -0
  108. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_green.png +0 -0
  109. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_light_blue.png +0 -0
  110. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_light_gray.png +0 -0
  111. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_lime.png +0 -0
  112. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_magenta.png +0 -0
  113. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_orange.png +0 -0
  114. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_pink.png +0 -0
  115. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_purple.png +0 -0
  116. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_red.png +0 -0
  117. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_white.png +0 -0
  118. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_yellow.png +0 -0
  119. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/barrier.png +0 -0
  120. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/end_portal.png +0 -0
  121. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/grass.png +0 -0
  122. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/lava.png +0 -0
  123. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/structure_void.png +0 -0
  124. amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/water.png +0 -0
  125. amulet/resource_pack/java/java_vanilla_fix/pack.png +0 -0
  126. amulet/resource_pack/java/resource_pack.py +44 -0
  127. amulet/resource_pack/java/resource_pack_manager.py +551 -0
  128. amulet/resource_pack/unknown_resource_pack.py +10 -0
  129. amulet/utils/__init__.pyi +0 -5
  130. amulet/utils/call_spec/_call_spec.py +2 -7
  131. amulet/utils/comment_json.py +188 -0
  132. amulet/utils/matrix.py +3 -3
  133. amulet/utils/numpy_helpers.py +2 -2
  134. amulet/utils/world_utils.py +2 -2
  135. amulet/version.pyi +0 -8
  136. {amulet_core-2.0a6.dist-info → amulet_core-2.0a7.dist-info}/METADATA +2 -2
  137. amulet_core-2.0a7.dist-info/RECORD +295 -0
  138. amulet/chunk_/components/biome.py +0 -155
  139. amulet/chunk_/components/block_entity.py +0 -117
  140. amulet/chunk_/components/entity.py +0 -64
  141. amulet/chunk_/components/height_2d.py +0 -16
  142. amulet/level/bedrock/__init__.py +0 -2
  143. amulet/level/bedrock/_chunk_handle.py +0 -19
  144. amulet/level/bedrock/_dimension.py +0 -22
  145. amulet/level/bedrock/_level.py +0 -187
  146. amulet/level/bedrock/_raw/__init__.py +0 -5
  147. amulet/level/bedrock/_raw/_actor_counter.py +0 -53
  148. amulet/level/bedrock/_raw/_chunk.py +0 -54
  149. amulet/level/bedrock/_raw/_chunk_decode.py +0 -668
  150. amulet/level/bedrock/_raw/_chunk_encode.py +0 -602
  151. amulet/level/bedrock/_raw/_constant.py +0 -9
  152. amulet/level/bedrock/_raw/_dimension.py +0 -343
  153. amulet/level/bedrock/_raw/_level.py +0 -463
  154. amulet/level/bedrock/_raw/_level_dat.py +0 -90
  155. amulet/level/bedrock/_raw/_typing.py +0 -6
  156. amulet/level/bedrock/_raw/leveldb_chunk_versions.py +0 -83
  157. amulet/level/bedrock/chunk/__init__.py +0 -1
  158. amulet/level/bedrock/chunk/_chunk.py +0 -126
  159. amulet/level/bedrock/chunk/components/chunk_version.py +0 -12
  160. amulet/level/bedrock/chunk/components/finalised_state.py +0 -13
  161. amulet/level/bedrock/chunk/components/raw_chunk.py +0 -15
  162. amulet/level/construction/__init__.py +0 -0
  163. amulet/level/java/_chunk_handle.pyi +0 -15
  164. amulet/level/java/_dimension.pyi +0 -13
  165. amulet/level/java/_level.pyi +0 -120
  166. amulet/level/java/_raw/_chunk_decode.py +0 -561
  167. amulet/level/java/_raw/_chunk_encode.py +0 -463
  168. amulet/level/java/_raw/_constant.pyi +0 -20
  169. amulet/level/java/_raw/_data_pack/__init__.pyi +0 -8
  170. amulet/level/java/_raw/_data_pack/data_pack.pyi +0 -197
  171. amulet/level/java/_raw/_data_pack/data_pack_manager.pyi +0 -75
  172. amulet/level/java/_raw/_dimension.pyi +0 -72
  173. amulet/level/java/_raw/_level.pyi +0 -238
  174. amulet/level/java/_raw/_typing.pyi +0 -5
  175. amulet/level/java/anvil/__init__.pyi +0 -11
  176. amulet/level/java/anvil/_dimension.pyi +0 -109
  177. amulet/level/java/anvil/_region.pyi +0 -197
  178. amulet/level/java/anvil/_sector_manager.pyi +0 -142
  179. amulet/level/java_forge/__init__.py +0 -0
  180. amulet/level/mcstructure/__init__.py +0 -0
  181. amulet/level/nbt/__init__.py +0 -0
  182. amulet/level/schematic/__init__.py +0 -0
  183. amulet/level/sponge_schematic/__init__.py +0 -0
  184. amulet/pybind11/python.hpp +0 -14
  185. amulet/utils/call_spec/__init__.pyi +0 -53
  186. amulet/utils/call_spec/_call_spec.pyi +0 -272
  187. amulet/utils/matrix.pyi +0 -177
  188. amulet/utils/shareable_lock.pyi +0 -190
  189. amulet/utils/signal/__init__.pyi +0 -25
  190. amulet/utils/signal/_signal.pyi +0 -84
  191. amulet/utils/task_manager.pyi +0 -168
  192. amulet/utils/typing.py +0 -4
  193. amulet/utils/typing.pyi +0 -6
  194. amulet/utils/weakref.pyi +0 -50
  195. amulet/utils/world_utils.pyi +0 -109
  196. amulet_core-2.0a6.dist-info/RECORD +0 -253
  197. /amulet/img/{missing_world_icon.png → missing_world.png} +0 -0
  198. /amulet/{level/bedrock/chunk/components → mesh}/__init__.py +0 -0
  199. {amulet_core-2.0a6.dist-info → amulet_core-2.0a7.dist-info}/WHEEL +0 -0
  200. {amulet_core-2.0a6.dist-info → amulet_core-2.0a7.dist-info}/entry_points.txt +0 -0
  201. {amulet_core-2.0a6.dist-info → amulet_core-2.0a7.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,15 @@
1
+ from amulet.block import Block
2
+ from amulet.resource_pack.bedrock.blockshapes.cube import Cube
3
+
4
+
5
+ class SlabDouble(Cube):
6
+ @property
7
+ def blockshape(self) -> str:
8
+ return "slab_double"
9
+
10
+ def texture_index(self, block: Block, aux_value: int) -> int:
11
+ """The texture index to use within the list for the given Block"""
12
+ return aux_value % 8
13
+
14
+
15
+ BlockShape = SlabDouble()
@@ -0,0 +1,41 @@
1
+ from amulet.block import Block
2
+ from amulet.mesh.block import BlockMesh
3
+ from amulet.resource_pack.bedrock.blockshapes.cube import Cube
4
+ import amulet_nbt
5
+
6
+
7
+ class Tree(Cube):
8
+ def is_valid(self, block: Block) -> bool:
9
+ return isinstance(block.properties.get("pillar_axis"), amulet_nbt.TAG_String)
10
+
11
+ @property
12
+ def blockshape(self) -> str:
13
+ return "tree"
14
+
15
+ def texture_index(self, block: Block, aux_value: int) -> int:
16
+ return aux_value % 4
17
+
18
+ def get_block_model(
19
+ self,
20
+ block: Block,
21
+ down: str,
22
+ up: str,
23
+ north: str,
24
+ east: str,
25
+ south: str,
26
+ west: str,
27
+ transparency: tuple[bool, bool, bool, bool, bool, bool],
28
+ ) -> BlockMesh:
29
+ axis: str = block.properties["pillar_axis"].py_data
30
+
31
+ model = super().get_block_model(
32
+ block, down, up, north, east, south, west, transparency
33
+ )
34
+ if axis == "x":
35
+ return model.rotate(1, 1)
36
+ elif axis == "z":
37
+ return model.rotate(1, 2)
38
+ return model
39
+
40
+
41
+ BlockShape = Tree()
@@ -0,0 +1,15 @@
1
+ from amulet.block import Block
2
+ from amulet.resource_pack.bedrock.blockshapes.cube import Cube
3
+
4
+
5
+ class TurtleEgg(Cube):
6
+ @property
7
+ def blockshape(self) -> str:
8
+ return "turtle_egg"
9
+
10
+ def texture_index(self, block: Block, aux_value: int) -> int:
11
+ """The texture index to use within the list for the given Block"""
12
+ return (aux_value // 4) % 3
13
+
14
+
15
+ BlockShape = TurtleEgg()
@@ -0,0 +1,52 @@
1
+ from amulet.block import Block
2
+ from amulet.resource_pack.bedrock.blockshapes.flat_wall import (
3
+ FlatWall,
4
+ )
5
+ from amulet.mesh.block import BlockMesh
6
+ import amulet_nbt
7
+
8
+
9
+ class Vine(FlatWall):
10
+ def is_valid(self, block: Block) -> bool:
11
+ return isinstance(
12
+ block.properties.get("vine_direction_bits"), amulet_nbt.TAG_Int
13
+ )
14
+
15
+ @property
16
+ def blockshape(self) -> str:
17
+ return "vine"
18
+
19
+ @property
20
+ def tint(self) -> tuple[float, float, float]:
21
+ return 0, 1, 0
22
+
23
+ def get_block_model(
24
+ self,
25
+ block: Block,
26
+ down: str,
27
+ up: str,
28
+ north: str,
29
+ east: str,
30
+ south: str,
31
+ west: str,
32
+ transparency: tuple[bool, bool, bool, bool, bool, bool],
33
+ modify_uv: bool = True,
34
+ ) -> BlockMesh:
35
+ models = []
36
+ data: int = block.properties["vine_direction_bits"].py_data
37
+ if data:
38
+ model = super().get_block_model(
39
+ block, down, up, north, east, south, west, transparency
40
+ )
41
+ if data & 1:
42
+ models.append(model.rotate(0, 2))
43
+ if data & 2:
44
+ models.append(model.rotate(0, 3))
45
+ if data & 4:
46
+ models.append(model.rotate(0, 0))
47
+ if data & 8:
48
+ models.append(model.rotate(0, 1))
49
+ return BlockMesh.merge(models)
50
+
51
+
52
+ BlockShape = Vine()
@@ -0,0 +1,22 @@
1
+ from amulet.block import Block
2
+ from amulet.resource_pack.bedrock.blockshapes.partial_block import (
3
+ PartialBlock,
4
+ )
5
+
6
+
7
+ class Wall(PartialBlock):
8
+ @property
9
+ def blockshape(self) -> str:
10
+ return "wall"
11
+
12
+ def bounds(
13
+ self, block: Block
14
+ ) -> tuple[tuple[float, float], tuple[float, float], tuple[float, float]]:
15
+ return (4 / 16, 12 / 16), (0, 1), (4 / 16, 12 / 16)
16
+
17
+ @property
18
+ def do_not_cull(self) -> tuple[bool, bool, bool, bool, bool, bool]:
19
+ return False, False, True, True, True, True
20
+
21
+
22
+ BlockShape = Wall()
@@ -0,0 +1,38 @@
1
+ from amulet.block import Block
2
+ from amulet.mesh.block.block_mesh import BlockMesh, Transparency
3
+ from amulet.mesh.block.cube import get_unit_cube
4
+ from amulet.resource_pack.bedrock.blockshapes.cube import Cube
5
+
6
+
7
+ class Water(Cube):
8
+ @property
9
+ def blockshape(self) -> str:
10
+ return "water"
11
+
12
+ def get_block_model(
13
+ self,
14
+ block: Block,
15
+ down: str,
16
+ up: str,
17
+ north: str,
18
+ east: str,
19
+ south: str,
20
+ west: str,
21
+ transparency: tuple[bool, bool, bool, bool, bool, bool],
22
+ ) -> BlockMesh:
23
+ return get_unit_cube(
24
+ down,
25
+ down,
26
+ down,
27
+ down,
28
+ down,
29
+ down,
30
+ (
31
+ Transparency.FullTranslucent
32
+ if transparency[0]
33
+ else Transparency.FullOpaque
34
+ ),
35
+ )
36
+
37
+
38
+ BlockShape = Water()
@@ -0,0 +1,147 @@
1
+ import os
2
+
3
+ # import shutil
4
+ # import zipfile
5
+ # import json
6
+ # from urllib.request import urlopen
7
+ # import io
8
+ from typing import Generator, Optional, TypeVar, Any
9
+ import logging
10
+
11
+ from amulet.resource_pack import BedrockResourcePack
12
+
13
+ T = TypeVar("T")
14
+
15
+ log = logging.getLogger(__name__)
16
+
17
+
18
+ def generator_unpacker(gen: Generator[Any, Any, T]) -> T:
19
+ try:
20
+ while True:
21
+ next(gen)
22
+ except StopIteration as e:
23
+ return e.value # type: ignore
24
+
25
+
26
+ def get_latest() -> BedrockResourcePack:
27
+ return generator_unpacker(get_latest_iter())
28
+
29
+
30
+ def get_latest_iter() -> Generator[float, None, BedrockResourcePack]:
31
+ vanilla_rp_path = os.path.join(
32
+ os.environ["CACHE_DIR"], "resource_packs", "bedrock", "vanilla"
33
+ )
34
+ yield 0
35
+ # new_version = launcher_manifest["latest"]["release"]
36
+ # if new_version is None:
37
+ # if os.path.isdir(vanilla_rp_path):
38
+ # log.error(
39
+ # "Could not download the launcher manifest. The resource pack seems to be present so using that."
40
+ # )
41
+ # else:
42
+ # log.error(
43
+ # "Could not download the launcher manifest. The resource pack is not present, blocks may not be rendered correctly."
44
+ # )
45
+ # else:
46
+ # if os.path.isdir(vanilla_rp_path):
47
+ # if os.path.isfile(os.path.join(vanilla_rp_path, "version")):
48
+ # with open(os.path.join(vanilla_rp_path, "version")) as f:
49
+ # old_version = f.read()
50
+ # if old_version != new_version:
51
+ # yield from _remove_and_download_iter(vanilla_rp_path, new_version)
52
+ # else:
53
+ # yield from _remove_and_download_iter(vanilla_rp_path, new_version)
54
+ # else:
55
+ # yield from _remove_and_download_iter(vanilla_rp_path, new_version)
56
+ return BedrockResourcePack(vanilla_rp_path)
57
+
58
+
59
+ _bedrock_vanilla_fix: Optional[BedrockResourcePack] = None
60
+ _bedrock_vanilla_latest: Optional[BedrockResourcePack] = None
61
+
62
+
63
+ def get_bedrock_vanilla_fix() -> BedrockResourcePack:
64
+ global _bedrock_vanilla_fix
65
+ if _bedrock_vanilla_fix is None:
66
+ _bedrock_vanilla_fix = BedrockResourcePack(
67
+ os.path.join(os.path.dirname(__file__), "bedrock_vanilla_fix")
68
+ )
69
+ return _bedrock_vanilla_fix
70
+
71
+
72
+ def get_bedrock_vanilla_latest() -> BedrockResourcePack:
73
+ global _bedrock_vanilla_latest
74
+ if _bedrock_vanilla_latest is None:
75
+ _bedrock_vanilla_latest = get_latest()
76
+ return _bedrock_vanilla_latest
77
+
78
+
79
+ def get_bedrock_vanilla_latest_iter() -> Generator[float, None, BedrockResourcePack]:
80
+ global _bedrock_vanilla_latest
81
+ if _bedrock_vanilla_latest is None:
82
+ _bedrock_vanilla_latest = yield from get_latest_iter()
83
+ return _bedrock_vanilla_latest
84
+
85
+
86
+ # def _remove_and_download(path, version):
87
+ # for _ in _remove_and_download_iter(path, version):
88
+ # pass
89
+
90
+
91
+ # def _remove_and_download_iter(path, version) -> Generator[float, None, None]:
92
+ # if os.path.isdir(path):
93
+ # shutil.rmtree(path, ignore_errors=True)
94
+ # exists = yield from download_resources_iter(path, version)
95
+ # if exists:
96
+ # with open(os.path.join(path, "version"), "w") as f:
97
+ # f.write(version)
98
+
99
+
100
+ # def download_resources(path, version) -> bool:
101
+ # return generator_unpacker(download_resources_iter(path, version))
102
+
103
+
104
+ # def download_resources_iter(
105
+ # path, version, chunk_size=4096
106
+ # ) -> Generator[float, None, bool]:
107
+ # log.info(f"Downloading Bedrock resource pack for version {version}")
108
+ # version_url = next(
109
+ # (v["url"] for v in launcher_manifest["versions"] if v["id"] == version), None
110
+ # )
111
+ # if version_url is None:
112
+ # log.error(f"Could not find Bedrock resource pack for version {version}.")
113
+ # return False
114
+ #
115
+ # try:
116
+ # version_manifest = json.load(urlopen(version_url))
117
+ # version_client_url = version_manifest["downloads"]["client"]["url"]
118
+ #
119
+ # response = urlopen(version_client_url)
120
+ # data = []
121
+ # data_size = int(response.headers["content-length"].strip())
122
+ # index = 0
123
+ # chunk = b"hello"
124
+ # while chunk:
125
+ # chunk = response.read(chunk_size)
126
+ # data.append(chunk)
127
+ # index += 1
128
+ # yield min(1.0, (index * chunk_size) / (data_size * 2))
129
+ #
130
+ # client = zipfile.ZipFile(io.BytesIO(b"".join(data)))
131
+ # paths = [fpath for fpath in client.namelist() if fpath.startswith("assets/")]
132
+ # path_count = len(paths)
133
+ # for path_index, fpath in enumerate(paths):
134
+ # if not path_index % 30:
135
+ # yield path_index / (path_count * 2) + 0.5
136
+ # client.extract(fpath, path)
137
+ # client.extract("pack.mcmeta", path)
138
+ # client.extract("pack.png", path)
139
+ #
140
+ # except:
141
+ # log.error(
142
+ # f"Failed to download and extract the Bedrock resource pack for version {version}. Make sure you have a connection to the internet.",
143
+ # exc_info=True,
144
+ # )
145
+ # return False
146
+ # log.info(f"Finished downloading Bedrock resource pack for version {version}")
147
+ # return True
@@ -0,0 +1,40 @@
1
+ import os
2
+ import json
3
+
4
+ from amulet.resource_pack.abc import BaseResourcePack
5
+ from amulet.utils import comment_json
6
+
7
+
8
+ class BedrockResourcePack(BaseResourcePack):
9
+ """A class to hold the bare-bones information about the resource pack.
10
+ Holds the pack format, description and if the pack is valid.
11
+ This information can be used in a viewer to display the packs to the user."""
12
+
13
+ def __init__(self, resource_pack_path: str):
14
+ super().__init__(resource_pack_path)
15
+ meta_path = os.path.join(resource_pack_path, "manifest.json")
16
+ if os.path.isfile(meta_path):
17
+ try:
18
+ with open(meta_path) as f:
19
+ pack_mcmeta = comment_json.load(f)
20
+ except json.JSONDecodeError:
21
+ pass
22
+ else:
23
+ if isinstance(pack_mcmeta, dict):
24
+ header = pack_mcmeta.get("header", None)
25
+ if isinstance(header, dict):
26
+ description = header.get("description", None)
27
+ if isinstance(description, str):
28
+ self._pack_description = description
29
+ self._valid_pack = True
30
+
31
+ pack_icon_path = os.path.join(resource_pack_path, "pack_icon.png")
32
+ if os.path.isfile(pack_icon_path):
33
+ self._pack_icon = pack_icon_path
34
+
35
+ @staticmethod
36
+ def is_valid(pack_path: str) -> bool:
37
+ return os.path.isfile(os.path.join(pack_path, "manifest.json"))
38
+
39
+ def __repr__(self) -> str:
40
+ return f"BedrockResourcePack({self._root_dir})"