amulet-core 2.0a8__cp311-cp311-win_amd64.whl → 2.0.1.0.1297307203.19.43.34808.0a1__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.0a8.dist-info → amulet_core-2.0.1.0.1297307203.19.43.34808.0a1.dist-info}/METADATA +25 -20
- amulet_core-2.0.1.0.1297307203.19.43.34808.0a1.dist-info/RECORD +45 -0
- {amulet_core-2.0a8.dist-info → amulet_core-2.0.1.0.1297307203.19.43.34808.0a1.dist-info}/WHEEL +1 -1
- amulet_core-2.0.1.0.1297307203.19.43.34808.0a1.dist-info/entry_points.txt +2 -0
- amulet/__init__.cp311-win_amd64.pyd +0 -0
- amulet/__init__.py.cpp +0 -45
- amulet/__init__.pyi +0 -30
- 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 -100
- 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 -358
- 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__.pyi +0 -301
- amulet/mesh/block/_cube.py +0 -198
- amulet/mesh/block/_missing_block.py +0 -20
- amulet/mesh/block/block_mesh.cpp +0 -107
- amulet/mesh/block/block_mesh.hpp +0 -207
- 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 -63
- 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 -85
- 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 -563
- 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/cast.py +0 -10
- 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.0a8.dist-info/RECORD +0 -241
- amulet_core-2.0a8.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.0a8.dist-info → amulet_core-2.0.1.0.1297307203.19.43.34808.0a1.dist-info}/top_level.txt +0 -0
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from typing import Self, Any
|
|
4
|
-
from collections.abc import Sequence
|
|
5
|
-
|
|
6
|
-
from .abc import (
|
|
7
|
-
AbstractBaseTranslationFunction,
|
|
8
|
-
translation_function_from_json,
|
|
9
|
-
Data,
|
|
10
|
-
)
|
|
11
|
-
from amulet.game.abc import JSONCompatible, JSONList
|
|
12
|
-
from ._state import SrcData, StateData, DstData
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class TranslationFunctionSequence(AbstractBaseTranslationFunction):
|
|
16
|
-
# Class variables
|
|
17
|
-
Name = "sequence"
|
|
18
|
-
_instances = {}
|
|
19
|
-
|
|
20
|
-
# Instance variables
|
|
21
|
-
_functions: tuple[AbstractBaseTranslationFunction, ...]
|
|
22
|
-
|
|
23
|
-
def __init__(self, functions: Sequence[AbstractBaseTranslationFunction]) -> None:
|
|
24
|
-
super().__init__()
|
|
25
|
-
self._functions = tuple(functions)
|
|
26
|
-
if not all(
|
|
27
|
-
isinstance(inst, AbstractBaseTranslationFunction)
|
|
28
|
-
for inst in self._functions
|
|
29
|
-
):
|
|
30
|
-
raise TypeError
|
|
31
|
-
|
|
32
|
-
def __reduce__(self) -> Any:
|
|
33
|
-
return TranslationFunctionSequence, (self._functions,)
|
|
34
|
-
|
|
35
|
-
def _data(self) -> Data:
|
|
36
|
-
return self._functions
|
|
37
|
-
|
|
38
|
-
@classmethod
|
|
39
|
-
def from_json(cls, data: JSONCompatible) -> Self:
|
|
40
|
-
assert isinstance(data, Sequence)
|
|
41
|
-
return cls([translation_function_from_json(func) for func in data])
|
|
42
|
-
|
|
43
|
-
def to_json(self) -> JSONList:
|
|
44
|
-
return [func.to_json() for func in self._functions]
|
|
45
|
-
|
|
46
|
-
def __bool__(self) -> bool:
|
|
47
|
-
return bool(self._functions)
|
|
48
|
-
|
|
49
|
-
def run(self, src: SrcData, state: StateData, dst: DstData) -> None:
|
|
50
|
-
for func in self._functions:
|
|
51
|
-
func.run(src, state, dst)
|
|
@@ -1,331 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from typing import Self, TypeVar, cast, Any
|
|
4
|
-
from collections.abc import Mapping, Sequence, Iterable
|
|
5
|
-
import logging
|
|
6
|
-
|
|
7
|
-
from amulet_nbt import (
|
|
8
|
-
AbstractBaseArrayTag,
|
|
9
|
-
ByteTag,
|
|
10
|
-
ShortTag,
|
|
11
|
-
IntTag,
|
|
12
|
-
LongTag,
|
|
13
|
-
FloatTag,
|
|
14
|
-
DoubleTag,
|
|
15
|
-
ByteArrayTag,
|
|
16
|
-
StringTag,
|
|
17
|
-
ListTag,
|
|
18
|
-
CompoundTag,
|
|
19
|
-
IntArrayTag,
|
|
20
|
-
LongArrayTag,
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
from .abc import (
|
|
24
|
-
AbstractBaseTranslationFunction,
|
|
25
|
-
Data,
|
|
26
|
-
translation_function_from_json,
|
|
27
|
-
follow_nbt_path,
|
|
28
|
-
)
|
|
29
|
-
from amulet.game.abc import JSONCompatible, JSONDict
|
|
30
|
-
from ._typing import NBTClsToStr, StrToNBTCls, NBTPath, NBTPathElement, NBTTagClsT
|
|
31
|
-
from ._frozen import FrozenMapping
|
|
32
|
-
from ._state import SrcData, StateData, DstData
|
|
33
|
-
|
|
34
|
-
log = logging.getLogger(__name__)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
NBTLookUp = [
|
|
38
|
-
None,
|
|
39
|
-
ByteTag,
|
|
40
|
-
ShortTag,
|
|
41
|
-
IntTag,
|
|
42
|
-
LongTag,
|
|
43
|
-
FloatTag,
|
|
44
|
-
DoubleTag,
|
|
45
|
-
ByteArrayTag,
|
|
46
|
-
StringTag,
|
|
47
|
-
ListTag,
|
|
48
|
-
CompoundTag,
|
|
49
|
-
IntArrayTag,
|
|
50
|
-
LongArrayTag,
|
|
51
|
-
]
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
KeyT = TypeVar("KeyT", str, int)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
class WalkInputNBTOptions(AbstractBaseTranslationFunction):
|
|
58
|
-
# Class variables
|
|
59
|
-
Name = "_walk_input_nbt"
|
|
60
|
-
_instances = {}
|
|
61
|
-
|
|
62
|
-
# Instance variables
|
|
63
|
-
_nbt_cls: type[CompoundTag] | type[ListTag]
|
|
64
|
-
_self_default: AbstractBaseTranslationFunction | None
|
|
65
|
-
_functions: AbstractBaseTranslationFunction | None
|
|
66
|
-
_keys: FrozenMapping[str, WalkInputNBTOptions] | None
|
|
67
|
-
_index: FrozenMapping[int, WalkInputNBTOptions] | None
|
|
68
|
-
_nested_default: AbstractBaseTranslationFunction | None
|
|
69
|
-
|
|
70
|
-
def __init__(
|
|
71
|
-
self,
|
|
72
|
-
nbt_cls: type[CompoundTag] | type[ListTag],
|
|
73
|
-
self_default: AbstractBaseTranslationFunction | None = None,
|
|
74
|
-
functions: AbstractBaseTranslationFunction | None = None,
|
|
75
|
-
keys: Mapping[str, WalkInputNBTOptions] | None = None,
|
|
76
|
-
index: Mapping[int, WalkInputNBTOptions] | None = None,
|
|
77
|
-
nested_default: AbstractBaseTranslationFunction | None = None,
|
|
78
|
-
) -> None:
|
|
79
|
-
super().__init__()
|
|
80
|
-
self._nbt_cls = nbt_cls
|
|
81
|
-
self._self_default = self_default
|
|
82
|
-
self._functions = functions
|
|
83
|
-
self._keys = (
|
|
84
|
-
None if keys is None else FrozenMapping[str, WalkInputNBTOptions](keys)
|
|
85
|
-
)
|
|
86
|
-
self._index = (
|
|
87
|
-
None if index is None else FrozenMapping[int, WalkInputNBTOptions](index)
|
|
88
|
-
)
|
|
89
|
-
self._nested_default = nested_default
|
|
90
|
-
|
|
91
|
-
def __reduce__(self) -> Any:
|
|
92
|
-
return WalkInputNBTOptions, (
|
|
93
|
-
self._nbt_cls,
|
|
94
|
-
self._self_default,
|
|
95
|
-
self._functions,
|
|
96
|
-
self._keys,
|
|
97
|
-
self._index,
|
|
98
|
-
self._nested_default,
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
def _data(self) -> Data:
|
|
102
|
-
return (
|
|
103
|
-
self._nbt_cls,
|
|
104
|
-
self._self_default,
|
|
105
|
-
self._functions,
|
|
106
|
-
self._keys,
|
|
107
|
-
self._index,
|
|
108
|
-
self._nested_default,
|
|
109
|
-
)
|
|
110
|
-
|
|
111
|
-
@classmethod
|
|
112
|
-
def from_json(cls, data: JSONCompatible) -> Self:
|
|
113
|
-
assert isinstance(data, dict)
|
|
114
|
-
nbt_type = data["type"]
|
|
115
|
-
assert isinstance(nbt_type, str)
|
|
116
|
-
if "keys" in data:
|
|
117
|
-
raw_keys = data["keys"]
|
|
118
|
-
assert isinstance(raw_keys, dict)
|
|
119
|
-
keys = {
|
|
120
|
-
key: WalkInputNBTOptions.from_json(value)
|
|
121
|
-
for key, value in raw_keys.items()
|
|
122
|
-
}
|
|
123
|
-
else:
|
|
124
|
-
keys = None
|
|
125
|
-
if "index" in data:
|
|
126
|
-
raw_index = data["index"]
|
|
127
|
-
assert isinstance(raw_index, dict)
|
|
128
|
-
index = {
|
|
129
|
-
int(key): WalkInputNBTOptions.from_json(value)
|
|
130
|
-
for key, value in raw_index.items()
|
|
131
|
-
}
|
|
132
|
-
else:
|
|
133
|
-
index = None
|
|
134
|
-
return cls(
|
|
135
|
-
StrToNBTCls[nbt_type],
|
|
136
|
-
(
|
|
137
|
-
translation_function_from_json(data["self_default"])
|
|
138
|
-
if "self_default" in data
|
|
139
|
-
else None
|
|
140
|
-
),
|
|
141
|
-
(
|
|
142
|
-
translation_function_from_json(data["functions"])
|
|
143
|
-
if "functions" in data
|
|
144
|
-
else None
|
|
145
|
-
),
|
|
146
|
-
keys,
|
|
147
|
-
index,
|
|
148
|
-
(
|
|
149
|
-
translation_function_from_json(data["nested_default"])
|
|
150
|
-
if "nested_default" in data
|
|
151
|
-
else None
|
|
152
|
-
),
|
|
153
|
-
)
|
|
154
|
-
|
|
155
|
-
def to_json(self) -> JSONDict:
|
|
156
|
-
options: JSONDict = {
|
|
157
|
-
"type": NBTClsToStr[self._nbt_cls],
|
|
158
|
-
}
|
|
159
|
-
if self._self_default is not None:
|
|
160
|
-
options["self_default"] = self._self_default.to_json()
|
|
161
|
-
if self._functions is not None:
|
|
162
|
-
options["functions"] = self._functions.to_json()
|
|
163
|
-
if self._keys is not None:
|
|
164
|
-
options["keys"] = {
|
|
165
|
-
key: value.to_json() for key, value in self._keys.items()
|
|
166
|
-
}
|
|
167
|
-
if self._index is not None:
|
|
168
|
-
options["index"] = {
|
|
169
|
-
str(key): value.to_json() for key, value in self._index.items()
|
|
170
|
-
}
|
|
171
|
-
if self._nested_default is not None:
|
|
172
|
-
options["nested_default"] = self._nested_default.to_json()
|
|
173
|
-
return options
|
|
174
|
-
|
|
175
|
-
def run(self, src: SrcData, state: StateData, dst: DstData) -> None:
|
|
176
|
-
if self._functions is not None:
|
|
177
|
-
self._functions.run(src, state, dst)
|
|
178
|
-
|
|
179
|
-
nbt = src.nbt
|
|
180
|
-
if nbt is None:
|
|
181
|
-
raise RuntimeError
|
|
182
|
-
nbt_path_or_none = state.nbt_path
|
|
183
|
-
if nbt_path_or_none is None:
|
|
184
|
-
raise RuntimeError
|
|
185
|
-
else:
|
|
186
|
-
nbt_path = nbt_path_or_none
|
|
187
|
-
|
|
188
|
-
tag_or_none = follow_nbt_path(nbt, nbt_path)
|
|
189
|
-
|
|
190
|
-
nbt_cls = self._nbt_cls
|
|
191
|
-
if tag_or_none is None:
|
|
192
|
-
pass
|
|
193
|
-
elif isinstance(tag_or_none, nbt_cls):
|
|
194
|
-
tag = tag_or_none
|
|
195
|
-
|
|
196
|
-
def run(
|
|
197
|
-
keys: Iterable[KeyT],
|
|
198
|
-
lut: Mapping[KeyT, WalkInputNBTOptions] | None,
|
|
199
|
-
nested_dtype: NBTTagClsT | None,
|
|
200
|
-
) -> None:
|
|
201
|
-
for key in keys:
|
|
202
|
-
if lut is not None and key in lut:
|
|
203
|
-
lut[key].run(src, StateData(), dst)
|
|
204
|
-
elif self._nested_default is not None:
|
|
205
|
-
outer_name, outer_type, path = nbt_path
|
|
206
|
-
new_type: NBTTagClsT
|
|
207
|
-
if nested_dtype is None:
|
|
208
|
-
new_type = tag.__class__
|
|
209
|
-
else:
|
|
210
|
-
new_type = nested_dtype
|
|
211
|
-
new_path: NBTPath = path + (
|
|
212
|
-
(
|
|
213
|
-
key,
|
|
214
|
-
new_type,
|
|
215
|
-
),
|
|
216
|
-
)
|
|
217
|
-
self._nested_default.run(
|
|
218
|
-
src,
|
|
219
|
-
StateData(
|
|
220
|
-
state.relative_location,
|
|
221
|
-
(
|
|
222
|
-
outer_name,
|
|
223
|
-
outer_type,
|
|
224
|
-
new_path,
|
|
225
|
-
),
|
|
226
|
-
),
|
|
227
|
-
dst,
|
|
228
|
-
)
|
|
229
|
-
|
|
230
|
-
if isinstance(tag, CompoundTag):
|
|
231
|
-
run(
|
|
232
|
-
[key for key in tag.keys() if isinstance(key, str)],
|
|
233
|
-
self._keys,
|
|
234
|
-
None,
|
|
235
|
-
)
|
|
236
|
-
elif isinstance(tag, ListTag):
|
|
237
|
-
dtype = NBTLookUp[tag.element_tag_id]
|
|
238
|
-
assert dtype is not None
|
|
239
|
-
run(range(len(tag)), self._index, dtype)
|
|
240
|
-
elif isinstance(tag, AbstractBaseArrayTag):
|
|
241
|
-
nested_dtype_: NBTTagClsT
|
|
242
|
-
if isinstance(tag, ByteArrayTag):
|
|
243
|
-
nested_dtype_ = ByteTag
|
|
244
|
-
elif isinstance(tag, IntArrayTag):
|
|
245
|
-
nested_dtype_ = IntTag
|
|
246
|
-
elif isinstance(tag, LongArrayTag):
|
|
247
|
-
nested_dtype_ = LongTag
|
|
248
|
-
else:
|
|
249
|
-
raise TypeError
|
|
250
|
-
run(range(len(tag)), self._index, nested_dtype_)
|
|
251
|
-
else:
|
|
252
|
-
return
|
|
253
|
-
|
|
254
|
-
elif self._self_default is not None:
|
|
255
|
-
self._self_default.run(src, state, dst)
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
class WalkInputNBT(AbstractBaseTranslationFunction):
|
|
259
|
-
# Class variables
|
|
260
|
-
Name = "walk_input_nbt"
|
|
261
|
-
_instances = {}
|
|
262
|
-
|
|
263
|
-
# Instance variables
|
|
264
|
-
_walk_nbt: WalkInputNBTOptions
|
|
265
|
-
_path: NBTPath | None
|
|
266
|
-
|
|
267
|
-
def __init__(
|
|
268
|
-
self,
|
|
269
|
-
walk_nbt: WalkInputNBTOptions,
|
|
270
|
-
path: Sequence[NBTPathElement] | None = None,
|
|
271
|
-
) -> None:
|
|
272
|
-
super().__init__()
|
|
273
|
-
self._walk_nbt = walk_nbt
|
|
274
|
-
self._path = None if path is None else tuple(path)
|
|
275
|
-
|
|
276
|
-
def __reduce__(self) -> Any:
|
|
277
|
-
return WalkInputNBT, (self._walk_nbt, self._path)
|
|
278
|
-
|
|
279
|
-
def _data(self) -> Data:
|
|
280
|
-
return self._walk_nbt, self._path
|
|
281
|
-
|
|
282
|
-
@classmethod
|
|
283
|
-
def from_json(cls, data: JSONCompatible) -> Self:
|
|
284
|
-
assert isinstance(data, dict)
|
|
285
|
-
assert data.get("function") == "walk_input_nbt"
|
|
286
|
-
raw_path = data.get("path", None)
|
|
287
|
-
if raw_path is None:
|
|
288
|
-
path = None
|
|
289
|
-
elif isinstance(raw_path, list):
|
|
290
|
-
path = []
|
|
291
|
-
for item in raw_path:
|
|
292
|
-
assert isinstance(item, list) and len(item) == 2
|
|
293
|
-
key, cls_name = item
|
|
294
|
-
assert isinstance(key, str | int)
|
|
295
|
-
assert isinstance(cls_name, str)
|
|
296
|
-
path.append((key, StrToNBTCls[cls_name]))
|
|
297
|
-
else:
|
|
298
|
-
raise TypeError
|
|
299
|
-
return cls(
|
|
300
|
-
WalkInputNBTOptions.from_json(data["options"]),
|
|
301
|
-
path,
|
|
302
|
-
)
|
|
303
|
-
|
|
304
|
-
def to_json(self) -> JSONDict:
|
|
305
|
-
data: JSONDict = {
|
|
306
|
-
"function": "walk_input_nbt",
|
|
307
|
-
"options": self._walk_nbt.to_json(),
|
|
308
|
-
}
|
|
309
|
-
if self._path is not None:
|
|
310
|
-
data["path"] = [[key, NBTClsToStr[cls]] for key, cls in self._path]
|
|
311
|
-
return data
|
|
312
|
-
|
|
313
|
-
def run(self, src: SrcData, state: StateData, dst: DstData) -> None:
|
|
314
|
-
dst.cacheable = False
|
|
315
|
-
nbt = src.nbt
|
|
316
|
-
if nbt is None:
|
|
317
|
-
dst.extra_needed = True
|
|
318
|
-
return
|
|
319
|
-
|
|
320
|
-
if self._path is None:
|
|
321
|
-
new_state = state
|
|
322
|
-
else:
|
|
323
|
-
path = ("", CompoundTag, self._path)
|
|
324
|
-
# verify that the data exists at the path
|
|
325
|
-
tag = follow_nbt_path(nbt, path)
|
|
326
|
-
if not isinstance(tag, self._path[-1][1]):
|
|
327
|
-
log.error(f"Tag at path {path} does not exist or has the wrong type.")
|
|
328
|
-
return
|
|
329
|
-
new_state = StateData(state.relative_location, path)
|
|
330
|
-
|
|
331
|
-
self._walk_nbt.run(src, new_state, dst)
|