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,71 +1,71 @@
|
|
|
1
|
-
from typing import Union, Callable, Tuple, Optional, TYPE_CHECKING, List
|
|
2
|
-
import numpy
|
|
3
|
-
|
|
4
|
-
if TYPE_CHECKING:
|
|
5
|
-
from .world_types import BlockCoordinates
|
|
6
|
-
from amulet.api.chunk import Chunk
|
|
7
|
-
from amulet.api.block import Block
|
|
8
|
-
from amulet.api.block_entity import BlockEntity
|
|
9
|
-
from amulet.api.entity import Entity
|
|
10
|
-
|
|
11
|
-
# Wrapper types
|
|
12
|
-
BlockNDArray = numpy.ndarray # NDArray[(Any, ), 'Block']
|
|
13
|
-
AnyNDArray = numpy.ndarray # NDArray[(Any, ), Any]
|
|
14
|
-
|
|
15
|
-
#: The data type for the platform identifier.
|
|
16
|
-
PlatformType = str
|
|
17
|
-
|
|
18
|
-
#: The data type for an integer version number.
|
|
19
|
-
VersionNumberInt = int
|
|
20
|
-
|
|
21
|
-
#: The data type for the tuple version number.
|
|
22
|
-
VersionNumberTuple = Tuple[int, ...]
|
|
23
|
-
|
|
24
|
-
#: The data type for either an integer or tuple version number.
|
|
25
|
-
VersionNumberAny = Union[VersionNumberInt, VersionNumberTuple]
|
|
26
|
-
|
|
27
|
-
#: The data type for a version identifier containing platform and int or tuple version number
|
|
28
|
-
VersionIdentifierType = Tuple[PlatformType, VersionNumberAny]
|
|
29
|
-
#: The data type for a version identifier containing platform and int version number
|
|
30
|
-
VersionIdentifierInt = Tuple[PlatformType, VersionNumberInt]
|
|
31
|
-
#: The data type for a version identifier containing platform and tuple version number
|
|
32
|
-
VersionIdentifierTuple = Tuple[PlatformType, VersionNumberTuple]
|
|
33
|
-
|
|
34
|
-
GetChunkCallback = Callable[[int, int], "Chunk"]
|
|
35
|
-
|
|
36
|
-
BedrockInterfaceBlockType = Tuple[
|
|
37
|
-
Union[Tuple[None, Tuple[int, int]], Tuple[None, "Block"], Tuple[int, "Block"]], ...
|
|
38
|
-
]
|
|
39
|
-
|
|
40
|
-
GetBlockCallback = Callable[ # get a block at a different location
|
|
41
|
-
[
|
|
42
|
-
"BlockCoordinates"
|
|
43
|
-
], # this takes the coordinates relative to the block in question
|
|
44
|
-
Tuple[
|
|
45
|
-
"Block", Optional["BlockEntity"]
|
|
46
|
-
], # and returns a new block and optionally a block entity
|
|
47
|
-
]
|
|
48
|
-
|
|
49
|
-
TranslateBlockCallbackReturn = Tuple[
|
|
50
|
-
Optional["Block"], Optional["BlockEntity"], List["Entity"], bool
|
|
51
|
-
]
|
|
52
|
-
|
|
53
|
-
TranslateEntityCallbackReturn = Tuple[
|
|
54
|
-
Optional["Block"], Optional["BlockEntity"], List["Entity"]
|
|
55
|
-
]
|
|
56
|
-
|
|
57
|
-
TranslateBlockCallback = Callable[
|
|
58
|
-
[ # a callable
|
|
59
|
-
"Block", # that takes either a Block
|
|
60
|
-
Optional[
|
|
61
|
-
GetBlockCallback
|
|
62
|
-
], # this is used in cases where the block needs data beyond itself to fully define itself (eg doors)
|
|
63
|
-
"BlockCoordinates", # used in a select few cases where the translation needs to know where the block is
|
|
64
|
-
],
|
|
65
|
-
TranslateBlockCallbackReturn, # ultimately return the converted objects(s)
|
|
66
|
-
]
|
|
67
|
-
|
|
68
|
-
TranslateEntityCallback = Callable[
|
|
69
|
-
["Entity"], # a callable # that takes either an Entity
|
|
70
|
-
TranslateEntityCallbackReturn, # ultimately return the converted objects(s)
|
|
71
|
-
]
|
|
1
|
+
from typing import Union, Callable, Tuple, Optional, TYPE_CHECKING, List
|
|
2
|
+
import numpy
|
|
3
|
+
|
|
4
|
+
if TYPE_CHECKING:
|
|
5
|
+
from .world_types import BlockCoordinates
|
|
6
|
+
from amulet.api.chunk import Chunk
|
|
7
|
+
from amulet.api.block import Block
|
|
8
|
+
from amulet.api.block_entity import BlockEntity
|
|
9
|
+
from amulet.api.entity import Entity
|
|
10
|
+
|
|
11
|
+
# Wrapper types
|
|
12
|
+
BlockNDArray = numpy.ndarray # NDArray[(Any, ), 'Block']
|
|
13
|
+
AnyNDArray = numpy.ndarray # NDArray[(Any, ), Any]
|
|
14
|
+
|
|
15
|
+
#: The data type for the platform identifier.
|
|
16
|
+
PlatformType = str
|
|
17
|
+
|
|
18
|
+
#: The data type for an integer version number.
|
|
19
|
+
VersionNumberInt = int
|
|
20
|
+
|
|
21
|
+
#: The data type for the tuple version number.
|
|
22
|
+
VersionNumberTuple = Tuple[int, ...]
|
|
23
|
+
|
|
24
|
+
#: The data type for either an integer or tuple version number.
|
|
25
|
+
VersionNumberAny = Union[VersionNumberInt, VersionNumberTuple]
|
|
26
|
+
|
|
27
|
+
#: The data type for a version identifier containing platform and int or tuple version number
|
|
28
|
+
VersionIdentifierType = Tuple[PlatformType, VersionNumberAny]
|
|
29
|
+
#: The data type for a version identifier containing platform and int version number
|
|
30
|
+
VersionIdentifierInt = Tuple[PlatformType, VersionNumberInt]
|
|
31
|
+
#: The data type for a version identifier containing platform and tuple version number
|
|
32
|
+
VersionIdentifierTuple = Tuple[PlatformType, VersionNumberTuple]
|
|
33
|
+
|
|
34
|
+
GetChunkCallback = Callable[[int, int], "Chunk"]
|
|
35
|
+
|
|
36
|
+
BedrockInterfaceBlockType = Tuple[
|
|
37
|
+
Union[Tuple[None, Tuple[int, int]], Tuple[None, "Block"], Tuple[int, "Block"]], ...
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
GetBlockCallback = Callable[ # get a block at a different location
|
|
41
|
+
[
|
|
42
|
+
"BlockCoordinates"
|
|
43
|
+
], # this takes the coordinates relative to the block in question
|
|
44
|
+
Tuple[
|
|
45
|
+
"Block", Optional["BlockEntity"]
|
|
46
|
+
], # and returns a new block and optionally a block entity
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
TranslateBlockCallbackReturn = Tuple[
|
|
50
|
+
Optional["Block"], Optional["BlockEntity"], List["Entity"], bool
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
TranslateEntityCallbackReturn = Tuple[
|
|
54
|
+
Optional["Block"], Optional["BlockEntity"], List["Entity"]
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
TranslateBlockCallback = Callable[
|
|
58
|
+
[ # a callable
|
|
59
|
+
"Block", # that takes either a Block
|
|
60
|
+
Optional[
|
|
61
|
+
GetBlockCallback
|
|
62
|
+
], # this is used in cases where the block needs data beyond itself to fully define itself (eg doors)
|
|
63
|
+
"BlockCoordinates", # used in a select few cases where the translation needs to know where the block is
|
|
64
|
+
],
|
|
65
|
+
TranslateBlockCallbackReturn, # ultimately return the converted objects(s)
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
TranslateEntityCallback = Callable[
|
|
69
|
+
["Entity"], # a callable # that takes either an Entity
|
|
70
|
+
TranslateEntityCallbackReturn, # ultimately return the converted objects(s)
|
|
71
|
+
]
|
amulet/api/entity.py
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import numpy
|
|
4
|
-
from typing import Tuple, Union
|
|
5
|
-
from amulet_nbt import NamedTag
|
|
6
|
-
from .abstract_base_entity import AbstractBaseEntity
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class Entity(AbstractBaseEntity):
|
|
10
|
-
"""
|
|
11
|
-
A class to contain all the data to define an Entity.
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
obj_name = "Entity"
|
|
15
|
-
coord_types = (float, numpy.floating)
|
|
16
|
-
|
|
17
|
-
def __init__(
|
|
18
|
-
self,
|
|
19
|
-
namespace: str,
|
|
20
|
-
base_name: str,
|
|
21
|
-
x: float,
|
|
22
|
-
y: float,
|
|
23
|
-
z: float,
|
|
24
|
-
nbt: NamedTag,
|
|
25
|
-
):
|
|
26
|
-
"""
|
|
27
|
-
Constructs a :class:`Entity` instance.
|
|
28
|
-
|
|
29
|
-
:param namespace: The namespace of the entity eg "minecraft"
|
|
30
|
-
:param base_name: The base name of the entity eg "creeper"
|
|
31
|
-
:param x: The x coordinate of the entity
|
|
32
|
-
:param y: The y coordinate of the entity
|
|
33
|
-
:param z: The z coordinate of the entity
|
|
34
|
-
:param nbt: The NBT stored with the entity
|
|
35
|
-
"""
|
|
36
|
-
super().__init__(namespace, base_name, x, y, z, nbt)
|
|
37
|
-
|
|
38
|
-
@property
|
|
39
|
-
def x(self) -> float:
|
|
40
|
-
"""The x location of the Entity."""
|
|
41
|
-
return self._x
|
|
42
|
-
|
|
43
|
-
@x.setter
|
|
44
|
-
def x(self, value: float):
|
|
45
|
-
self._x = value
|
|
46
|
-
|
|
47
|
-
@property
|
|
48
|
-
def y(self) -> float:
|
|
49
|
-
"""The y location of the Entity."""
|
|
50
|
-
return self._y
|
|
51
|
-
|
|
52
|
-
@y.setter
|
|
53
|
-
def y(self, value: float):
|
|
54
|
-
self._y = value
|
|
55
|
-
|
|
56
|
-
@property
|
|
57
|
-
def z(self) -> float:
|
|
58
|
-
"""The z location of the Entity."""
|
|
59
|
-
return self._z
|
|
60
|
-
|
|
61
|
-
@z.setter
|
|
62
|
-
def z(self, value: float):
|
|
63
|
-
self._z = value
|
|
64
|
-
|
|
65
|
-
@property
|
|
66
|
-
def location(self) -> Tuple[float, float, float]:
|
|
67
|
-
"""The location of the Entity."""
|
|
68
|
-
return self._x, self._y, self._z
|
|
69
|
-
|
|
70
|
-
@location.setter
|
|
71
|
-
def location(
|
|
72
|
-
self, location: Tuple[Union[int, float], Union[int, float], Union[int, float]]
|
|
73
|
-
):
|
|
74
|
-
self._x, self._y, self._z = location
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import numpy
|
|
4
|
+
from typing import Tuple, Union
|
|
5
|
+
from amulet_nbt import NamedTag
|
|
6
|
+
from .abstract_base_entity import AbstractBaseEntity
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Entity(AbstractBaseEntity):
|
|
10
|
+
"""
|
|
11
|
+
A class to contain all the data to define an Entity.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
obj_name = "Entity"
|
|
15
|
+
coord_types = (float, numpy.floating)
|
|
16
|
+
|
|
17
|
+
def __init__(
|
|
18
|
+
self,
|
|
19
|
+
namespace: str,
|
|
20
|
+
base_name: str,
|
|
21
|
+
x: float,
|
|
22
|
+
y: float,
|
|
23
|
+
z: float,
|
|
24
|
+
nbt: NamedTag,
|
|
25
|
+
):
|
|
26
|
+
"""
|
|
27
|
+
Constructs a :class:`Entity` instance.
|
|
28
|
+
|
|
29
|
+
:param namespace: The namespace of the entity eg "minecraft"
|
|
30
|
+
:param base_name: The base name of the entity eg "creeper"
|
|
31
|
+
:param x: The x coordinate of the entity
|
|
32
|
+
:param y: The y coordinate of the entity
|
|
33
|
+
:param z: The z coordinate of the entity
|
|
34
|
+
:param nbt: The NBT stored with the entity
|
|
35
|
+
"""
|
|
36
|
+
super().__init__(namespace, base_name, x, y, z, nbt)
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def x(self) -> float:
|
|
40
|
+
"""The x location of the Entity."""
|
|
41
|
+
return self._x
|
|
42
|
+
|
|
43
|
+
@x.setter
|
|
44
|
+
def x(self, value: float):
|
|
45
|
+
self._x = value
|
|
46
|
+
|
|
47
|
+
@property
|
|
48
|
+
def y(self) -> float:
|
|
49
|
+
"""The y location of the Entity."""
|
|
50
|
+
return self._y
|
|
51
|
+
|
|
52
|
+
@y.setter
|
|
53
|
+
def y(self, value: float):
|
|
54
|
+
self._y = value
|
|
55
|
+
|
|
56
|
+
@property
|
|
57
|
+
def z(self) -> float:
|
|
58
|
+
"""The z location of the Entity."""
|
|
59
|
+
return self._z
|
|
60
|
+
|
|
61
|
+
@z.setter
|
|
62
|
+
def z(self, value: float):
|
|
63
|
+
self._z = value
|
|
64
|
+
|
|
65
|
+
@property
|
|
66
|
+
def location(self) -> Tuple[float, float, float]:
|
|
67
|
+
"""The location of the Entity."""
|
|
68
|
+
return self._x, self._y, self._z
|
|
69
|
+
|
|
70
|
+
@location.setter
|
|
71
|
+
def location(
|
|
72
|
+
self, location: Tuple[Union[int, float], Union[int, float], Union[int, float]]
|
|
73
|
+
):
|
|
74
|
+
self._x, self._y, self._z = location
|
amulet/api/errors.py
CHANGED
|
@@ -1,119 +1,119 @@
|
|
|
1
|
-
class FormatError(Exception):
|
|
2
|
-
"""A base error for all errors related to the :class:`~amulet.api.wrapper.format_wrapper.FormatWrapper` class."""
|
|
3
|
-
|
|
4
|
-
pass
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class LoaderNoneMatched(FormatError):
|
|
8
|
-
"""An error thrown if no loader could be found that could load the given data."""
|
|
9
|
-
|
|
10
|
-
pass
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class BlockException(Exception):
|
|
14
|
-
"""An error thrown by the :class:`~amulet.api.block.Block` class."""
|
|
15
|
-
|
|
16
|
-
pass
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class EntryLoadError(Exception):
|
|
20
|
-
pass
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class EntryDoesNotExist(EntryLoadError):
|
|
24
|
-
pass
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
class PlayerLoadError(EntryLoadError):
|
|
28
|
-
"""
|
|
29
|
-
An error thrown if a player failed to load for some reason.
|
|
30
|
-
"""
|
|
31
|
-
|
|
32
|
-
pass
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
class PlayerDoesNotExist(EntryDoesNotExist, PlayerLoadError):
|
|
36
|
-
"""
|
|
37
|
-
An error thrown if a player does not exist.
|
|
38
|
-
"""
|
|
39
|
-
|
|
40
|
-
pass
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
class ChunkLoadError(EntryLoadError):
|
|
44
|
-
"""
|
|
45
|
-
An error thrown if a chunk failed to load for some reason.
|
|
46
|
-
|
|
47
|
-
This may be due to a corrupt chunk, an unsupported chunk format or just because the chunk does not exist to be loaded.
|
|
48
|
-
|
|
49
|
-
Catching this error will also catch :class:`ChunkDoesNotExist`
|
|
50
|
-
|
|
51
|
-
>>> try:
|
|
52
|
-
>>> # get chunk
|
|
53
|
-
>>> chunk = world.get_chunk(cx, cz, dimension)
|
|
54
|
-
>>> except ChunkLoadError:
|
|
55
|
-
>>> # will catch all chunks that have failed to load
|
|
56
|
-
>>> # either because they do not exist or errored during loading.
|
|
57
|
-
"""
|
|
58
|
-
|
|
59
|
-
pass
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
class ChunkDoesNotExist(EntryDoesNotExist, ChunkLoadError):
|
|
63
|
-
"""
|
|
64
|
-
An error thrown if a chunk does not exist and therefor cannot be loaded.
|
|
65
|
-
|
|
66
|
-
>>> try:
|
|
67
|
-
>>> # get chunk
|
|
68
|
-
>>> chunk = world.get_chunk(cx, cz, dimension)
|
|
69
|
-
>>> except ChunkDoesNotExist:
|
|
70
|
-
>>> # will catch all chunks that do not exist
|
|
71
|
-
>>> # will not catch corrupt chunks
|
|
72
|
-
>>> except ChunkLoadError:
|
|
73
|
-
>>> # will only catch chunks that errored during loading
|
|
74
|
-
>>> # chunks that do not exist were caught by the previous except section.
|
|
75
|
-
"""
|
|
76
|
-
|
|
77
|
-
pass
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
class ChunkSaveError(Exception):
|
|
81
|
-
"""An error thrown if there was an error during the chunk saving process."""
|
|
82
|
-
|
|
83
|
-
pass
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
class DimensionDoesNotExist(Exception):
|
|
87
|
-
"""An error thrown if trying to load data from a dimension that does not exist."""
|
|
88
|
-
|
|
89
|
-
pass
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
class ObjectReadWriteError(Exception):
|
|
93
|
-
"""
|
|
94
|
-
An error thrown when the raw level data cannot be read from or written to.
|
|
95
|
-
|
|
96
|
-
This is usually because the data has been opened somewhere else.
|
|
97
|
-
"""
|
|
98
|
-
|
|
99
|
-
pass
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
class ObjectReadError(ObjectReadWriteError):
|
|
103
|
-
"""
|
|
104
|
-
An error thrown when the raw level data cannot be read from.
|
|
105
|
-
|
|
106
|
-
This is usually because the data has been opened somewhere else.
|
|
107
|
-
"""
|
|
108
|
-
|
|
109
|
-
pass
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
class ObjectWriteError(ObjectReadWriteError):
|
|
113
|
-
"""
|
|
114
|
-
An error thrown when the raw level data cannot be written to.
|
|
115
|
-
|
|
116
|
-
This is usually because the data has been opened somewhere else.
|
|
117
|
-
"""
|
|
118
|
-
|
|
119
|
-
pass
|
|
1
|
+
class FormatError(Exception):
|
|
2
|
+
"""A base error for all errors related to the :class:`~amulet.api.wrapper.format_wrapper.FormatWrapper` class."""
|
|
3
|
+
|
|
4
|
+
pass
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class LoaderNoneMatched(FormatError):
|
|
8
|
+
"""An error thrown if no loader could be found that could load the given data."""
|
|
9
|
+
|
|
10
|
+
pass
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class BlockException(Exception):
|
|
14
|
+
"""An error thrown by the :class:`~amulet.api.block.Block` class."""
|
|
15
|
+
|
|
16
|
+
pass
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class EntryLoadError(Exception):
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class EntryDoesNotExist(EntryLoadError):
|
|
24
|
+
pass
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class PlayerLoadError(EntryLoadError):
|
|
28
|
+
"""
|
|
29
|
+
An error thrown if a player failed to load for some reason.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
pass
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class PlayerDoesNotExist(EntryDoesNotExist, PlayerLoadError):
|
|
36
|
+
"""
|
|
37
|
+
An error thrown if a player does not exist.
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
pass
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class ChunkLoadError(EntryLoadError):
|
|
44
|
+
"""
|
|
45
|
+
An error thrown if a chunk failed to load for some reason.
|
|
46
|
+
|
|
47
|
+
This may be due to a corrupt chunk, an unsupported chunk format or just because the chunk does not exist to be loaded.
|
|
48
|
+
|
|
49
|
+
Catching this error will also catch :class:`ChunkDoesNotExist`
|
|
50
|
+
|
|
51
|
+
>>> try:
|
|
52
|
+
>>> # get chunk
|
|
53
|
+
>>> chunk = world.get_chunk(cx, cz, dimension)
|
|
54
|
+
>>> except ChunkLoadError:
|
|
55
|
+
>>> # will catch all chunks that have failed to load
|
|
56
|
+
>>> # either because they do not exist or errored during loading.
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
pass
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class ChunkDoesNotExist(EntryDoesNotExist, ChunkLoadError):
|
|
63
|
+
"""
|
|
64
|
+
An error thrown if a chunk does not exist and therefor cannot be loaded.
|
|
65
|
+
|
|
66
|
+
>>> try:
|
|
67
|
+
>>> # get chunk
|
|
68
|
+
>>> chunk = world.get_chunk(cx, cz, dimension)
|
|
69
|
+
>>> except ChunkDoesNotExist:
|
|
70
|
+
>>> # will catch all chunks that do not exist
|
|
71
|
+
>>> # will not catch corrupt chunks
|
|
72
|
+
>>> except ChunkLoadError:
|
|
73
|
+
>>> # will only catch chunks that errored during loading
|
|
74
|
+
>>> # chunks that do not exist were caught by the previous except section.
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
pass
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class ChunkSaveError(Exception):
|
|
81
|
+
"""An error thrown if there was an error during the chunk saving process."""
|
|
82
|
+
|
|
83
|
+
pass
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class DimensionDoesNotExist(Exception):
|
|
87
|
+
"""An error thrown if trying to load data from a dimension that does not exist."""
|
|
88
|
+
|
|
89
|
+
pass
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class ObjectReadWriteError(Exception):
|
|
93
|
+
"""
|
|
94
|
+
An error thrown when the raw level data cannot be read from or written to.
|
|
95
|
+
|
|
96
|
+
This is usually because the data has been opened somewhere else.
|
|
97
|
+
"""
|
|
98
|
+
|
|
99
|
+
pass
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class ObjectReadError(ObjectReadWriteError):
|
|
103
|
+
"""
|
|
104
|
+
An error thrown when the raw level data cannot be read from.
|
|
105
|
+
|
|
106
|
+
This is usually because the data has been opened somewhere else.
|
|
107
|
+
"""
|
|
108
|
+
|
|
109
|
+
pass
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
class ObjectWriteError(ObjectReadWriteError):
|
|
113
|
+
"""
|
|
114
|
+
An error thrown when the raw level data cannot be written to.
|
|
115
|
+
|
|
116
|
+
This is usually because the data has been opened somewhere else.
|
|
117
|
+
"""
|
|
118
|
+
|
|
119
|
+
pass
|
amulet/api/history/__init__.py
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
"""
|
|
2
|
-
local history manager
|
|
3
|
-
key based storage
|
|
4
|
-
When a piece of data is loaded from disk it needs to be stored as revision 0
|
|
5
|
-
If a piece of data is deleted it should be stored as None to specify that the data has been deleted
|
|
6
|
-
If a piece of data was created rather than loaded from disk the revision 0 should be populated as None
|
|
7
|
-
to specify that the revision 0 did not exist and the data should be added as revision 1
|
|
8
|
-
It needs to store the revision index that is current within the editor.
|
|
9
|
-
It also needs to store the revision that is saved to disk so that we know what has changed compared to
|
|
10
|
-
the current save state rather than the original save state.
|
|
11
|
-
If the above two indexes do not match then the data has been changed compared to the saved version so it needs saving.
|
|
12
|
-
global storage
|
|
13
|
-
We need to store a list of pools of keys that have changed for each undo point.
|
|
14
|
-
We also need to store the index of which pool is current. This will get changed when undoing/redoing to keep track.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
When the creation of an undo point is requested
|
|
18
|
-
we should scan all of the objects and see if the `changed` flag has been set to `True`.
|
|
19
|
-
If this is the case the data has been changed and we should create a backup of it.
|
|
20
|
-
make sure to reset the `changed` flag to False for the cached version
|
|
21
|
-
A new revision for each entry is created and the current revision index is incremented.
|
|
22
|
-
A pool of keys that have changed should be created.
|
|
23
|
-
When undoing this change we look at this pool to see what changed and undo each of those.
|
|
24
|
-
The same applies when redoing
|
|
25
|
-
Finally the `changed` flags for each of the entries should be changed to False so that the next
|
|
26
|
-
undo point only catches what has changed since this undo point.
|
|
27
|
-
The better solution here is to empty the temporary database and re-populate from the latest cache
|
|
28
|
-
revision where the `changed` flag was already set to False. This also solves the issue where
|
|
29
|
-
the data was modified but the `changed` flag was not set to True by the script.
|
|
30
|
-
|
|
31
|
-
global history manager
|
|
32
|
-
would store each of the local history managers
|
|
33
|
-
would be the entry
|
|
34
|
-
"""
|
|
35
|
-
|
|
36
|
-
from .changeable import Changeable
|
|
1
|
+
"""
|
|
2
|
+
local history manager
|
|
3
|
+
key based storage
|
|
4
|
+
When a piece of data is loaded from disk it needs to be stored as revision 0
|
|
5
|
+
If a piece of data is deleted it should be stored as None to specify that the data has been deleted
|
|
6
|
+
If a piece of data was created rather than loaded from disk the revision 0 should be populated as None
|
|
7
|
+
to specify that the revision 0 did not exist and the data should be added as revision 1
|
|
8
|
+
It needs to store the revision index that is current within the editor.
|
|
9
|
+
It also needs to store the revision that is saved to disk so that we know what has changed compared to
|
|
10
|
+
the current save state rather than the original save state.
|
|
11
|
+
If the above two indexes do not match then the data has been changed compared to the saved version so it needs saving.
|
|
12
|
+
global storage
|
|
13
|
+
We need to store a list of pools of keys that have changed for each undo point.
|
|
14
|
+
We also need to store the index of which pool is current. This will get changed when undoing/redoing to keep track.
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
When the creation of an undo point is requested
|
|
18
|
+
we should scan all of the objects and see if the `changed` flag has been set to `True`.
|
|
19
|
+
If this is the case the data has been changed and we should create a backup of it.
|
|
20
|
+
make sure to reset the `changed` flag to False for the cached version
|
|
21
|
+
A new revision for each entry is created and the current revision index is incremented.
|
|
22
|
+
A pool of keys that have changed should be created.
|
|
23
|
+
When undoing this change we look at this pool to see what changed and undo each of those.
|
|
24
|
+
The same applies when redoing
|
|
25
|
+
Finally the `changed` flags for each of the entries should be changed to False so that the next
|
|
26
|
+
undo point only catches what has changed since this undo point.
|
|
27
|
+
The better solution here is to empty the temporary database and re-populate from the latest cache
|
|
28
|
+
revision where the `changed` flag was already set to False. This also solves the issue where
|
|
29
|
+
the data was modified but the `changed` flag was not set to True by the script.
|
|
30
|
+
|
|
31
|
+
global history manager
|
|
32
|
+
would store each of the local history managers
|
|
33
|
+
would be the entry
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
from .changeable import Changeable
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
from .base_history import BaseHistory
|
|
2
|
-
from .revision_manager import RevisionManager
|
|
3
|
-
from .history_manager import HistoryManager
|
|
1
|
+
from .base_history import BaseHistory
|
|
2
|
+
from .revision_manager import RevisionManager
|
|
3
|
+
from .history_manager import HistoryManager
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
from abc import ABC, abstractmethod
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class BaseHistory(ABC):
|
|
5
|
-
"""The base class for all history related objects"""
|
|
6
|
-
|
|
7
|
-
@abstractmethod
|
|
8
|
-
def undo(self):
|
|
9
|
-
"""Revert to the previous state."""
|
|
10
|
-
raise NotImplementedError
|
|
11
|
-
|
|
12
|
-
@abstractmethod
|
|
13
|
-
def redo(self):
|
|
14
|
-
"""Un-revert to the next state."""
|
|
15
|
-
raise NotImplementedError
|
|
16
|
-
|
|
17
|
-
@abstractmethod
|
|
18
|
-
def mark_saved(self):
|
|
19
|
-
"""Let the class know that the current state has been saved."""
|
|
20
|
-
raise NotImplementedError
|
|
21
|
-
|
|
22
|
-
@property
|
|
23
|
-
@abstractmethod
|
|
24
|
-
def changed(self) -> bool:
|
|
25
|
-
"""Have there been modifications since the last save."""
|
|
26
|
-
raise NotImplementedError
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class BaseHistory(ABC):
|
|
5
|
+
"""The base class for all history related objects"""
|
|
6
|
+
|
|
7
|
+
@abstractmethod
|
|
8
|
+
def undo(self):
|
|
9
|
+
"""Revert to the previous state."""
|
|
10
|
+
raise NotImplementedError
|
|
11
|
+
|
|
12
|
+
@abstractmethod
|
|
13
|
+
def redo(self):
|
|
14
|
+
"""Un-revert to the next state."""
|
|
15
|
+
raise NotImplementedError
|
|
16
|
+
|
|
17
|
+
@abstractmethod
|
|
18
|
+
def mark_saved(self):
|
|
19
|
+
"""Let the class know that the current state has been saved."""
|
|
20
|
+
raise NotImplementedError
|
|
21
|
+
|
|
22
|
+
@property
|
|
23
|
+
@abstractmethod
|
|
24
|
+
def changed(self) -> bool:
|
|
25
|
+
"""Have there been modifications since the last save."""
|
|
26
|
+
raise NotImplementedError
|