amulet-core 2.0a7__cp311-cp311-win_amd64.whl → 2.0.1a2.post250529084738__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.
- amulet/core/__init__.py +36 -0
- amulet/core/__pyinstaller/hook-amulet.core.py +4 -0
- amulet/core/_amulet_core.cp311-win_amd64.pyd +0 -0
- amulet/core/_amulet_core.pyi +7 -0
- amulet/{_version.py → core/_version.py} +3 -3
- amulet/core/amulet_core.dll +0 -0
- amulet/core/amulet_core.lib +0 -0
- amulet/core/amulet_coreConfig.cmake +18 -0
- amulet/{biome.pyi → core/biome/__init__.pyi} +3 -3
- amulet/core/biome/biome.hpp +53 -0
- amulet/{block.pyi → core/block/__init__.pyi} +25 -26
- amulet/core/block/block.hpp +156 -0
- amulet/{block_entity.pyi → core/block_entity/__init__.pyi} +7 -7
- amulet/core/block_entity/block_entity.hpp +84 -0
- amulet/{errors.py → core/chunk/__init__.pyi} +37 -33
- amulet/core/chunk/chunk.hpp +126 -0
- amulet/core/chunk/component/__init__.pyi +18 -0
- amulet/core/chunk/component/biome_3d_component.hpp +96 -0
- amulet/core/chunk/component/block_component.hpp +101 -0
- amulet/core/chunk/component/block_component.pyi +28 -0
- amulet/core/chunk/component/block_entity_component.hpp +119 -0
- amulet/core/chunk/component/section_array_map.hpp +129 -0
- amulet/{chunk_components.pyi → core/chunk/component/section_array_map.pyi} +4 -24
- amulet/core/dll.hpp +21 -0
- amulet/core/entity/__init__.pyi +105 -0
- amulet/core/entity/entity.hpp +100 -0
- amulet/{palette → core/palette}/__init__.pyi +2 -2
- amulet/core/palette/biome_palette.hpp +65 -0
- amulet/{palette → core/palette}/biome_palette.pyi +8 -8
- amulet/core/palette/block_palette.hpp +71 -0
- amulet/{palette → core/palette}/block_palette.pyi +12 -10
- amulet/core/selection/__init__.pyi +8 -0
- amulet/core/selection/box.hpp +86 -0
- amulet/core/selection/box.pyi +215 -0
- amulet/core/selection/group.hpp +80 -0
- amulet/core/selection/group.pyi +213 -0
- amulet/{version.pyi → core/version/__init__.pyi} +58 -10
- amulet/core/version/version.hpp +204 -0
- {amulet_core-2.0a7.dist-info → amulet_core-2.0.1a2.post250529084738.dist-info}/METADATA +25 -20
- amulet_core-2.0.1a2.post250529084738.dist-info/RECORD +45 -0
- {amulet_core-2.0a7.dist-info → amulet_core-2.0.1a2.post250529084738.dist-info}/WHEEL +1 -1
- amulet_core-2.0.1a2.post250529084738.dist-info/entry_points.txt +2 -0
- amulet/__init__.cp311-win_amd64.pyd +0 -0
- amulet/__init__.py.cpp +0 -43
- amulet/__init__.pyi +0 -28
- amulet/__pyinstaller/hook-amulet.py +0 -4
- amulet/_init.py +0 -26
- amulet/biome.cpp +0 -36
- amulet/biome.hpp +0 -43
- amulet/biome.py.cpp +0 -122
- amulet/block.cpp +0 -435
- amulet/block.hpp +0 -119
- amulet/block.py.cpp +0 -377
- amulet/block_entity.cpp +0 -12
- amulet/block_entity.hpp +0 -56
- amulet/block_entity.py.cpp +0 -115
- amulet/chunk.cpp +0 -16
- amulet/chunk.hpp +0 -99
- amulet/chunk.py.cpp +0 -80
- amulet/chunk.pyi +0 -28
- amulet/chunk_components/biome_3d_component.cpp +0 -5
- amulet/chunk_components/biome_3d_component.hpp +0 -79
- amulet/chunk_components/block_component.cpp +0 -41
- amulet/chunk_components/block_component.hpp +0 -88
- amulet/chunk_components/block_entity_component.cpp +0 -5
- amulet/chunk_components/block_entity_component.hpp +0 -147
- amulet/chunk_components/section_array_map.cpp +0 -129
- amulet/chunk_components/section_array_map.hpp +0 -147
- amulet/collections/eq.py.hpp +0 -37
- amulet/collections/hash.py.hpp +0 -27
- amulet/collections/holder.py.hpp +0 -37
- amulet/collections/iterator.py.hpp +0 -80
- amulet/collections/mapping.py.hpp +0 -199
- amulet/collections/mutable_mapping.py.hpp +0 -226
- amulet/collections/sequence.py.hpp +0 -163
- amulet/collections.pyi +0 -40
- amulet/data_types.py +0 -29
- amulet/entity.py +0 -182
- amulet/game/__init__.py +0 -7
- amulet/game/_game.py +0 -152
- amulet/game/_universal/__init__.py +0 -1
- amulet/game/_universal/_biome.py +0 -17
- amulet/game/_universal/_block.py +0 -47
- amulet/game/_universal/_version.py +0 -68
- amulet/game/abc/__init__.py +0 -22
- amulet/game/abc/_block_specification.py +0 -150
- amulet/game/abc/biome.py +0 -213
- amulet/game/abc/block.py +0 -331
- amulet/game/abc/game_version_container.py +0 -25
- amulet/game/abc/json_interface.py +0 -27
- amulet/game/abc/version.py +0 -44
- amulet/game/bedrock/__init__.py +0 -1
- amulet/game/bedrock/_biome.py +0 -35
- amulet/game/bedrock/_block.py +0 -42
- amulet/game/bedrock/_version.py +0 -165
- amulet/game/java/__init__.py +0 -2
- amulet/game/java/_biome.py +0 -35
- amulet/game/java/_block.py +0 -60
- amulet/game/java/_version.py +0 -176
- amulet/game/translate/__init__.py +0 -12
- amulet/game/translate/_functions/__init__.py +0 -15
- amulet/game/translate/_functions/_code_functions/__init__.py +0 -0
- amulet/game/translate/_functions/_code_functions/_text.py +0 -553
- amulet/game/translate/_functions/_code_functions/banner_pattern.py +0 -67
- amulet/game/translate/_functions/_code_functions/bedrock_chest_connection.py +0 -152
- amulet/game/translate/_functions/_code_functions/bedrock_moving_block_pos.py +0 -88
- amulet/game/translate/_functions/_code_functions/bedrock_sign.py +0 -152
- amulet/game/translate/_functions/_code_functions/bedrock_skull_rotation.py +0 -16
- amulet/game/translate/_functions/_code_functions/custom_name.py +0 -146
- amulet/game/translate/_functions/_frozen.py +0 -66
- amulet/game/translate/_functions/_state.py +0 -54
- amulet/game/translate/_functions/_typing.py +0 -98
- amulet/game/translate/_functions/abc.py +0 -123
- amulet/game/translate/_functions/carry_nbt.py +0 -160
- amulet/game/translate/_functions/carry_properties.py +0 -80
- amulet/game/translate/_functions/code.py +0 -143
- amulet/game/translate/_functions/map_block_name.py +0 -66
- amulet/game/translate/_functions/map_nbt.py +0 -111
- amulet/game/translate/_functions/map_properties.py +0 -93
- amulet/game/translate/_functions/multiblock.py +0 -112
- amulet/game/translate/_functions/new_block.py +0 -42
- amulet/game/translate/_functions/new_entity.py +0 -43
- amulet/game/translate/_functions/new_nbt.py +0 -206
- amulet/game/translate/_functions/new_properties.py +0 -64
- amulet/game/translate/_functions/sequence.py +0 -51
- amulet/game/translate/_functions/walk_input_nbt.py +0 -331
- amulet/game/translate/_translator.py +0 -433
- amulet/img/__init__.py +0 -10
- amulet/img/missing_no.png +0 -0
- amulet/img/missing_pack.png +0 -0
- amulet/img/missing_world.png +0 -0
- amulet/io/binary_reader.hpp +0 -45
- amulet/io/binary_writer.hpp +0 -30
- amulet/item.py +0 -75
- amulet/level/__init__.pyi +0 -23
- amulet/level/_load.py +0 -100
- amulet/level/abc/__init__.py +0 -12
- amulet/level/abc/_chunk_handle.py +0 -335
- amulet/level/abc/_dimension.py +0 -86
- amulet/level/abc/_history/__init__.py +0 -1
- amulet/level/abc/_history/_cache.py +0 -224
- amulet/level/abc/_history/_history_manager.py +0 -291
- amulet/level/abc/_level/__init__.py +0 -5
- amulet/level/abc/_level/_compactable_level.py +0 -10
- amulet/level/abc/_level/_creatable_level.py +0 -28
- amulet/level/abc/_level/_disk_level.py +0 -17
- amulet/level/abc/_level/_level.py +0 -449
- amulet/level/abc/_level/_loadable_level.py +0 -42
- amulet/level/abc/_player_storage.py +0 -7
- amulet/level/abc/_raw_level.py +0 -187
- amulet/level/abc/_registry.py +0 -40
- amulet/level/java/__init__.pyi +0 -16
- amulet/level/java/_chunk_handle.py +0 -17
- amulet/level/java/_dimension.py +0 -20
- amulet/level/java/_level.py +0 -184
- amulet/level/java/_raw/__init__.pyi +0 -15
- amulet/level/java/_raw/_chunk.pyi +0 -23
- amulet/level/java/_raw/_constant.py +0 -9
- amulet/level/java/_raw/_data_pack/__init__.py +0 -2
- amulet/level/java/_raw/_data_pack/data_pack.py +0 -241
- amulet/level/java/_raw/_data_pack/data_pack_manager.py +0 -77
- amulet/level/java/_raw/_dimension.py +0 -86
- amulet/level/java/_raw/_level.py +0 -507
- amulet/level/java/_raw/_typing.py +0 -3
- amulet/level/java/_raw/java_chunk_decode.cpp +0 -531
- amulet/level/java/_raw/java_chunk_decode.hpp +0 -23
- amulet/level/java/_raw/java_chunk_encode.cpp +0 -25
- amulet/level/java/_raw/java_chunk_encode.hpp +0 -23
- amulet/level/java/anvil/__init__.py +0 -2
- amulet/level/java/anvil/_dimension.py +0 -170
- amulet/level/java/anvil/_region.py +0 -421
- amulet/level/java/anvil/_sector_manager.py +0 -223
- amulet/level/java/chunk.pyi +0 -81
- amulet/level/java/chunk_/_chunk.py +0 -260
- amulet/level/java/chunk_/components/inhabited_time.py +0 -12
- amulet/level/java/chunk_/components/last_update.py +0 -12
- amulet/level/java/chunk_/components/legacy_version.py +0 -12
- amulet/level/java/chunk_/components/light_populated.py +0 -12
- amulet/level/java/chunk_/components/named_height_2d.py +0 -37
- amulet/level/java/chunk_/components/status.py +0 -11
- amulet/level/java/chunk_/components/terrain_populated.py +0 -12
- amulet/level/java/chunk_components/data_version_component.cpp +0 -32
- amulet/level/java/chunk_components/data_version_component.hpp +0 -31
- amulet/level/java/chunk_components/java_raw_chunk_component.cpp +0 -56
- amulet/level/java/chunk_components/java_raw_chunk_component.hpp +0 -45
- amulet/level/java/chunk_components.pyi +0 -22
- amulet/level/java/java_chunk.cpp +0 -170
- amulet/level/java/java_chunk.hpp +0 -141
- amulet/level/java/long_array.hpp +0 -175
- amulet/level/java/long_array.pyi +0 -39
- amulet/level/temporary_level/__init__.py +0 -1
- amulet/level/temporary_level/_level.py +0 -16
- amulet/mesh/__init__.py +0 -0
- amulet/mesh/block/__init__.py +0 -1
- amulet/mesh/block/block_mesh.py +0 -369
- amulet/mesh/block/cube.py +0 -149
- amulet/mesh/block/missing_block.py +0 -20
- amulet/mesh/util.py +0 -17
- amulet/palette/biome_palette.hpp +0 -85
- amulet/palette/block_palette.cpp +0 -32
- amulet/palette/block_palette.hpp +0 -93
- amulet/player.py +0 -62
- amulet/pybind11/collections.hpp +0 -118
- amulet/pybind11/numpy.hpp +0 -26
- amulet/pybind11/py_module.hpp +0 -34
- amulet/pybind11/type_hints.hpp +0 -51
- amulet/pybind11/types.hpp +0 -25
- amulet/pybind11/typing.hpp +0 -7
- amulet/resource_pack/__init__.py +0 -62
- amulet/resource_pack/abc/__init__.py +0 -2
- amulet/resource_pack/abc/resource_pack.py +0 -38
- amulet/resource_pack/abc/resource_pack_manager.py +0 -87
- amulet/resource_pack/bedrock/__init__.py +0 -2
- amulet/resource_pack/bedrock/bedrock_vanilla_fix/pack_icon.png +0 -0
- amulet/resource_pack/bedrock/bedrock_vanilla_fix/textures/blocks/grass_carried.png +0 -0
- amulet/resource_pack/bedrock/bedrock_vanilla_fix/textures/blocks/grass_side_carried.png +0 -0
- amulet/resource_pack/bedrock/bedrock_vanilla_fix/textures/blocks/water.png +0 -0
- amulet/resource_pack/bedrock/blockshapes/__init__.py +0 -31
- amulet/resource_pack/bedrock/blockshapes/air.py +0 -35
- amulet/resource_pack/bedrock/blockshapes/base_blockshape.py +0 -29
- amulet/resource_pack/bedrock/blockshapes/bubble_column.py +0 -29
- amulet/resource_pack/bedrock/blockshapes/cake.py +0 -46
- amulet/resource_pack/bedrock/blockshapes/chest.py +0 -54
- amulet/resource_pack/bedrock/blockshapes/comparator.py +0 -51
- amulet/resource_pack/bedrock/blockshapes/cross_texture.py +0 -186
- amulet/resource_pack/bedrock/blockshapes/cross_texture0.py +0 -17
- amulet/resource_pack/bedrock/blockshapes/cross_texture_green.py +0 -16
- amulet/resource_pack/bedrock/blockshapes/cube.py +0 -38
- amulet/resource_pack/bedrock/blockshapes/default.py +0 -14
- amulet/resource_pack/bedrock/blockshapes/door.py +0 -38
- amulet/resource_pack/bedrock/blockshapes/door1.py +0 -14
- amulet/resource_pack/bedrock/blockshapes/door2.py +0 -14
- amulet/resource_pack/bedrock/blockshapes/door3.py +0 -14
- amulet/resource_pack/bedrock/blockshapes/door4.py +0 -14
- amulet/resource_pack/bedrock/blockshapes/door5.py +0 -14
- amulet/resource_pack/bedrock/blockshapes/door6.py +0 -14
- amulet/resource_pack/bedrock/blockshapes/double_plant.py +0 -40
- amulet/resource_pack/bedrock/blockshapes/enchanting_table.py +0 -22
- amulet/resource_pack/bedrock/blockshapes/farmland.py +0 -22
- amulet/resource_pack/bedrock/blockshapes/fence.py +0 -22
- amulet/resource_pack/bedrock/blockshapes/flat.py +0 -55
- amulet/resource_pack/bedrock/blockshapes/flat_wall.py +0 -55
- amulet/resource_pack/bedrock/blockshapes/furnace.py +0 -44
- amulet/resource_pack/bedrock/blockshapes/furnace_lit.py +0 -14
- amulet/resource_pack/bedrock/blockshapes/green_cube.py +0 -39
- amulet/resource_pack/bedrock/blockshapes/ladder.py +0 -36
- amulet/resource_pack/bedrock/blockshapes/lilypad.py +0 -14
- amulet/resource_pack/bedrock/blockshapes/partial_block.py +0 -57
- amulet/resource_pack/bedrock/blockshapes/piston.py +0 -44
- amulet/resource_pack/bedrock/blockshapes/piston_arm.py +0 -72
- amulet/resource_pack/bedrock/blockshapes/portal_frame.py +0 -22
- amulet/resource_pack/bedrock/blockshapes/pressure_plate.py +0 -29
- amulet/resource_pack/bedrock/blockshapes/pumpkin.py +0 -36
- amulet/resource_pack/bedrock/blockshapes/pumpkin_carved.py +0 -14
- amulet/resource_pack/bedrock/blockshapes/pumpkin_lit.py +0 -14
- amulet/resource_pack/bedrock/blockshapes/red_dust.py +0 -14
- amulet/resource_pack/bedrock/blockshapes/repeater.py +0 -53
- amulet/resource_pack/bedrock/blockshapes/slab.py +0 -33
- amulet/resource_pack/bedrock/blockshapes/slab_double.py +0 -15
- amulet/resource_pack/bedrock/blockshapes/tree.py +0 -41
- amulet/resource_pack/bedrock/blockshapes/turtle_egg.py +0 -15
- amulet/resource_pack/bedrock/blockshapes/vine.py +0 -52
- amulet/resource_pack/bedrock/blockshapes/wall.py +0 -22
- amulet/resource_pack/bedrock/blockshapes/water.py +0 -38
- amulet/resource_pack/bedrock/download_resources.py +0 -147
- amulet/resource_pack/bedrock/resource_pack.py +0 -40
- amulet/resource_pack/bedrock/resource_pack_manager.py +0 -361
- amulet/resource_pack/bedrock/sort_blockshapes.py +0 -15
- amulet/resource_pack/java/__init__.py +0 -2
- amulet/resource_pack/java/download_resources.py +0 -212
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_black.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_blue.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_brown.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_cyan.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_gray.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_green.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_light_blue.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_light_gray.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_lime.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_magenta.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_orange.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_pink.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_purple.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_red.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_white.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_yellow.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/barrier.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/end_portal.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/grass.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/lava.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/structure_void.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/water.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/pack.png +0 -0
- amulet/resource_pack/java/resource_pack.py +0 -44
- amulet/resource_pack/java/resource_pack_manager.py +0 -551
- amulet/resource_pack/unknown_resource_pack.py +0 -10
- amulet/selection/__init__.py +0 -2
- amulet/selection/abstract_selection.py +0 -342
- amulet/selection/box.py +0 -852
- amulet/selection/group.py +0 -481
- amulet/utils/__init__.pyi +0 -23
- amulet/utils/call_spec/__init__.py +0 -24
- amulet/utils/call_spec/_call_spec.py +0 -257
- amulet/utils/comment_json.py +0 -188
- amulet/utils/format_utils.py +0 -41
- amulet/utils/generator.py +0 -18
- amulet/utils/matrix.py +0 -243
- amulet/utils/numpy.hpp +0 -36
- amulet/utils/numpy.pyi +0 -11
- amulet/utils/numpy_helpers.py +0 -19
- amulet/utils/shareable_lock.py +0 -335
- amulet/utils/signal/__init__.py +0 -10
- amulet/utils/signal/_signal.py +0 -228
- amulet/utils/task_manager.py +0 -235
- amulet/utils/typed_property.py +0 -111
- amulet/utils/weakref.py +0 -70
- amulet/utils/world_utils.py +0 -102
- amulet/version.cpp +0 -136
- amulet/version.hpp +0 -142
- amulet/version.py.cpp +0 -281
- amulet_core-2.0a7.dist-info/RECORD +0 -295
- amulet_core-2.0a7.dist-info/entry_points.txt +0 -2
- /amulet/{__pyinstaller → core/__pyinstaller}/__init__.py +0 -0
- /amulet/{py.typed → core/py.typed} +0 -0
- {amulet_core-2.0a7.dist-info → amulet_core-2.0.1a2.post250529084738.dist-info}/top_level.txt +0 -0
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import json
|
|
3
|
-
from typing import Union, Iterable, Generator, Optional, TypedDict, Literal, Any
|
|
4
|
-
from PIL import Image
|
|
5
|
-
import numpy
|
|
6
|
-
|
|
7
|
-
from amulet.block import Block
|
|
8
|
-
from amulet.utils import comment_json
|
|
9
|
-
from amulet.resource_pack import BaseResourcePackManager
|
|
10
|
-
from amulet.resource_pack.bedrock import BedrockResourcePack
|
|
11
|
-
from amulet.mesh.block.block_mesh import BlockMesh
|
|
12
|
-
from .blockshapes import BlockShapeClasses
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class NumericalProperty(TypedDict):
|
|
16
|
-
name: str
|
|
17
|
-
type: Union[Literal["byte"], Literal["int"]]
|
|
18
|
-
value: int
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class StrProperty(TypedDict):
|
|
22
|
-
name: str
|
|
23
|
-
type: Literal["string"]
|
|
24
|
-
value: str
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
class StateDict(TypedDict):
|
|
28
|
-
name: str
|
|
29
|
-
data: int
|
|
30
|
-
states: list[Union[NumericalProperty, StrProperty]]
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
class BlockPaletteDict(TypedDict):
|
|
34
|
-
blocks: list[StateDict]
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def _load_data() -> tuple[
|
|
38
|
-
dict[str, str],
|
|
39
|
-
dict[
|
|
40
|
-
str,
|
|
41
|
-
tuple[
|
|
42
|
-
tuple[tuple[str, Union[int, str]], ...],
|
|
43
|
-
dict[tuple[Union[str, int], ...], int],
|
|
44
|
-
],
|
|
45
|
-
],
|
|
46
|
-
]:
|
|
47
|
-
with open(os.path.join(os.path.dirname(__file__), "blockshapes.json")) as f:
|
|
48
|
-
_block_shapes: dict[str, str] = comment_json.load(f) # type: ignore
|
|
49
|
-
|
|
50
|
-
_aux_values: dict[
|
|
51
|
-
str,
|
|
52
|
-
tuple[
|
|
53
|
-
tuple[tuple[str, Union[int, str]], ...],
|
|
54
|
-
dict[tuple[Union[str, int], ...], int],
|
|
55
|
-
],
|
|
56
|
-
] = {}
|
|
57
|
-
with open(os.path.join(os.path.dirname(__file__), "block_palette.json")) as f:
|
|
58
|
-
_block_palette: BlockPaletteDict = comment_json.load(f) # type: ignore
|
|
59
|
-
for block in _block_palette["blocks"]:
|
|
60
|
-
data = block["data"]
|
|
61
|
-
name = block["name"]
|
|
62
|
-
if name not in _aux_values:
|
|
63
|
-
_aux_values[name] = (
|
|
64
|
-
tuple((state["name"], state["value"]) for state in block["states"]),
|
|
65
|
-
{},
|
|
66
|
-
)
|
|
67
|
-
_aux_values[name][1][tuple(state["value"] for state in block["states"])] = data
|
|
68
|
-
|
|
69
|
-
return _block_shapes, _aux_values
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
BlockShapes, AuxValues = _load_data()
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def get_aux_value(block: Block) -> int:
|
|
76
|
-
name = block.namespaced_name
|
|
77
|
-
if name in AuxValues:
|
|
78
|
-
property_names, aux_map = AuxValues[name]
|
|
79
|
-
properties = block.properties
|
|
80
|
-
key = tuple(
|
|
81
|
-
(
|
|
82
|
-
properties[property_name].py_data
|
|
83
|
-
if property_name in properties
|
|
84
|
-
else default
|
|
85
|
-
)
|
|
86
|
-
for property_name, default in property_names
|
|
87
|
-
)
|
|
88
|
-
return aux_map.get(key, 0)
|
|
89
|
-
else:
|
|
90
|
-
return 0
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
class BedrockResourcePackManager(BaseResourcePackManager):
|
|
94
|
-
"""A class to load and handle the data from the packs.
|
|
95
|
-
Packs are given as a list with the later packs overwriting the earlier ones."""
|
|
96
|
-
|
|
97
|
-
def __init__(
|
|
98
|
-
self,
|
|
99
|
-
resource_packs: Union[BedrockResourcePack, Iterable[BedrockResourcePack]],
|
|
100
|
-
load: bool = True,
|
|
101
|
-
) -> None:
|
|
102
|
-
super().__init__()
|
|
103
|
-
self._block_shapes: dict[str, str] = {} # block string to block shape
|
|
104
|
-
self._blocks: dict[str, Union[dict[str, str], str, None]] = (
|
|
105
|
-
{}
|
|
106
|
-
) # block string to short texture ids
|
|
107
|
-
self._terrain_texture: dict[str, tuple[str, ...]] = (
|
|
108
|
-
{}
|
|
109
|
-
) # texture ids to list of relative paths. Each relates to a different data value.
|
|
110
|
-
self._textures: dict[str, str] = {} # relative path to texture path
|
|
111
|
-
self._all_textures = None
|
|
112
|
-
|
|
113
|
-
self._texture_is_transparent: dict[str, tuple[float, bool]] = {}
|
|
114
|
-
|
|
115
|
-
if isinstance(resource_packs, (list, tuple)):
|
|
116
|
-
self._packs = [
|
|
117
|
-
rp for rp in resource_packs if isinstance(rp, BedrockResourcePack)
|
|
118
|
-
]
|
|
119
|
-
elif isinstance(resource_packs, BedrockResourcePack):
|
|
120
|
-
self._packs = [resource_packs]
|
|
121
|
-
else:
|
|
122
|
-
raise Exception(f"Invalid format {resource_packs}")
|
|
123
|
-
if load:
|
|
124
|
-
for _ in self.reload():
|
|
125
|
-
pass
|
|
126
|
-
|
|
127
|
-
def _unload(self) -> None:
|
|
128
|
-
"""Clear all loaded resources."""
|
|
129
|
-
super()._unload()
|
|
130
|
-
self._block_shapes.clear()
|
|
131
|
-
self._blocks.clear()
|
|
132
|
-
self._terrain_texture.clear()
|
|
133
|
-
self._textures.clear()
|
|
134
|
-
self._all_textures = None
|
|
135
|
-
|
|
136
|
-
def _check_texture(self, texture_path: str) -> str:
|
|
137
|
-
if os.path.isfile(texture_path + ".png"):
|
|
138
|
-
texture_path += ".png"
|
|
139
|
-
elif os.path.isfile(texture_path + ".tga"):
|
|
140
|
-
texture_path += ".tga"
|
|
141
|
-
else:
|
|
142
|
-
texture_path = self.missing_no
|
|
143
|
-
if (
|
|
144
|
-
os.stat(texture_path).st_mtime
|
|
145
|
-
!= self._texture_is_transparent.get(texture_path, [0])[0]
|
|
146
|
-
):
|
|
147
|
-
im: Image.Image = Image.open(texture_path)
|
|
148
|
-
if im.mode == "RGBA":
|
|
149
|
-
alpha = numpy.array(im.getchannel("A").getdata())
|
|
150
|
-
texture_is_transparent = bool(numpy.any(alpha != 255))
|
|
151
|
-
else:
|
|
152
|
-
texture_is_transparent = False
|
|
153
|
-
|
|
154
|
-
self._texture_is_transparent[texture_path] = (
|
|
155
|
-
os.stat(texture_path).st_mtime,
|
|
156
|
-
bool(texture_is_transparent),
|
|
157
|
-
)
|
|
158
|
-
return texture_path
|
|
159
|
-
|
|
160
|
-
def _load_iter(self) -> Generator[float, None, None]:
|
|
161
|
-
self._block_shapes.update(BlockShapes) # add the default block shapes
|
|
162
|
-
|
|
163
|
-
transparency_cache_path = os.path.join(
|
|
164
|
-
os.environ["CACHE_DIR"],
|
|
165
|
-
"resource_packs",
|
|
166
|
-
"bedrock",
|
|
167
|
-
"transparency_cache.json",
|
|
168
|
-
)
|
|
169
|
-
self._load_transparency_cache(transparency_cache_path)
|
|
170
|
-
|
|
171
|
-
self._textures["missing_no"] = self._check_texture("missing")
|
|
172
|
-
|
|
173
|
-
pack_count = len(self._packs)
|
|
174
|
-
|
|
175
|
-
for pack_index, pack in enumerate(self._packs):
|
|
176
|
-
pack_progress = pack_index / pack_count
|
|
177
|
-
yield pack_progress
|
|
178
|
-
|
|
179
|
-
if pack.valid_pack:
|
|
180
|
-
terrain_texture_path = os.path.join(
|
|
181
|
-
pack.root_dir, "textures", "terrain_texture.json"
|
|
182
|
-
)
|
|
183
|
-
if os.path.isfile(terrain_texture_path):
|
|
184
|
-
try:
|
|
185
|
-
with open(terrain_texture_path) as f:
|
|
186
|
-
terrain_texture = comment_json.load(f)
|
|
187
|
-
except json.JSONDecodeError:
|
|
188
|
-
pass
|
|
189
|
-
else:
|
|
190
|
-
if (
|
|
191
|
-
isinstance(terrain_texture, dict)
|
|
192
|
-
and "texture_data" in terrain_texture
|
|
193
|
-
and isinstance(terrain_texture["texture_data"], dict)
|
|
194
|
-
):
|
|
195
|
-
sub_progress = pack_progress
|
|
196
|
-
image_count = len(terrain_texture["texture_data"])
|
|
197
|
-
|
|
198
|
-
def get_texture(_relative_path: Any) -> str:
|
|
199
|
-
if isinstance(_relative_path, dict):
|
|
200
|
-
_relative_path = _relative_path.get(
|
|
201
|
-
"path", "misssingno"
|
|
202
|
-
)
|
|
203
|
-
assert isinstance(_relative_path, str)
|
|
204
|
-
if isinstance(_relative_path, str):
|
|
205
|
-
full_path = self._check_texture(
|
|
206
|
-
os.path.join(pack.root_dir, _relative_path)
|
|
207
|
-
)
|
|
208
|
-
if _relative_path in self._textures:
|
|
209
|
-
if full_path != self.missing_no:
|
|
210
|
-
self._textures[_relative_path] = full_path
|
|
211
|
-
else:
|
|
212
|
-
self._textures[_relative_path] = full_path
|
|
213
|
-
else:
|
|
214
|
-
raise TypeError
|
|
215
|
-
return _relative_path
|
|
216
|
-
|
|
217
|
-
for image_index, (texture_id, data) in enumerate(
|
|
218
|
-
terrain_texture["texture_data"].items()
|
|
219
|
-
):
|
|
220
|
-
if (
|
|
221
|
-
isinstance(texture_id, str)
|
|
222
|
-
and isinstance(data, dict)
|
|
223
|
-
and "textures" in data
|
|
224
|
-
):
|
|
225
|
-
texture_data = data["textures"]
|
|
226
|
-
if isinstance(texture_data, list):
|
|
227
|
-
self._terrain_texture[texture_id] = tuple(
|
|
228
|
-
get_texture(relative_path)
|
|
229
|
-
for relative_path in texture_data
|
|
230
|
-
)
|
|
231
|
-
else:
|
|
232
|
-
self._terrain_texture[texture_id] = (
|
|
233
|
-
get_texture(texture_data),
|
|
234
|
-
) * 16
|
|
235
|
-
yield sub_progress + image_index / (
|
|
236
|
-
image_count * pack_count * 2
|
|
237
|
-
)
|
|
238
|
-
sub_progress = pack_progress + 1 / (pack_count * 2)
|
|
239
|
-
yield sub_progress
|
|
240
|
-
blocks_path = os.path.join(pack.root_dir, "blocks.json")
|
|
241
|
-
if os.path.isfile(blocks_path):
|
|
242
|
-
try:
|
|
243
|
-
with open(blocks_path) as f:
|
|
244
|
-
blocks = comment_json.load(f)
|
|
245
|
-
except json.JSONDecodeError:
|
|
246
|
-
pass
|
|
247
|
-
else:
|
|
248
|
-
if isinstance(blocks, dict):
|
|
249
|
-
model_count = len(blocks)
|
|
250
|
-
for model_index, (block_id, data) in enumerate(
|
|
251
|
-
blocks.items()
|
|
252
|
-
):
|
|
253
|
-
if isinstance(block_id, str) and isinstance(data, dict):
|
|
254
|
-
if ":" not in block_id:
|
|
255
|
-
block_id = "minecraft:" + block_id
|
|
256
|
-
textures = data.get("textures")
|
|
257
|
-
if textures is None or isinstance(textures, str):
|
|
258
|
-
self._blocks[block_id] = textures
|
|
259
|
-
elif isinstance(textures, dict) and all(
|
|
260
|
-
isinstance(v, str) for v in textures.values()
|
|
261
|
-
):
|
|
262
|
-
self._blocks[block_id] = textures # type: ignore # TODO: improve this with TypeGuard
|
|
263
|
-
else:
|
|
264
|
-
raise TypeError
|
|
265
|
-
|
|
266
|
-
yield sub_progress + (model_index) / (
|
|
267
|
-
model_count * pack_count * 2
|
|
268
|
-
)
|
|
269
|
-
yield pack_progress + 1
|
|
270
|
-
|
|
271
|
-
os.makedirs(os.path.dirname(transparency_cache_path), exist_ok=True)
|
|
272
|
-
with open(transparency_cache_path, "w") as f:
|
|
273
|
-
json.dump(self._texture_is_transparent, f)
|
|
274
|
-
|
|
275
|
-
@property
|
|
276
|
-
def textures(self) -> tuple[str, ...]:
|
|
277
|
-
"""Returns a tuple of all the texture paths in the resource pack."""
|
|
278
|
-
return tuple(self._textures.values())
|
|
279
|
-
|
|
280
|
-
def get_texture_path(self, namespace: Optional[str], relative_path: str) -> str:
|
|
281
|
-
"""Get the absolute texture path from the namespace and relative path pair"""
|
|
282
|
-
if relative_path in self._textures:
|
|
283
|
-
return self._textures[relative_path]
|
|
284
|
-
else:
|
|
285
|
-
return self.missing_no
|
|
286
|
-
|
|
287
|
-
def _get_model(self, block: Block) -> BlockMesh:
|
|
288
|
-
block_shape = self._block_shapes.get(block.namespaced_name, "cube")
|
|
289
|
-
|
|
290
|
-
if block_shape in BlockShapeClasses:
|
|
291
|
-
block_shape_class = BlockShapeClasses[block_shape]
|
|
292
|
-
else:
|
|
293
|
-
block_shape_class = BlockShapeClasses["cube"]
|
|
294
|
-
|
|
295
|
-
if not block_shape_class.is_valid(block):
|
|
296
|
-
block_shape_class = BlockShapeClasses["cube"]
|
|
297
|
-
|
|
298
|
-
texture_index = block_shape_class.texture_index(block, get_aux_value(block))
|
|
299
|
-
|
|
300
|
-
if block.namespaced_name in self._blocks:
|
|
301
|
-
texture_id = self._blocks[block.namespaced_name]
|
|
302
|
-
if isinstance(texture_id, str):
|
|
303
|
-
up = down = north = east = south = west = self._get_texture(
|
|
304
|
-
texture_id, texture_index
|
|
305
|
-
)
|
|
306
|
-
transparent = (self._texture_is_transparent[up][1],) * 6
|
|
307
|
-
|
|
308
|
-
elif isinstance(texture_id, dict):
|
|
309
|
-
down = self._get_texture(
|
|
310
|
-
texture_id.get("down", "missing"), texture_index
|
|
311
|
-
)
|
|
312
|
-
up = self._get_texture(texture_id.get("up", "missing"), texture_index)
|
|
313
|
-
|
|
314
|
-
if "side" in texture_id:
|
|
315
|
-
north = east = south = west = self._get_texture(
|
|
316
|
-
texture_id.get("side", "missing"), texture_index
|
|
317
|
-
)
|
|
318
|
-
transparent = (
|
|
319
|
-
self._texture_is_transparent[down][1],
|
|
320
|
-
self._texture_is_transparent[up][1],
|
|
321
|
-
) + (self._texture_is_transparent[north][1],) * 4
|
|
322
|
-
else:
|
|
323
|
-
north = self._get_texture(
|
|
324
|
-
texture_id.get("north", "missing"), texture_index
|
|
325
|
-
)
|
|
326
|
-
east = self._get_texture(
|
|
327
|
-
texture_id.get("east", "missing"), texture_index
|
|
328
|
-
)
|
|
329
|
-
south = self._get_texture(
|
|
330
|
-
texture_id.get("south", "missing"), texture_index
|
|
331
|
-
)
|
|
332
|
-
west = self._get_texture(
|
|
333
|
-
texture_id.get("west", "missing"), texture_index
|
|
334
|
-
)
|
|
335
|
-
transparent = (
|
|
336
|
-
self._texture_is_transparent[down][1],
|
|
337
|
-
self._texture_is_transparent[up][1],
|
|
338
|
-
self._texture_is_transparent[north][1],
|
|
339
|
-
self._texture_is_transparent[east][1],
|
|
340
|
-
self._texture_is_transparent[south][1],
|
|
341
|
-
self._texture_is_transparent[west][1],
|
|
342
|
-
)
|
|
343
|
-
else:
|
|
344
|
-
up = down = north = east = south = west = self._get_texture(
|
|
345
|
-
"missing", texture_index
|
|
346
|
-
)
|
|
347
|
-
transparent = (self._texture_is_transparent[up][1],) * 6
|
|
348
|
-
|
|
349
|
-
return block_shape_class.get_block_model(
|
|
350
|
-
block, down, up, north, east, south, west, transparent
|
|
351
|
-
)
|
|
352
|
-
|
|
353
|
-
return self.missing_block
|
|
354
|
-
|
|
355
|
-
def _get_texture(self, texture_id: str, index: int) -> str:
|
|
356
|
-
texture = self.missing_no
|
|
357
|
-
if texture_id in self._terrain_texture:
|
|
358
|
-
texture_list = self._terrain_texture[texture_id]
|
|
359
|
-
if len(texture_list) > index:
|
|
360
|
-
texture = self.get_texture_path(None, texture_list[index])
|
|
361
|
-
return texture
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import json
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def main() -> None:
|
|
6
|
-
with open(os.path.join(os.path.dirname(__file__), "blockshapes.json")) as f:
|
|
7
|
-
shapes = json.load(f)
|
|
8
|
-
shapes_tuple = tuple(sorted(shapes.items(), key=lambda i: (i[1], i[0])))
|
|
9
|
-
shapes2 = dict(shapes_tuple)
|
|
10
|
-
with open(os.path.join(os.path.dirname(__file__), "blockshapes.json"), "w") as f:
|
|
11
|
-
json.dump(shapes2, f, indent=4)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if __name__ == "__main__":
|
|
15
|
-
main()
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import shutil
|
|
3
|
-
import zipfile
|
|
4
|
-
import json
|
|
5
|
-
from urllib.request import urlopen, Request
|
|
6
|
-
import io
|
|
7
|
-
from typing import Generator, TypeVar, Any, Optional
|
|
8
|
-
import logging
|
|
9
|
-
|
|
10
|
-
from amulet.resource_pack import JavaResourcePack
|
|
11
|
-
|
|
12
|
-
T = TypeVar("T")
|
|
13
|
-
|
|
14
|
-
log = logging.getLogger(__name__)
|
|
15
|
-
|
|
16
|
-
launcher_manifest: Optional[dict] = None
|
|
17
|
-
INCLUDE_SNAPSHOT = False
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def get_launcher_manifest() -> dict:
|
|
21
|
-
global launcher_manifest
|
|
22
|
-
if launcher_manifest is None:
|
|
23
|
-
log.info("Downloading java launcher manifest file.")
|
|
24
|
-
with urlopen(
|
|
25
|
-
"https://launchermeta.mojang.com/mc/game/version_manifest.json", timeout=20
|
|
26
|
-
) as manifest:
|
|
27
|
-
launcher_manifest = json.load(manifest)
|
|
28
|
-
log.info("Finished downloading java launcher manifest file.")
|
|
29
|
-
return launcher_manifest
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def generator_unpacker(gen: Generator[Any, Any, T]) -> T:
|
|
33
|
-
try:
|
|
34
|
-
while True:
|
|
35
|
-
next(gen)
|
|
36
|
-
except StopIteration as e:
|
|
37
|
-
return e.value # type: ignore
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def get_latest() -> JavaResourcePack:
|
|
41
|
-
return generator_unpacker(get_latest_iter())
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
def get_latest_iter() -> Generator[float, None, JavaResourcePack]:
|
|
45
|
-
"""Download the latest resource pack if required.
|
|
46
|
-
|
|
47
|
-
:return: The loaded Java resource pack.
|
|
48
|
-
:raises:
|
|
49
|
-
Exception: If the
|
|
50
|
-
"""
|
|
51
|
-
vanilla_rp_path = os.path.join(
|
|
52
|
-
os.environ["CACHE_DIR"], "resource_packs", "java", "vanilla"
|
|
53
|
-
)
|
|
54
|
-
try:
|
|
55
|
-
if INCLUDE_SNAPSHOT:
|
|
56
|
-
new_version = get_launcher_manifest()["latest"]["snapshot"]
|
|
57
|
-
else:
|
|
58
|
-
new_version = get_launcher_manifest()["latest"]["release"]
|
|
59
|
-
except Exception as e:
|
|
60
|
-
if os.path.isdir(vanilla_rp_path):
|
|
61
|
-
log.error(
|
|
62
|
-
"Could not download the launcher manifest. The resource pack seems to be present so using that."
|
|
63
|
-
)
|
|
64
|
-
else:
|
|
65
|
-
raise e
|
|
66
|
-
else:
|
|
67
|
-
has_new_pack = False
|
|
68
|
-
if os.path.isfile(os.path.join(vanilla_rp_path, "version")):
|
|
69
|
-
with open(os.path.join(vanilla_rp_path, "version")) as f:
|
|
70
|
-
old_version = f.read()
|
|
71
|
-
has_new_pack = old_version == new_version
|
|
72
|
-
|
|
73
|
-
if not has_new_pack:
|
|
74
|
-
yield from _remove_and_download_iter(vanilla_rp_path, new_version)
|
|
75
|
-
return JavaResourcePack(vanilla_rp_path)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
_java_vanilla_fix: Optional[JavaResourcePack] = None
|
|
79
|
-
_java_vanilla_latest: Optional[JavaResourcePack] = None
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
def get_java_vanilla_fix() -> JavaResourcePack:
|
|
83
|
-
global _java_vanilla_fix
|
|
84
|
-
if _java_vanilla_fix is None:
|
|
85
|
-
_java_vanilla_fix = JavaResourcePack(
|
|
86
|
-
os.path.join(os.path.dirname(__file__), "java_vanilla_fix")
|
|
87
|
-
)
|
|
88
|
-
return _java_vanilla_fix
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
def get_java_vanilla_latest() -> JavaResourcePack:
|
|
92
|
-
global _java_vanilla_latest
|
|
93
|
-
if _java_vanilla_latest is None:
|
|
94
|
-
_java_vanilla_latest = get_latest()
|
|
95
|
-
return _java_vanilla_latest
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
def get_java_vanilla_latest_iter() -> Generator[float, None, JavaResourcePack]:
|
|
99
|
-
global _java_vanilla_latest
|
|
100
|
-
if _java_vanilla_latest is None:
|
|
101
|
-
_java_vanilla_latest = yield from get_latest_iter()
|
|
102
|
-
return _java_vanilla_latest
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
def _remove_and_download(path: str, version: str) -> None:
|
|
106
|
-
for _ in _remove_and_download_iter(path, version):
|
|
107
|
-
pass
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
def _remove_and_download_iter(path: str, version: str) -> Generator[float, None, None]:
|
|
111
|
-
# try downloading the new resources to a temporary location
|
|
112
|
-
temp_path = os.path.join(os.path.dirname(path), "_temp_")
|
|
113
|
-
# clear the temporary location
|
|
114
|
-
if os.path.isfile(temp_path):
|
|
115
|
-
os.remove(temp_path)
|
|
116
|
-
elif os.path.isdir(temp_path):
|
|
117
|
-
shutil.rmtree(temp_path, ignore_errors=True)
|
|
118
|
-
|
|
119
|
-
yield from download_resources_iter(temp_path, version)
|
|
120
|
-
if os.path.isdir(path):
|
|
121
|
-
shutil.rmtree(path, ignore_errors=True)
|
|
122
|
-
|
|
123
|
-
shutil.move(temp_path, path)
|
|
124
|
-
|
|
125
|
-
with open(os.path.join(path, "version"), "w") as f:
|
|
126
|
-
f.write(version)
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
def download_with_retry(
|
|
130
|
-
url: str, chunk_size: int = 4096, attempts: int = 5
|
|
131
|
-
) -> Generator[float, None, bytes]:
|
|
132
|
-
content_length_found = 0
|
|
133
|
-
content = []
|
|
134
|
-
|
|
135
|
-
for _ in range(attempts):
|
|
136
|
-
request = Request(url, headers={"Range": f"bytes={content_length_found}-"})
|
|
137
|
-
with urlopen(request, timeout=20) as response:
|
|
138
|
-
content_length = int(response.headers["content-length"].strip())
|
|
139
|
-
while content_length_found < content_length:
|
|
140
|
-
chunk = response.read(chunk_size)
|
|
141
|
-
if not chunk:
|
|
142
|
-
break
|
|
143
|
-
content.append(chunk)
|
|
144
|
-
content_length_found += len(chunk)
|
|
145
|
-
yield min(1.0, content_length_found / content_length)
|
|
146
|
-
if content_length == content_length_found:
|
|
147
|
-
break
|
|
148
|
-
else:
|
|
149
|
-
raise RuntimeError(f"Failed to download")
|
|
150
|
-
return b"".join(content)
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
def download_resources(path: str, version: str) -> None:
|
|
154
|
-
generator_unpacker(download_resources_iter(path, version))
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
def download_resources_iter(
|
|
158
|
-
path: str, version: str, chunk_size: int = 4096
|
|
159
|
-
) -> Generator[float, None, None]:
|
|
160
|
-
log.info(f"Downloading Java resource pack for version {version}")
|
|
161
|
-
version_url = next(
|
|
162
|
-
(v["url"] for v in get_launcher_manifest()["versions"] if v["id"] == version),
|
|
163
|
-
None,
|
|
164
|
-
)
|
|
165
|
-
if version_url is None:
|
|
166
|
-
raise Exception(f"Could not find Java resource pack for version {version}.")
|
|
167
|
-
|
|
168
|
-
try:
|
|
169
|
-
with urlopen(version_url, timeout=20) as vm:
|
|
170
|
-
version_manifest = json.load(vm)
|
|
171
|
-
version_client_url = version_manifest["downloads"]["client"]["url"]
|
|
172
|
-
|
|
173
|
-
downloader = download_with_retry(version_client_url)
|
|
174
|
-
try:
|
|
175
|
-
while True:
|
|
176
|
-
yield next(downloader) / 2
|
|
177
|
-
except StopIteration as e:
|
|
178
|
-
data = e.value
|
|
179
|
-
|
|
180
|
-
client = zipfile.ZipFile(io.BytesIO(data))
|
|
181
|
-
paths: list[str] = [
|
|
182
|
-
fpath for fpath in client.namelist() if fpath.startswith("assets/")
|
|
183
|
-
]
|
|
184
|
-
path_count = len(paths)
|
|
185
|
-
for path_index, fpath in enumerate(paths):
|
|
186
|
-
if not path_index % 30:
|
|
187
|
-
yield path_index / (path_count * 2) + 0.5
|
|
188
|
-
if fpath.endswith("/"):
|
|
189
|
-
continue
|
|
190
|
-
os.makedirs(
|
|
191
|
-
os.path.dirname(os.path.abspath(os.path.join(path, fpath))),
|
|
192
|
-
exist_ok=True,
|
|
193
|
-
)
|
|
194
|
-
client.extract(fpath, path)
|
|
195
|
-
if "pack.mcmeta" in client.namelist():
|
|
196
|
-
client.extract("pack.mcmeta", path)
|
|
197
|
-
else:
|
|
198
|
-
# TODO: work out proper version support for this
|
|
199
|
-
with open(os.path.join(path, "pack.mcmeta"), "w") as f:
|
|
200
|
-
f.write(
|
|
201
|
-
'{"pack": {"description": "The default data for Minecraft","pack_format": 7}}'
|
|
202
|
-
)
|
|
203
|
-
if "pack.png" in client.namelist():
|
|
204
|
-
client.extract("pack.png", path)
|
|
205
|
-
|
|
206
|
-
except Exception as e:
|
|
207
|
-
log.error(
|
|
208
|
-
f"Failed to download and extract the Java resource pack for version {version}.",
|
|
209
|
-
exc_info=True,
|
|
210
|
-
)
|
|
211
|
-
raise e
|
|
212
|
-
log.info(f"Finished downloading Java resource pack for version {version}")
|
amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_black.png
DELETED
|
Binary file
|
amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_blue.png
DELETED
|
Binary file
|
amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_brown.png
DELETED
|
Binary file
|
amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_cyan.png
DELETED
|
Binary file
|
amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_gray.png
DELETED
|
Binary file
|
amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_green.png
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_lime.png
DELETED
|
Binary file
|
amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_magenta.png
DELETED
|
Binary file
|
amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_orange.png
DELETED
|
Binary file
|
amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_pink.png
DELETED
|
Binary file
|
amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_purple.png
DELETED
|
Binary file
|
amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_red.png
DELETED
|
Binary file
|
amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_white.png
DELETED
|
Binary file
|
amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_yellow.png
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/structure_void.png
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|