amulet-core 1.9.19__py3-none-any.whl → 1.9.20__py3-none-any.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/__init__.py +27 -27
- amulet/__pyinstaller/__init__.py +2 -2
- amulet/__pyinstaller/hook-amulet.py +4 -4
- amulet/_version.py +21 -21
- amulet/api/__init__.py +2 -2
- amulet/api/abstract_base_entity.py +128 -128
- amulet/api/block.py +630 -630
- amulet/api/block_entity.py +71 -71
- amulet/api/cache.py +107 -107
- amulet/api/chunk/__init__.py +6 -6
- amulet/api/chunk/biomes.py +207 -207
- amulet/api/chunk/block_entity_dict.py +175 -175
- amulet/api/chunk/blocks.py +46 -46
- amulet/api/chunk/chunk.py +389 -389
- amulet/api/chunk/entity_list.py +75 -75
- amulet/api/chunk/status.py +167 -167
- amulet/api/data_types/__init__.py +4 -4
- amulet/api/data_types/generic_types.py +4 -4
- amulet/api/data_types/operation_types.py +16 -16
- amulet/api/data_types/world_types.py +49 -49
- amulet/api/data_types/wrapper_types.py +71 -71
- amulet/api/entity.py +74 -74
- amulet/api/errors.py +119 -119
- amulet/api/history/__init__.py +36 -36
- amulet/api/history/base/__init__.py +3 -3
- amulet/api/history/base/base_history.py +26 -26
- amulet/api/history/base/history_manager.py +63 -63
- amulet/api/history/base/revision_manager.py +73 -73
- amulet/api/history/changeable.py +15 -15
- amulet/api/history/data_types.py +7 -7
- amulet/api/history/history_manager/__init__.py +3 -3
- amulet/api/history/history_manager/container.py +102 -102
- amulet/api/history/history_manager/database.py +279 -279
- amulet/api/history/history_manager/meta.py +93 -93
- amulet/api/history/history_manager/object.py +116 -116
- amulet/api/history/revision_manager/__init__.py +2 -2
- amulet/api/history/revision_manager/disk.py +33 -33
- amulet/api/history/revision_manager/ram.py +12 -12
- amulet/api/item.py +75 -75
- amulet/api/level/__init__.py +4 -4
- amulet/api/level/base_level/__init__.py +1 -1
- amulet/api/level/base_level/base_level.py +1035 -1026
- amulet/api/level/base_level/chunk_manager.py +227 -227
- amulet/api/level/base_level/clone.py +389 -389
- amulet/api/level/base_level/player_manager.py +101 -101
- amulet/api/level/immutable_structure/__init__.py +1 -1
- amulet/api/level/immutable_structure/immutable_structure.py +94 -94
- amulet/api/level/immutable_structure/void_format_wrapper.py +117 -117
- amulet/api/level/structure.py +22 -22
- amulet/api/level/world.py +19 -19
- amulet/api/partial_3d_array/__init__.py +2 -2
- amulet/api/partial_3d_array/base_partial_3d_array.py +263 -263
- amulet/api/partial_3d_array/bounded_partial_3d_array.py +528 -528
- amulet/api/partial_3d_array/data_types.py +15 -15
- amulet/api/partial_3d_array/unbounded_partial_3d_array.py +229 -229
- amulet/api/partial_3d_array/util.py +152 -152
- amulet/api/player.py +65 -65
- amulet/api/registry/__init__.py +2 -2
- amulet/api/registry/base_registry.py +34 -34
- amulet/api/registry/biome_manager.py +153 -153
- amulet/api/registry/block_manager.py +156 -156
- amulet/api/selection/__init__.py +2 -2
- amulet/api/selection/abstract_selection.py +315 -315
- amulet/api/selection/box.py +805 -805
- amulet/api/selection/group.py +488 -488
- amulet/api/structure.py +37 -37
- amulet/api/wrapper/__init__.py +8 -8
- amulet/api/wrapper/chunk/interface.py +441 -441
- amulet/api/wrapper/chunk/translator.py +567 -567
- amulet/api/wrapper/format_wrapper.py +772 -772
- amulet/api/wrapper/structure_format_wrapper.py +116 -116
- amulet/api/wrapper/world_format_wrapper.py +63 -63
- amulet/level/__init__.py +1 -1
- amulet/level/formats/anvil_forge_world.py +40 -40
- amulet/level/formats/anvil_world/__init__.py +3 -3
- amulet/level/formats/anvil_world/_sector_manager.py +291 -384
- amulet/level/formats/anvil_world/data_pack/__init__.py +2 -2
- amulet/level/formats/anvil_world/data_pack/data_pack.py +224 -224
- amulet/level/formats/anvil_world/data_pack/data_pack_manager.py +77 -77
- amulet/level/formats/anvil_world/dimension.py +177 -177
- amulet/level/formats/anvil_world/format.py +769 -769
- amulet/level/formats/anvil_world/region.py +384 -384
- amulet/level/formats/construction/__init__.py +3 -3
- amulet/level/formats/construction/format_wrapper.py +515 -515
- amulet/level/formats/construction/interface.py +134 -134
- amulet/level/formats/construction/section.py +60 -60
- amulet/level/formats/construction/util.py +165 -165
- amulet/level/formats/leveldb_world/__init__.py +3 -3
- amulet/level/formats/leveldb_world/chunk.py +33 -33
- amulet/level/formats/leveldb_world/dimension.py +385 -419
- amulet/level/formats/leveldb_world/format.py +659 -641
- amulet/level/formats/leveldb_world/interface/chunk/__init__.py +36 -36
- amulet/level/formats/leveldb_world/interface/chunk/base_leveldb_interface.py +836 -836
- amulet/level/formats/leveldb_world/interface/chunk/generate_interface.py +31 -31
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_0.py +30 -30
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_1.py +12 -12
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_10.py +12 -12
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_11.py +12 -12
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_12.py +12 -12
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_13.py +12 -12
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_14.py +12 -12
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_15.py +12 -12
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_16.py +12 -12
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_17.py +12 -12
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_18.py +12 -12
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_19.py +12 -12
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_2.py +12 -12
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_20.py +12 -12
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_21.py +12 -12
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_22.py +12 -12
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_23.py +10 -10
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_24.py +10 -10
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_25.py +24 -24
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_26.py +10 -10
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_27.py +10 -10
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_28.py +10 -10
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_29.py +33 -33
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_3.py +57 -57
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_30.py +10 -10
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_31.py +10 -10
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_32.py +10 -10
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_33.py +10 -10
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_34.py +10 -10
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_35.py +10 -10
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_36.py +10 -10
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_37.py +10 -10
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_38.py +10 -10
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_39.py +12 -12
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_4.py +12 -12
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_40.py +16 -16
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_5.py +12 -12
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_6.py +12 -12
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_7.py +12 -12
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_8.py +180 -180
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_9.py +18 -18
- amulet/level/formats/leveldb_world/interface/chunk/leveldb_chunk_versions.py +79 -79
- amulet/level/formats/mcstructure/__init__.py +3 -3
- amulet/level/formats/mcstructure/chunk.py +50 -50
- amulet/level/formats/mcstructure/format_wrapper.py +408 -408
- amulet/level/formats/mcstructure/interface.py +175 -175
- amulet/level/formats/schematic/__init__.py +3 -3
- amulet/level/formats/schematic/chunk.py +55 -55
- amulet/level/formats/schematic/data_types.py +4 -4
- amulet/level/formats/schematic/format_wrapper.py +373 -373
- amulet/level/formats/schematic/interface.py +142 -142
- amulet/level/formats/sponge_schem/__init__.py +4 -4
- amulet/level/formats/sponge_schem/chunk.py +62 -62
- amulet/level/formats/sponge_schem/format_wrapper.py +463 -463
- amulet/level/formats/sponge_schem/interface.py +118 -118
- amulet/level/formats/sponge_schem/varint/__init__.py +1 -1
- amulet/level/formats/sponge_schem/varint/varint.py +87 -87
- amulet/level/interfaces/chunk/anvil/anvil_0.py +72 -72
- amulet/level/interfaces/chunk/anvil/anvil_1444.py +336 -336
- amulet/level/interfaces/chunk/anvil/anvil_1466.py +94 -94
- amulet/level/interfaces/chunk/anvil/anvil_1467.py +37 -37
- amulet/level/interfaces/chunk/anvil/anvil_1484.py +20 -20
- amulet/level/interfaces/chunk/anvil/anvil_1503.py +20 -20
- amulet/level/interfaces/chunk/anvil/anvil_1519.py +34 -34
- amulet/level/interfaces/chunk/anvil/anvil_1901.py +20 -20
- amulet/level/interfaces/chunk/anvil/anvil_1908.py +20 -20
- amulet/level/interfaces/chunk/anvil/anvil_1912.py +21 -21
- amulet/level/interfaces/chunk/anvil/anvil_1934.py +20 -20
- amulet/level/interfaces/chunk/anvil/anvil_2203.py +69 -69
- amulet/level/interfaces/chunk/anvil/anvil_2529.py +19 -19
- amulet/level/interfaces/chunk/anvil/anvil_2681.py +76 -76
- amulet/level/interfaces/chunk/anvil/anvil_2709.py +19 -19
- amulet/level/interfaces/chunk/anvil/anvil_2844.py +267 -267
- amulet/level/interfaces/chunk/anvil/anvil_3463.py +19 -19
- amulet/level/interfaces/chunk/anvil/anvil_na.py +607 -607
- amulet/level/interfaces/chunk/anvil/base_anvil_interface.py +326 -326
- amulet/level/load.py +59 -59
- amulet/level/loader.py +95 -95
- amulet/level/translators/chunk/bedrock/__init__.py +267 -267
- amulet/level/translators/chunk/bedrock/bedrock_nbt_blockstate_translator.py +46 -46
- amulet/level/translators/chunk/bedrock/bedrock_numerical_translator.py +39 -39
- amulet/level/translators/chunk/bedrock/bedrock_psudo_numerical_translator.py +37 -37
- amulet/level/translators/chunk/java/java_1_18_translator.py +40 -40
- amulet/level/translators/chunk/java/java_blockstate_translator.py +94 -94
- amulet/level/translators/chunk/java/java_numerical_translator.py +62 -62
- amulet/libs/leveldb/__init__.py +7 -7
- amulet/operations/__init__.py +5 -5
- amulet/operations/clone.py +18 -18
- amulet/operations/delete_chunk.py +32 -32
- amulet/operations/fill.py +30 -30
- amulet/operations/paste.py +65 -65
- amulet/operations/replace.py +58 -58
- amulet/utils/__init__.py +14 -14
- amulet/utils/format_utils.py +41 -41
- amulet/utils/generator.py +15 -15
- amulet/utils/matrix.py +243 -243
- amulet/utils/numpy_helpers.py +46 -46
- amulet/utils/world_utils.py +349 -349
- {amulet_core-1.9.19.dist-info → amulet_core-1.9.20.dist-info}/METADATA +97 -97
- amulet_core-1.9.20.dist-info/RECORD +208 -0
- amulet_core-1.9.19.dist-info/RECORD +0 -208
- {amulet_core-1.9.19.dist-info → amulet_core-1.9.20.dist-info}/WHEEL +0 -0
- {amulet_core-1.9.19.dist-info → amulet_core-1.9.20.dist-info}/entry_points.txt +0 -0
- {amulet_core-1.9.19.dist-info → amulet_core-1.9.20.dist-info}/top_level.txt +0 -0
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from typing import Generator, Set, Iterable, Dict
|
|
4
|
-
|
|
5
|
-
import weakref
|
|
6
|
-
|
|
7
|
-
from amulet.api.player import Player
|
|
8
|
-
from amulet.api.history.history_manager import DatabaseHistoryManager
|
|
9
|
-
from amulet.api.history.revision_manager import RAMRevisionManager
|
|
10
|
-
from amulet.api import level as api_level
|
|
11
|
-
from amulet.api.errors import PlayerLoadError, PlayerDoesNotExist
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class PlayerManager(DatabaseHistoryManager):
|
|
15
|
-
_temporary_database: Dict[str, Player]
|
|
16
|
-
_history_database: Dict[str, RAMRevisionManager]
|
|
17
|
-
|
|
18
|
-
DoesNotExistError = PlayerDoesNotExist
|
|
19
|
-
LoadError = PlayerLoadError
|
|
20
|
-
|
|
21
|
-
def __init__(self, level: api_level.BaseLevel):
|
|
22
|
-
"""
|
|
23
|
-
Construct a new :class:`PlayerManager` instance
|
|
24
|
-
|
|
25
|
-
This should not be used by third party code
|
|
26
|
-
|
|
27
|
-
:param level: The world that this player manager is associated with
|
|
28
|
-
"""
|
|
29
|
-
super().__init__()
|
|
30
|
-
self._level = weakref.ref(level)
|
|
31
|
-
|
|
32
|
-
@property
|
|
33
|
-
def level(self) -> api_level.BaseLevel:
|
|
34
|
-
"""The level that this player manager is associated with."""
|
|
35
|
-
return self._level()
|
|
36
|
-
|
|
37
|
-
def all_player_ids(self) -> Set[str]:
|
|
38
|
-
"""
|
|
39
|
-
Returns a set of all player ids that are present in the level
|
|
40
|
-
"""
|
|
41
|
-
return self._all_entries()
|
|
42
|
-
|
|
43
|
-
def _raw_all_entries(self) -> Iterable[str]:
|
|
44
|
-
return self.level.level_wrapper.all_player_ids()
|
|
45
|
-
|
|
46
|
-
def changed_players(self) -> Generator[str, None, None]:
|
|
47
|
-
"""The player objects that have changed since the last save"""
|
|
48
|
-
return self.changed_entries()
|
|
49
|
-
|
|
50
|
-
def has_player(self, player_id: str) -> bool:
|
|
51
|
-
"""
|
|
52
|
-
Is the given player id present in the level
|
|
53
|
-
|
|
54
|
-
:param player_id: The player id to check
|
|
55
|
-
:return: True if the player id is present, False otherwise
|
|
56
|
-
"""
|
|
57
|
-
return self._has_entry(player_id)
|
|
58
|
-
|
|
59
|
-
def _raw_has_entry(self, key: str) -> bool:
|
|
60
|
-
return self.level.level_wrapper.has_player(key)
|
|
61
|
-
|
|
62
|
-
def __contains__(self, item):
|
|
63
|
-
"""
|
|
64
|
-
Is the given player id present in the level
|
|
65
|
-
|
|
66
|
-
>>> '<uuid>' in level.players
|
|
67
|
-
|
|
68
|
-
:param item: The player id to check
|
|
69
|
-
:return: True if the player id is present, False otherwise
|
|
70
|
-
"""
|
|
71
|
-
return self.has_player(item)
|
|
72
|
-
|
|
73
|
-
def put_player(self, player: Player):
|
|
74
|
-
"""
|
|
75
|
-
Add the given player to the player manager.
|
|
76
|
-
|
|
77
|
-
:param player: The :class:`Player` object to add to the chunk manager. It will be added with the key designated by :attr:`Player.uuid`
|
|
78
|
-
"""
|
|
79
|
-
self._put_entry(player.player_id, player)
|
|
80
|
-
|
|
81
|
-
def get_player(self, player_id: str) -> Player:
|
|
82
|
-
"""
|
|
83
|
-
Gets the :class:`Player` object that belongs to the specified player id
|
|
84
|
-
|
|
85
|
-
If no parameter is supplied, the data of the local player will be returned
|
|
86
|
-
|
|
87
|
-
:param player_id: The desired player id
|
|
88
|
-
:return: A Player instance
|
|
89
|
-
"""
|
|
90
|
-
return self._get_entry(player_id)
|
|
91
|
-
|
|
92
|
-
def _raw_get_entry(self, key: str) -> Player:
|
|
93
|
-
return self.level.level_wrapper.load_player(key)
|
|
94
|
-
|
|
95
|
-
def delete_player(self, player_id: str):
|
|
96
|
-
"""
|
|
97
|
-
Deletes a player from the player manager
|
|
98
|
-
|
|
99
|
-
:param player_id: The desired player id
|
|
100
|
-
"""
|
|
101
|
-
self._delete_entry(player_id)
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Generator, Set, Iterable, Dict
|
|
4
|
+
|
|
5
|
+
import weakref
|
|
6
|
+
|
|
7
|
+
from amulet.api.player import Player
|
|
8
|
+
from amulet.api.history.history_manager import DatabaseHistoryManager
|
|
9
|
+
from amulet.api.history.revision_manager import RAMRevisionManager
|
|
10
|
+
from amulet.api import level as api_level
|
|
11
|
+
from amulet.api.errors import PlayerLoadError, PlayerDoesNotExist
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class PlayerManager(DatabaseHistoryManager):
|
|
15
|
+
_temporary_database: Dict[str, Player]
|
|
16
|
+
_history_database: Dict[str, RAMRevisionManager]
|
|
17
|
+
|
|
18
|
+
DoesNotExistError = PlayerDoesNotExist
|
|
19
|
+
LoadError = PlayerLoadError
|
|
20
|
+
|
|
21
|
+
def __init__(self, level: api_level.BaseLevel):
|
|
22
|
+
"""
|
|
23
|
+
Construct a new :class:`PlayerManager` instance
|
|
24
|
+
|
|
25
|
+
This should not be used by third party code
|
|
26
|
+
|
|
27
|
+
:param level: The world that this player manager is associated with
|
|
28
|
+
"""
|
|
29
|
+
super().__init__()
|
|
30
|
+
self._level = weakref.ref(level)
|
|
31
|
+
|
|
32
|
+
@property
|
|
33
|
+
def level(self) -> api_level.BaseLevel:
|
|
34
|
+
"""The level that this player manager is associated with."""
|
|
35
|
+
return self._level()
|
|
36
|
+
|
|
37
|
+
def all_player_ids(self) -> Set[str]:
|
|
38
|
+
"""
|
|
39
|
+
Returns a set of all player ids that are present in the level
|
|
40
|
+
"""
|
|
41
|
+
return self._all_entries()
|
|
42
|
+
|
|
43
|
+
def _raw_all_entries(self) -> Iterable[str]:
|
|
44
|
+
return self.level.level_wrapper.all_player_ids()
|
|
45
|
+
|
|
46
|
+
def changed_players(self) -> Generator[str, None, None]:
|
|
47
|
+
"""The player objects that have changed since the last save"""
|
|
48
|
+
return self.changed_entries()
|
|
49
|
+
|
|
50
|
+
def has_player(self, player_id: str) -> bool:
|
|
51
|
+
"""
|
|
52
|
+
Is the given player id present in the level
|
|
53
|
+
|
|
54
|
+
:param player_id: The player id to check
|
|
55
|
+
:return: True if the player id is present, False otherwise
|
|
56
|
+
"""
|
|
57
|
+
return self._has_entry(player_id)
|
|
58
|
+
|
|
59
|
+
def _raw_has_entry(self, key: str) -> bool:
|
|
60
|
+
return self.level.level_wrapper.has_player(key)
|
|
61
|
+
|
|
62
|
+
def __contains__(self, item):
|
|
63
|
+
"""
|
|
64
|
+
Is the given player id present in the level
|
|
65
|
+
|
|
66
|
+
>>> '<uuid>' in level.players
|
|
67
|
+
|
|
68
|
+
:param item: The player id to check
|
|
69
|
+
:return: True if the player id is present, False otherwise
|
|
70
|
+
"""
|
|
71
|
+
return self.has_player(item)
|
|
72
|
+
|
|
73
|
+
def put_player(self, player: Player):
|
|
74
|
+
"""
|
|
75
|
+
Add the given player to the player manager.
|
|
76
|
+
|
|
77
|
+
:param player: The :class:`Player` object to add to the chunk manager. It will be added with the key designated by :attr:`Player.uuid`
|
|
78
|
+
"""
|
|
79
|
+
self._put_entry(player.player_id, player)
|
|
80
|
+
|
|
81
|
+
def get_player(self, player_id: str) -> Player:
|
|
82
|
+
"""
|
|
83
|
+
Gets the :class:`Player` object that belongs to the specified player id
|
|
84
|
+
|
|
85
|
+
If no parameter is supplied, the data of the local player will be returned
|
|
86
|
+
|
|
87
|
+
:param player_id: The desired player id
|
|
88
|
+
:return: A Player instance
|
|
89
|
+
"""
|
|
90
|
+
return self._get_entry(player_id)
|
|
91
|
+
|
|
92
|
+
def _raw_get_entry(self, key: str) -> Player:
|
|
93
|
+
return self.level.level_wrapper.load_player(key)
|
|
94
|
+
|
|
95
|
+
def delete_player(self, player_id: str):
|
|
96
|
+
"""
|
|
97
|
+
Deletes a player from the player manager
|
|
98
|
+
|
|
99
|
+
:param player_id: The desired player id
|
|
100
|
+
"""
|
|
101
|
+
self._delete_entry(player_id)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
from .immutable_structure import ImmutableStructure
|
|
1
|
+
from .immutable_structure import ImmutableStructure
|
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
from typing import Generator
|
|
3
|
-
|
|
4
|
-
from ..base_level import BaseLevel
|
|
5
|
-
from .void_format_wrapper import VoidFormatWrapper
|
|
6
|
-
from amulet.api.chunk import Chunk
|
|
7
|
-
from amulet.api.data_types import Dimension
|
|
8
|
-
from amulet.api.selection import SelectionGroup, SelectionBox
|
|
9
|
-
from amulet.utils.generator import generator_unpacker
|
|
10
|
-
import copy
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class ImmutableStructure(BaseLevel):
|
|
14
|
-
"""
|
|
15
|
-
This is a special version of the level class that is only used when extracting a region of the world.
|
|
16
|
-
|
|
17
|
-
It is much the same as a normal level class but does not have an associated file/folder data like :class:`~amulet.api.level.World` and :class:`~amulet.api.level.Structure` do.
|
|
18
|
-
|
|
19
|
-
To extract a section of a world you should use :meth:`~amulet.api.level.BaseLevel.extract_structure`.
|
|
20
|
-
"""
|
|
21
|
-
|
|
22
|
-
def __init__(
|
|
23
|
-
self,
|
|
24
|
-
):
|
|
25
|
-
"""
|
|
26
|
-
Construct an :class:`ImmutableStructure` instance.
|
|
27
|
-
|
|
28
|
-
You probably don't want to call this directly.
|
|
29
|
-
|
|
30
|
-
To extract a section of a world you should use :meth:`~amulet.api.level.BaseLevel.extract_structure`.
|
|
31
|
-
"""
|
|
32
|
-
super().__init__("", VoidFormatWrapper(""))
|
|
33
|
-
self._selection = SelectionGroup(
|
|
34
|
-
[
|
|
35
|
-
SelectionBox(
|
|
36
|
-
(-30_000_000, -30_000_000, -30_000_000),
|
|
37
|
-
(30_000_000, 30_000_000, 30_000_000),
|
|
38
|
-
)
|
|
39
|
-
]
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
@property
|
|
43
|
-
def selection_bounds(self) -> SelectionGroup:
|
|
44
|
-
return self._selection
|
|
45
|
-
|
|
46
|
-
def bounds(self, dimension: Dimension) -> SelectionGroup:
|
|
47
|
-
return self._selection
|
|
48
|
-
|
|
49
|
-
def undo(self):
|
|
50
|
-
pass
|
|
51
|
-
|
|
52
|
-
def redo(self):
|
|
53
|
-
pass
|
|
54
|
-
|
|
55
|
-
def put_chunk(self, chunk: Chunk, dimension: Dimension):
|
|
56
|
-
super().put_chunk(chunk, dimension)
|
|
57
|
-
self.history_manager.create_undo_point()
|
|
58
|
-
|
|
59
|
-
@classmethod
|
|
60
|
-
def from_level(
|
|
61
|
-
cls, level: BaseLevel, selection: SelectionGroup, dimension: Dimension
|
|
62
|
-
):
|
|
63
|
-
"""
|
|
64
|
-
Extract a section of the level into an :class:`ImmutableStructure` class.
|
|
65
|
-
|
|
66
|
-
:param level: The level to extract the area from.
|
|
67
|
-
:param selection: The selection to extract.
|
|
68
|
-
:param dimension: The dimension to extract from.
|
|
69
|
-
:return: The created instance of :class:`ImmutableStructure`
|
|
70
|
-
"""
|
|
71
|
-
return generator_unpacker(cls.from_level_iter(level, selection, dimension))
|
|
72
|
-
|
|
73
|
-
@classmethod
|
|
74
|
-
def from_level_iter(
|
|
75
|
-
cls, level: BaseLevel, selection: SelectionGroup, dimension: Dimension
|
|
76
|
-
) -> Generator[float, None, ImmutableStructure]:
|
|
77
|
-
"""
|
|
78
|
-
Extract a section of the level into an :class:`ImmutableStructure` class.
|
|
79
|
-
|
|
80
|
-
Also yields the progress from 0-1.
|
|
81
|
-
|
|
82
|
-
:param level: The level to extract the area from.
|
|
83
|
-
:param selection: The selection to extract.
|
|
84
|
-
:param dimension: The dimension to extract from.
|
|
85
|
-
:return: The created instance of :class:`ImmutableStructure`
|
|
86
|
-
"""
|
|
87
|
-
self = cls()
|
|
88
|
-
self._selection = selection
|
|
89
|
-
dst_dimension = self.dimensions[0]
|
|
90
|
-
count = len(list(level.get_coord_box(dimension, selection)))
|
|
91
|
-
for index, (chunk, _) in enumerate(level.get_chunk_boxes(dimension, selection)):
|
|
92
|
-
self.put_chunk(copy.deepcopy(chunk), dst_dimension)
|
|
93
|
-
yield (index + 1) / count
|
|
94
|
-
return self
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from typing import Generator
|
|
3
|
+
|
|
4
|
+
from ..base_level import BaseLevel
|
|
5
|
+
from .void_format_wrapper import VoidFormatWrapper
|
|
6
|
+
from amulet.api.chunk import Chunk
|
|
7
|
+
from amulet.api.data_types import Dimension
|
|
8
|
+
from amulet.api.selection import SelectionGroup, SelectionBox
|
|
9
|
+
from amulet.utils.generator import generator_unpacker
|
|
10
|
+
import copy
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ImmutableStructure(BaseLevel):
|
|
14
|
+
"""
|
|
15
|
+
This is a special version of the level class that is only used when extracting a region of the world.
|
|
16
|
+
|
|
17
|
+
It is much the same as a normal level class but does not have an associated file/folder data like :class:`~amulet.api.level.World` and :class:`~amulet.api.level.Structure` do.
|
|
18
|
+
|
|
19
|
+
To extract a section of a world you should use :meth:`~amulet.api.level.BaseLevel.extract_structure`.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __init__(
|
|
23
|
+
self,
|
|
24
|
+
):
|
|
25
|
+
"""
|
|
26
|
+
Construct an :class:`ImmutableStructure` instance.
|
|
27
|
+
|
|
28
|
+
You probably don't want to call this directly.
|
|
29
|
+
|
|
30
|
+
To extract a section of a world you should use :meth:`~amulet.api.level.BaseLevel.extract_structure`.
|
|
31
|
+
"""
|
|
32
|
+
super().__init__("", VoidFormatWrapper(""))
|
|
33
|
+
self._selection = SelectionGroup(
|
|
34
|
+
[
|
|
35
|
+
SelectionBox(
|
|
36
|
+
(-30_000_000, -30_000_000, -30_000_000),
|
|
37
|
+
(30_000_000, 30_000_000, 30_000_000),
|
|
38
|
+
)
|
|
39
|
+
]
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def selection_bounds(self) -> SelectionGroup:
|
|
44
|
+
return self._selection
|
|
45
|
+
|
|
46
|
+
def bounds(self, dimension: Dimension) -> SelectionGroup:
|
|
47
|
+
return self._selection
|
|
48
|
+
|
|
49
|
+
def undo(self):
|
|
50
|
+
pass
|
|
51
|
+
|
|
52
|
+
def redo(self):
|
|
53
|
+
pass
|
|
54
|
+
|
|
55
|
+
def put_chunk(self, chunk: Chunk, dimension: Dimension):
|
|
56
|
+
super().put_chunk(chunk, dimension)
|
|
57
|
+
self.history_manager.create_undo_point()
|
|
58
|
+
|
|
59
|
+
@classmethod
|
|
60
|
+
def from_level(
|
|
61
|
+
cls, level: BaseLevel, selection: SelectionGroup, dimension: Dimension
|
|
62
|
+
):
|
|
63
|
+
"""
|
|
64
|
+
Extract a section of the level into an :class:`ImmutableStructure` class.
|
|
65
|
+
|
|
66
|
+
:param level: The level to extract the area from.
|
|
67
|
+
:param selection: The selection to extract.
|
|
68
|
+
:param dimension: The dimension to extract from.
|
|
69
|
+
:return: The created instance of :class:`ImmutableStructure`
|
|
70
|
+
"""
|
|
71
|
+
return generator_unpacker(cls.from_level_iter(level, selection, dimension))
|
|
72
|
+
|
|
73
|
+
@classmethod
|
|
74
|
+
def from_level_iter(
|
|
75
|
+
cls, level: BaseLevel, selection: SelectionGroup, dimension: Dimension
|
|
76
|
+
) -> Generator[float, None, ImmutableStructure]:
|
|
77
|
+
"""
|
|
78
|
+
Extract a section of the level into an :class:`ImmutableStructure` class.
|
|
79
|
+
|
|
80
|
+
Also yields the progress from 0-1.
|
|
81
|
+
|
|
82
|
+
:param level: The level to extract the area from.
|
|
83
|
+
:param selection: The selection to extract.
|
|
84
|
+
:param dimension: The dimension to extract from.
|
|
85
|
+
:return: The created instance of :class:`ImmutableStructure`
|
|
86
|
+
"""
|
|
87
|
+
self = cls()
|
|
88
|
+
self._selection = selection
|
|
89
|
+
dst_dimension = self.dimensions[0]
|
|
90
|
+
count = len(list(level.get_coord_box(dimension, selection)))
|
|
91
|
+
for index, (chunk, _) in enumerate(level.get_chunk_boxes(dimension, selection)):
|
|
92
|
+
self.put_chunk(copy.deepcopy(chunk), dst_dimension)
|
|
93
|
+
yield (index + 1) / count
|
|
94
|
+
return self
|
|
@@ -1,117 +1,117 @@
|
|
|
1
|
-
from typing import Any, List, Dict, Tuple, Optional, TYPE_CHECKING, Iterable, Union
|
|
2
|
-
|
|
3
|
-
from amulet.api.data_types import (
|
|
4
|
-
Dimension,
|
|
5
|
-
PlatformType,
|
|
6
|
-
ChunkCoordinates,
|
|
7
|
-
AnyNDArray,
|
|
8
|
-
VersionNumberTuple,
|
|
9
|
-
)
|
|
10
|
-
from amulet.api.wrapper import FormatWrapper
|
|
11
|
-
from amulet.api.errors import ChunkDoesNotExist, PlayerDoesNotExist
|
|
12
|
-
from amulet.api.player import Player
|
|
13
|
-
from amulet.api.chunk import Chunk
|
|
14
|
-
from amulet.api.selection import SelectionGroup
|
|
15
|
-
from amulet.api import wrapper as api_wrapper
|
|
16
|
-
|
|
17
|
-
if TYPE_CHECKING:
|
|
18
|
-
from amulet.api.wrapper import Interface
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class VoidFormatWrapper(FormatWrapper[VersionNumberTuple]):
|
|
22
|
-
"""
|
|
23
|
-
A custom :class:`FormatWrapper` class that has no associated data.
|
|
24
|
-
|
|
25
|
-
This is just to make the :class:`ImmutableStructure` class happy since it requires a :class:`FormatWrapper` class.
|
|
26
|
-
|
|
27
|
-
All methods effectively do nothing.
|
|
28
|
-
"""
|
|
29
|
-
|
|
30
|
-
def __init__(self, path: str):
|
|
31
|
-
super().__init__(path)
|
|
32
|
-
self._platform = "Unknown Platform"
|
|
33
|
-
self._version = (0, 0, 0)
|
|
34
|
-
|
|
35
|
-
@property
|
|
36
|
-
def level_name(self) -> str:
|
|
37
|
-
return "Void"
|
|
38
|
-
|
|
39
|
-
@staticmethod
|
|
40
|
-
def is_valid(path: str) -> bool:
|
|
41
|
-
return False
|
|
42
|
-
|
|
43
|
-
@property
|
|
44
|
-
def valid_formats(self) -> Dict[PlatformType, Tuple[bool, bool]]:
|
|
45
|
-
return {}
|
|
46
|
-
|
|
47
|
-
@property
|
|
48
|
-
def dimensions(self) -> List[Dimension]:
|
|
49
|
-
return ["main"]
|
|
50
|
-
|
|
51
|
-
@property
|
|
52
|
-
def can_add_dimension(self) -> bool:
|
|
53
|
-
return False
|
|
54
|
-
|
|
55
|
-
def register_dimension(self, dimension_identifier: Any):
|
|
56
|
-
pass
|
|
57
|
-
|
|
58
|
-
def _get_interface(self, raw_chunk_data: Optional[Any] = None) -> "Interface":
|
|
59
|
-
raise Exception("If this is called something is wrong")
|
|
60
|
-
|
|
61
|
-
def _encode(
|
|
62
|
-
self,
|
|
63
|
-
interface: api_wrapper.Interface,
|
|
64
|
-
chunk: Chunk,
|
|
65
|
-
dimension: Dimension,
|
|
66
|
-
chunk_palette: AnyNDArray,
|
|
67
|
-
) -> Any:
|
|
68
|
-
raise Exception("If this is called something is wrong")
|
|
69
|
-
|
|
70
|
-
def _create(
|
|
71
|
-
self,
|
|
72
|
-
overwrite: bool,
|
|
73
|
-
bounds: Union[
|
|
74
|
-
SelectionGroup, Dict[Dimension, Optional[SelectionGroup]], None
|
|
75
|
-
] = None,
|
|
76
|
-
**kwargs
|
|
77
|
-
):
|
|
78
|
-
pass
|
|
79
|
-
|
|
80
|
-
def _open(self):
|
|
81
|
-
pass
|
|
82
|
-
|
|
83
|
-
def _save(self):
|
|
84
|
-
pass
|
|
85
|
-
|
|
86
|
-
def _close(self):
|
|
87
|
-
pass
|
|
88
|
-
|
|
89
|
-
def unload(self):
|
|
90
|
-
pass
|
|
91
|
-
|
|
92
|
-
def all_chunk_coords(self, dimension: Dimension) -> Iterable[ChunkCoordinates]:
|
|
93
|
-
yield from ()
|
|
94
|
-
|
|
95
|
-
def has_chunk(self, cx: int, cz: int, dimension: Dimension) -> bool:
|
|
96
|
-
return False
|
|
97
|
-
|
|
98
|
-
def _delete_chunk(self, cx: int, cz: int, dimension: Dimension):
|
|
99
|
-
pass
|
|
100
|
-
|
|
101
|
-
def _put_raw_chunk_data(self, cx: int, cz: int, data: Any, dimension: Dimension):
|
|
102
|
-
pass
|
|
103
|
-
|
|
104
|
-
def _get_raw_chunk_data(self, cx: int, cz: int, dimension: Dimension) -> Any:
|
|
105
|
-
raise ChunkDoesNotExist
|
|
106
|
-
|
|
107
|
-
def all_player_ids(self) -> Iterable[str]:
|
|
108
|
-
yield from ()
|
|
109
|
-
|
|
110
|
-
def has_player(self, player_id: str) -> bool:
|
|
111
|
-
return False
|
|
112
|
-
|
|
113
|
-
def _load_player(self, player_id: str) -> Player:
|
|
114
|
-
raise PlayerDoesNotExist
|
|
115
|
-
|
|
116
|
-
def _get_raw_player_data(self, player_id: str) -> Any:
|
|
117
|
-
raise PlayerDoesNotExist
|
|
1
|
+
from typing import Any, List, Dict, Tuple, Optional, TYPE_CHECKING, Iterable, Union
|
|
2
|
+
|
|
3
|
+
from amulet.api.data_types import (
|
|
4
|
+
Dimension,
|
|
5
|
+
PlatformType,
|
|
6
|
+
ChunkCoordinates,
|
|
7
|
+
AnyNDArray,
|
|
8
|
+
VersionNumberTuple,
|
|
9
|
+
)
|
|
10
|
+
from amulet.api.wrapper import FormatWrapper
|
|
11
|
+
from amulet.api.errors import ChunkDoesNotExist, PlayerDoesNotExist
|
|
12
|
+
from amulet.api.player import Player
|
|
13
|
+
from amulet.api.chunk import Chunk
|
|
14
|
+
from amulet.api.selection import SelectionGroup
|
|
15
|
+
from amulet.api import wrapper as api_wrapper
|
|
16
|
+
|
|
17
|
+
if TYPE_CHECKING:
|
|
18
|
+
from amulet.api.wrapper import Interface
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class VoidFormatWrapper(FormatWrapper[VersionNumberTuple]):
|
|
22
|
+
"""
|
|
23
|
+
A custom :class:`FormatWrapper` class that has no associated data.
|
|
24
|
+
|
|
25
|
+
This is just to make the :class:`ImmutableStructure` class happy since it requires a :class:`FormatWrapper` class.
|
|
26
|
+
|
|
27
|
+
All methods effectively do nothing.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
def __init__(self, path: str):
|
|
31
|
+
super().__init__(path)
|
|
32
|
+
self._platform = "Unknown Platform"
|
|
33
|
+
self._version = (0, 0, 0)
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
def level_name(self) -> str:
|
|
37
|
+
return "Void"
|
|
38
|
+
|
|
39
|
+
@staticmethod
|
|
40
|
+
def is_valid(path: str) -> bool:
|
|
41
|
+
return False
|
|
42
|
+
|
|
43
|
+
@property
|
|
44
|
+
def valid_formats(self) -> Dict[PlatformType, Tuple[bool, bool]]:
|
|
45
|
+
return {}
|
|
46
|
+
|
|
47
|
+
@property
|
|
48
|
+
def dimensions(self) -> List[Dimension]:
|
|
49
|
+
return ["main"]
|
|
50
|
+
|
|
51
|
+
@property
|
|
52
|
+
def can_add_dimension(self) -> bool:
|
|
53
|
+
return False
|
|
54
|
+
|
|
55
|
+
def register_dimension(self, dimension_identifier: Any):
|
|
56
|
+
pass
|
|
57
|
+
|
|
58
|
+
def _get_interface(self, raw_chunk_data: Optional[Any] = None) -> "Interface":
|
|
59
|
+
raise Exception("If this is called something is wrong")
|
|
60
|
+
|
|
61
|
+
def _encode(
|
|
62
|
+
self,
|
|
63
|
+
interface: api_wrapper.Interface,
|
|
64
|
+
chunk: Chunk,
|
|
65
|
+
dimension: Dimension,
|
|
66
|
+
chunk_palette: AnyNDArray,
|
|
67
|
+
) -> Any:
|
|
68
|
+
raise Exception("If this is called something is wrong")
|
|
69
|
+
|
|
70
|
+
def _create(
|
|
71
|
+
self,
|
|
72
|
+
overwrite: bool,
|
|
73
|
+
bounds: Union[
|
|
74
|
+
SelectionGroup, Dict[Dimension, Optional[SelectionGroup]], None
|
|
75
|
+
] = None,
|
|
76
|
+
**kwargs
|
|
77
|
+
):
|
|
78
|
+
pass
|
|
79
|
+
|
|
80
|
+
def _open(self):
|
|
81
|
+
pass
|
|
82
|
+
|
|
83
|
+
def _save(self):
|
|
84
|
+
pass
|
|
85
|
+
|
|
86
|
+
def _close(self):
|
|
87
|
+
pass
|
|
88
|
+
|
|
89
|
+
def unload(self):
|
|
90
|
+
pass
|
|
91
|
+
|
|
92
|
+
def all_chunk_coords(self, dimension: Dimension) -> Iterable[ChunkCoordinates]:
|
|
93
|
+
yield from ()
|
|
94
|
+
|
|
95
|
+
def has_chunk(self, cx: int, cz: int, dimension: Dimension) -> bool:
|
|
96
|
+
return False
|
|
97
|
+
|
|
98
|
+
def _delete_chunk(self, cx: int, cz: int, dimension: Dimension):
|
|
99
|
+
pass
|
|
100
|
+
|
|
101
|
+
def _put_raw_chunk_data(self, cx: int, cz: int, data: Any, dimension: Dimension):
|
|
102
|
+
pass
|
|
103
|
+
|
|
104
|
+
def _get_raw_chunk_data(self, cx: int, cz: int, dimension: Dimension) -> Any:
|
|
105
|
+
raise ChunkDoesNotExist
|
|
106
|
+
|
|
107
|
+
def all_player_ids(self) -> Iterable[str]:
|
|
108
|
+
yield from ()
|
|
109
|
+
|
|
110
|
+
def has_player(self, player_id: str) -> bool:
|
|
111
|
+
return False
|
|
112
|
+
|
|
113
|
+
def _load_player(self, player_id: str) -> Player:
|
|
114
|
+
raise PlayerDoesNotExist
|
|
115
|
+
|
|
116
|
+
def _get_raw_player_data(self, player_id: str) -> Any:
|
|
117
|
+
raise PlayerDoesNotExist
|
amulet/api/level/structure.py
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from .base_level import BaseLevel
|
|
4
|
-
from amulet.api import wrapper as api_wrapper
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class Structure(BaseLevel):
|
|
8
|
-
"""
|
|
9
|
-
Class that handles editing of any structure format via an separate and flexible data format
|
|
10
|
-
"""
|
|
11
|
-
|
|
12
|
-
def __init__(
|
|
13
|
-
self,
|
|
14
|
-
directory: str,
|
|
15
|
-
structure_wrapper: api_wrapper.StructureFormatWrapper,
|
|
16
|
-
):
|
|
17
|
-
super().__init__(directory, structure_wrapper)
|
|
18
|
-
|
|
19
|
-
@property
|
|
20
|
-
def level_wrapper(self) -> api_wrapper.StructureFormatWrapper:
|
|
21
|
-
"""A class to access data directly from the level."""
|
|
22
|
-
return self._level_wrapper
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from .base_level import BaseLevel
|
|
4
|
+
from amulet.api import wrapper as api_wrapper
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Structure(BaseLevel):
|
|
8
|
+
"""
|
|
9
|
+
Class that handles editing of any structure format via an separate and flexible data format
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
def __init__(
|
|
13
|
+
self,
|
|
14
|
+
directory: str,
|
|
15
|
+
structure_wrapper: api_wrapper.StructureFormatWrapper,
|
|
16
|
+
):
|
|
17
|
+
super().__init__(directory, structure_wrapper)
|
|
18
|
+
|
|
19
|
+
@property
|
|
20
|
+
def level_wrapper(self) -> api_wrapper.StructureFormatWrapper:
|
|
21
|
+
"""A class to access data directly from the level."""
|
|
22
|
+
return self._level_wrapper
|