amulet-core 2.0.7a0__cp312-cp312-macosx_10_15_universal2.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.
- amulet/core/__init__.py +38 -0
- amulet/core/__init__.pyi +31 -0
- amulet/core/__pyinstaller/__init__.py +2 -0
- amulet/core/__pyinstaller/hook-amulet.core.py +4 -0
- amulet/core/_amulet_core.cpython-312-darwin.so +0 -0
- amulet/core/_amulet_core.pyi +7 -0
- amulet/core/_version.py +21 -0
- amulet/core/amulet_coreConfig.cmake +23 -0
- amulet/core/biome/__init__.pyi +75 -0
- amulet/core/biome/biome.hpp +53 -0
- amulet/core/block/__init__.pyi +273 -0
- amulet/core/block/block.hpp +156 -0
- amulet/core/block_entity/__init__.pyi +78 -0
- amulet/core/block_entity/block_entity.hpp +84 -0
- amulet/core/chunk/__init__.pyi +67 -0
- amulet/core/chunk/chunk.hpp +126 -0
- amulet/core/chunk/component/__init__.pyi +15 -0
- amulet/core/chunk/component/biome_3d_component.hpp +99 -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 +178 -0
- amulet/core/chunk/component/section_array_map.pyi +112 -0
- amulet/core/dll.hpp +21 -0
- amulet/core/entity/__init__.pyi +105 -0
- amulet/core/entity/entity.hpp +100 -0
- amulet/core/libamulet_core.dylib +0 -0
- amulet/core/palette/__init__.pyi +8 -0
- amulet/core/palette/biome_palette.hpp +65 -0
- amulet/core/palette/biome_palette.pyi +48 -0
- amulet/core/palette/block_palette.hpp +71 -0
- amulet/core/palette/block_palette.pyi +52 -0
- amulet/core/py.typed +0 -0
- amulet/core/selection/__init__.pyi +25 -0
- amulet/core/selection/box.hpp +97 -0
- amulet/core/selection/box.pyi +239 -0
- amulet/core/selection/box_group.hpp +89 -0
- amulet/core/selection/box_group.pyi +222 -0
- amulet/core/selection/cuboid.hpp +41 -0
- amulet/core/selection/cuboid.pyi +49 -0
- amulet/core/selection/ellipsoid.hpp +42 -0
- amulet/core/selection/ellipsoid.pyi +47 -0
- amulet/core/selection/shape.hpp +73 -0
- amulet/core/selection/shape.pyi +56 -0
- amulet/core/selection/shape_group.hpp +73 -0
- amulet/core/selection/shape_group.pyi +118 -0
- amulet/core/version/__init__.pyi +138 -0
- amulet/core/version/version.hpp +206 -0
- amulet_core-2.0.7a0.dist-info/METADATA +112 -0
- amulet_core-2.0.7a0.dist-info/RECORD +53 -0
- amulet_core-2.0.7a0.dist-info/WHEEL +5 -0
- amulet_core-2.0.7a0.dist-info/entry_points.txt +2 -0
- amulet_core-2.0.7a0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import types
|
|
4
|
+
import typing
|
|
5
|
+
|
|
6
|
+
import amulet.core.version
|
|
7
|
+
import amulet.nbt
|
|
8
|
+
|
|
9
|
+
__all__: list[str] = ["BlockEntity"]
|
|
10
|
+
|
|
11
|
+
class BlockEntity(amulet.core.version.PlatformVersionContainer):
|
|
12
|
+
"""
|
|
13
|
+
A class to contain all the data to define a BlockEntity.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
@typing.overload
|
|
17
|
+
def __eq__(self, other: BlockEntity) -> bool: ...
|
|
18
|
+
@typing.overload
|
|
19
|
+
def __eq__(self, other: typing.Any) -> bool | types.NotImplementedType: ...
|
|
20
|
+
def __hash__(self) -> int: ...
|
|
21
|
+
def __init__(
|
|
22
|
+
self,
|
|
23
|
+
platform: str,
|
|
24
|
+
version: amulet.core.version.VersionNumber,
|
|
25
|
+
namespace: str,
|
|
26
|
+
base_name: str,
|
|
27
|
+
nbt: amulet.nbt.NamedTag,
|
|
28
|
+
) -> None: ...
|
|
29
|
+
def __repr__(self) -> str: ...
|
|
30
|
+
@property
|
|
31
|
+
def base_name(self) -> str:
|
|
32
|
+
"""
|
|
33
|
+
The base name of the block entity represented by the :class:`BlockEntity` object.
|
|
34
|
+
|
|
35
|
+
>>> block_entity: BlockEntity
|
|
36
|
+
>>> block_entity.base_name
|
|
37
|
+
|
|
38
|
+
:return: The base name of the block entity
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
@base_name.setter
|
|
42
|
+
def base_name(self, arg1: str) -> None: ...
|
|
43
|
+
@property
|
|
44
|
+
def namespace(self) -> str:
|
|
45
|
+
"""
|
|
46
|
+
The namespace of the block entity represented by the :class:`BlockEntity` object.
|
|
47
|
+
|
|
48
|
+
>>> block_entity: BlockEntity
|
|
49
|
+
>>> block_entity.namespace
|
|
50
|
+
|
|
51
|
+
:return: The namespace of the block entity
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
@namespace.setter
|
|
55
|
+
def namespace(self, arg1: str) -> None: ...
|
|
56
|
+
@property
|
|
57
|
+
def namespaced_name(self) -> str:
|
|
58
|
+
"""
|
|
59
|
+
The namespace:base_name of the block entity represented by the :class:`BlockEntity` object.
|
|
60
|
+
|
|
61
|
+
>>> block_entity: BlockEntity
|
|
62
|
+
>>> block_entity.namespaced_name
|
|
63
|
+
|
|
64
|
+
:return: The namespace:base_name of the block entity
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
@property
|
|
68
|
+
def nbt(self) -> amulet.nbt.NamedTag:
|
|
69
|
+
"""
|
|
70
|
+
The nbt data for the block entity.
|
|
71
|
+
>>> block_entity: BlockEntity
|
|
72
|
+
>>> block_entity.nbt
|
|
73
|
+
|
|
74
|
+
:return: The NamedTag of the block entity
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
@nbt.setter
|
|
78
|
+
def nbt(self, arg1: amulet.nbt.NamedTag) -> None: ...
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <map>
|
|
4
|
+
#include <string>
|
|
5
|
+
#include <variant>
|
|
6
|
+
|
|
7
|
+
#include <amulet/io/binary_reader.hpp>
|
|
8
|
+
#include <amulet/io/binary_writer.hpp>
|
|
9
|
+
|
|
10
|
+
#include <amulet/nbt/tag/eq.hpp>
|
|
11
|
+
#include <amulet/nbt/tag/named_tag.hpp>
|
|
12
|
+
|
|
13
|
+
#include <amulet/core/dll.hpp>
|
|
14
|
+
#include <amulet/core/version/version.hpp>
|
|
15
|
+
|
|
16
|
+
namespace Amulet {
|
|
17
|
+
class BlockEntity : public PlatformVersionContainer {
|
|
18
|
+
private:
|
|
19
|
+
std::string _namespace;
|
|
20
|
+
std::string _base_name;
|
|
21
|
+
std::shared_ptr<Amulet::NBT::NamedTag> _nbt;
|
|
22
|
+
|
|
23
|
+
public:
|
|
24
|
+
const std::string& get_namespace() const
|
|
25
|
+
{
|
|
26
|
+
return _namespace;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
template <typename NamespaceT>
|
|
30
|
+
void set_namespace(NamespaceT&& namespace_)
|
|
31
|
+
{
|
|
32
|
+
_namespace = std::forward<NamespaceT>(namespace_);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const std::string& get_base_name() const
|
|
36
|
+
{
|
|
37
|
+
return _base_name;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
template <typename BaseNameT>
|
|
41
|
+
void set_base_name(BaseNameT&& base_name)
|
|
42
|
+
{
|
|
43
|
+
_base_name = std::forward<BaseNameT>(base_name);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
std::shared_ptr<Amulet::NBT::NamedTag> get_nbt() const
|
|
47
|
+
{
|
|
48
|
+
return _nbt;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
template <typename NBTT>
|
|
52
|
+
void set_nbt(NBTT&& nbt)
|
|
53
|
+
{
|
|
54
|
+
if constexpr (std::is_same_v<std::shared_ptr<Amulet::NBT::NamedTag>, std::decay_t<NBTT>>) {
|
|
55
|
+
_nbt = std::forward<NBTT>(nbt);
|
|
56
|
+
} else {
|
|
57
|
+
_nbt = std::make_shared<Amulet::NBT::NamedTag>(std::forward<NBTT>(nbt));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
template <
|
|
62
|
+
typename PlatformT,
|
|
63
|
+
typename VersionNumberT,
|
|
64
|
+
typename NamespaceT,
|
|
65
|
+
typename BaseNameT>
|
|
66
|
+
BlockEntity(
|
|
67
|
+
PlatformT&& platform,
|
|
68
|
+
VersionNumberT&& version,
|
|
69
|
+
NamespaceT&& namespace_,
|
|
70
|
+
BaseNameT&& base_name,
|
|
71
|
+
std::shared_ptr<Amulet::NBT::NamedTag> nbt)
|
|
72
|
+
: PlatformVersionContainer(std::forward<PlatformT>(platform), std::forward<VersionNumberT>(version))
|
|
73
|
+
, _namespace(std::forward<NamespaceT>(namespace_))
|
|
74
|
+
, _base_name(std::forward<BaseNameT>(base_name))
|
|
75
|
+
, _nbt(std::move(nbt))
|
|
76
|
+
{
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
AMULET_CORE_EXPORT void serialise(BinaryWriter&) const;
|
|
80
|
+
AMULET_CORE_EXPORT static BlockEntity deserialise(BinaryReader&);
|
|
81
|
+
|
|
82
|
+
AMULET_CORE_EXPORT bool operator==(const BlockEntity& other) const;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from . import component
|
|
4
|
+
|
|
5
|
+
__all__: list[str] = [
|
|
6
|
+
"Chunk",
|
|
7
|
+
"ChunkDoesNotExist",
|
|
8
|
+
"ChunkLoadError",
|
|
9
|
+
"component",
|
|
10
|
+
"get_null_chunk",
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
class Chunk:
|
|
14
|
+
"""
|
|
15
|
+
A base class for all chunk classes.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def reconstruct_chunk(self, arg0: dict[str, bytes | None]) -> None:
|
|
19
|
+
"""
|
|
20
|
+
This is private. Do not use this. It will be removed in the future.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
def serialise_chunk(self) -> dict[str, bytes | None]:
|
|
24
|
+
"""
|
|
25
|
+
This is private. Do not use this. It will be removed in the future.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
@property
|
|
29
|
+
def chunk_id(self) -> str: ...
|
|
30
|
+
@property
|
|
31
|
+
def component_ids(self) -> set[str]: ...
|
|
32
|
+
|
|
33
|
+
class ChunkDoesNotExist(ChunkLoadError):
|
|
34
|
+
"""
|
|
35
|
+
An error thrown if a chunk does not exist and therefor cannot be loaded.
|
|
36
|
+
|
|
37
|
+
>>> try:
|
|
38
|
+
>>> # get chunk
|
|
39
|
+
>>> chunk = world.get_chunk(cx, cz, dimension)
|
|
40
|
+
>>> except ChunkDoesNotExist:
|
|
41
|
+
>>> # will catch all chunks that do not exist
|
|
42
|
+
>>> # will not catch corrupt chunks
|
|
43
|
+
>>> except ChunkLoadError:
|
|
44
|
+
>>> # will only catch chunks that errored during loading
|
|
45
|
+
>>> # chunks that do not exist were caught by the previous except section.
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
class ChunkLoadError(RuntimeError):
|
|
49
|
+
"""
|
|
50
|
+
An error thrown if a chunk failed to load for some reason.
|
|
51
|
+
|
|
52
|
+
This may be due to a corrupt chunk, an unsupported chunk format or just because the chunk does not exist to be loaded.
|
|
53
|
+
|
|
54
|
+
Catching this error will also catch :class:`ChunkDoesNotExist`
|
|
55
|
+
|
|
56
|
+
>>> try:
|
|
57
|
+
>>> # get chunk
|
|
58
|
+
>>> chunk = world.get_chunk(cx, cz, dimension)
|
|
59
|
+
>>> except ChunkLoadError:
|
|
60
|
+
>>> # will catch all chunks that have failed to load
|
|
61
|
+
>>> # either because they do not exist or errored during loading.
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
def get_null_chunk(arg0: str) -> Chunk:
|
|
65
|
+
"""
|
|
66
|
+
This is a private function
|
|
67
|
+
"""
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <functional>
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <optional>
|
|
6
|
+
#include <set>
|
|
7
|
+
#include <stdexcept>
|
|
8
|
+
#include <string>
|
|
9
|
+
#include <unordered_map>
|
|
10
|
+
|
|
11
|
+
#include <amulet/core/dll.hpp>
|
|
12
|
+
|
|
13
|
+
// Requirements:
|
|
14
|
+
// Split chunk data into components that are orthogonal to each other.
|
|
15
|
+
// create a chunk with all components default initialised.
|
|
16
|
+
// reconstruct a chunk from a subset of its components.
|
|
17
|
+
// reconstruct a chunk with all components.
|
|
18
|
+
// query if a chunk has a component. (isinstance/is_base_of/dynamic_cast or has_component)
|
|
19
|
+
// get a component. (method/property or get_component)
|
|
20
|
+
// set and validate a component. (method/property or set_component)
|
|
21
|
+
// serialise loaded components.
|
|
22
|
+
|
|
23
|
+
namespace Amulet {
|
|
24
|
+
typedef std::unordered_map<std::string, std::optional<std::string>> SerialisedChunkComponents;
|
|
25
|
+
|
|
26
|
+
// The abstract chunk class
|
|
27
|
+
class Chunk {
|
|
28
|
+
public:
|
|
29
|
+
virtual ~Chunk() = default;
|
|
30
|
+
virtual std::string get_chunk_id() const = 0;
|
|
31
|
+
virtual std::set<std::string> get_component_ids() const = 0;
|
|
32
|
+
// private:
|
|
33
|
+
// These are public but may become private one day
|
|
34
|
+
virtual SerialisedChunkComponents serialise_chunk() const = 0;
|
|
35
|
+
virtual void reconstruct_chunk(SerialisedChunkComponents) = 0;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
namespace detail {
|
|
39
|
+
using ChunkContructor = std::function<std::shared_ptr<Chunk>()>;
|
|
40
|
+
AMULET_CORE_EXPORT void add_null_chunk_constructor(const std::string& id, ChunkContructor constructor);
|
|
41
|
+
AMULET_CORE_EXPORT void remove_null_chunk_constructor(const std::string& id);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
AMULET_CORE_EXPORT std::shared_ptr<Chunk> get_null_chunk(std::string chunk_id);
|
|
45
|
+
|
|
46
|
+
// An object that concrete chunk classes must be registered with.
|
|
47
|
+
// This enables reconstructing the chunk class.
|
|
48
|
+
template <typename ChunkT>
|
|
49
|
+
class ChunkNullConstructor {
|
|
50
|
+
public:
|
|
51
|
+
ChunkNullConstructor()
|
|
52
|
+
{
|
|
53
|
+
detail::add_null_chunk_constructor(ChunkT::ChunkID, []() {
|
|
54
|
+
return std::make_shared<ChunkT>();
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
~ChunkNullConstructor()
|
|
58
|
+
{
|
|
59
|
+
detail::remove_null_chunk_constructor(ChunkT::ChunkID);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// A utility class to simplify component serialisation and deserialisation.
|
|
64
|
+
template <class ChunkBaseClass, class... Components>
|
|
65
|
+
class ChunkComponentHelper : public ChunkBaseClass, public Components... {
|
|
66
|
+
public:
|
|
67
|
+
// Component list
|
|
68
|
+
std::set<std::string> get_component_ids() const override
|
|
69
|
+
{
|
|
70
|
+
std::set<std::string> component_ids;
|
|
71
|
+
(
|
|
72
|
+
[&] {
|
|
73
|
+
component_ids.emplace(Components::ComponentID);
|
|
74
|
+
}(),
|
|
75
|
+
...);
|
|
76
|
+
return component_ids;
|
|
77
|
+
}
|
|
78
|
+
// These are public but may become private one day
|
|
79
|
+
// Null constructor
|
|
80
|
+
ChunkComponentHelper()
|
|
81
|
+
: Components()...
|
|
82
|
+
{
|
|
83
|
+
}
|
|
84
|
+
// private:
|
|
85
|
+
// Serialiser
|
|
86
|
+
SerialisedChunkComponents serialise_chunk() const override
|
|
87
|
+
{
|
|
88
|
+
SerialisedChunkComponents component_data;
|
|
89
|
+
(
|
|
90
|
+
[&] {
|
|
91
|
+
component_data[Components::ComponentID] = Components::serialise();
|
|
92
|
+
}(),
|
|
93
|
+
...);
|
|
94
|
+
return component_data;
|
|
95
|
+
}
|
|
96
|
+
// Deserialiser
|
|
97
|
+
void reconstruct_chunk(SerialisedChunkComponents component_data) override
|
|
98
|
+
{
|
|
99
|
+
(
|
|
100
|
+
[&] {
|
|
101
|
+
auto node = component_data.extract(Components::ComponentID);
|
|
102
|
+
Components::deserialise(node ? node.mapped() : std::nullopt);
|
|
103
|
+
}(),
|
|
104
|
+
...);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
class AMULET_CORE_EXPORT_EXCEPTION ChunkLoadError : public std::runtime_error {
|
|
109
|
+
public:
|
|
110
|
+
using std::runtime_error::runtime_error;
|
|
111
|
+
ChunkLoadError()
|
|
112
|
+
: ChunkLoadError("ChunkLoadError")
|
|
113
|
+
{
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
class AMULET_CORE_EXPORT_EXCEPTION ChunkDoesNotExist : public ChunkLoadError {
|
|
118
|
+
public:
|
|
119
|
+
using ChunkLoadError::ChunkLoadError;
|
|
120
|
+
ChunkDoesNotExist()
|
|
121
|
+
: ChunkDoesNotExist("ChunkDoesNotExist")
|
|
122
|
+
{
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
} // namespace Amulet
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from amulet.core.chunk.component.block_component import BlockComponent, BlockStorage
|
|
4
|
+
from amulet.core.chunk.component.section_array_map import IndexArray3D, SectionArrayMap
|
|
5
|
+
|
|
6
|
+
from . import block_component, section_array_map
|
|
7
|
+
|
|
8
|
+
__all__: list[str] = [
|
|
9
|
+
"BlockComponent",
|
|
10
|
+
"BlockStorage",
|
|
11
|
+
"IndexArray3D",
|
|
12
|
+
"SectionArrayMap",
|
|
13
|
+
"block_component",
|
|
14
|
+
"section_array_map",
|
|
15
|
+
]
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <cstdint>
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <optional>
|
|
6
|
+
#include <tuple>
|
|
7
|
+
|
|
8
|
+
#include <amulet/core/biome/biome.hpp>
|
|
9
|
+
#include <amulet/core/dll.hpp>
|
|
10
|
+
#include <amulet/core/palette/biome_palette.hpp>
|
|
11
|
+
#include <amulet/core/version/version.hpp>
|
|
12
|
+
|
|
13
|
+
#include "section_array_map.hpp"
|
|
14
|
+
|
|
15
|
+
namespace Amulet {
|
|
16
|
+
|
|
17
|
+
class Biome3DStorage {
|
|
18
|
+
private:
|
|
19
|
+
std::shared_ptr<BiomePalette> _palette;
|
|
20
|
+
std::shared_ptr<SectionArrayMap> _sections;
|
|
21
|
+
|
|
22
|
+
public:
|
|
23
|
+
template <typename PaletteT, typename SectionsT>
|
|
24
|
+
Biome3DStorage(
|
|
25
|
+
PaletteT&& palette,
|
|
26
|
+
SectionsT&& sections)
|
|
27
|
+
: _palette(
|
|
28
|
+
[&palette] {
|
|
29
|
+
if constexpr (std::is_same_v<std::shared_ptr<BiomePalette>, std::decay_t<PaletteT>>) {
|
|
30
|
+
return std::forward<PaletteT>(palette);
|
|
31
|
+
} else {
|
|
32
|
+
return std::make_shared<BiomePalette>(palette);
|
|
33
|
+
}
|
|
34
|
+
}())
|
|
35
|
+
, _sections(
|
|
36
|
+
[§ions] {
|
|
37
|
+
if constexpr (std::is_same_v<std::shared_ptr<SectionArrayMap>, std::decay_t<SectionsT>>) {
|
|
38
|
+
return std::forward<SectionsT>(sections);
|
|
39
|
+
} else {
|
|
40
|
+
return std::make_shared<SectionArrayMap>(sections);
|
|
41
|
+
}
|
|
42
|
+
}())
|
|
43
|
+
{
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
template <typename VersionRangeT>
|
|
47
|
+
Biome3DStorage(
|
|
48
|
+
VersionRangeT&& version_range,
|
|
49
|
+
const SectionShape& array_shape,
|
|
50
|
+
const Biome& default_biome)
|
|
51
|
+
: Biome3DStorage(
|
|
52
|
+
std::make_shared<BiomePalette>(std::forward<VersionRangeT>(version_range)),
|
|
53
|
+
std::make_shared<SectionArrayMap>(array_shape, static_cast<std::uint32_t>(0)))
|
|
54
|
+
{
|
|
55
|
+
_palette->biome_to_index(default_biome);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
BiomePalette& get_palette() { return *_palette; }
|
|
59
|
+
std::shared_ptr<BiomePalette> get_palette_ptr() { return _palette; }
|
|
60
|
+
SectionArrayMap& get_sections() { return *_sections; }
|
|
61
|
+
std::shared_ptr<SectionArrayMap> get_sections_ptr() { return _sections; }
|
|
62
|
+
|
|
63
|
+
AMULET_CORE_EXPORT void serialise(BinaryWriter&) const;
|
|
64
|
+
AMULET_CORE_EXPORT static Biome3DStorage deserialise(BinaryReader&);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
class Biome3DComponent {
|
|
68
|
+
private:
|
|
69
|
+
std::optional<std::shared_ptr<Biome3DStorage>> _value;
|
|
70
|
+
|
|
71
|
+
protected:
|
|
72
|
+
// Null constructor
|
|
73
|
+
Biome3DComponent() = default;
|
|
74
|
+
|
|
75
|
+
// Default constructor
|
|
76
|
+
template <typename VersionRangeT>
|
|
77
|
+
void init(
|
|
78
|
+
VersionRangeT&& version_range,
|
|
79
|
+
const SectionShape& array_shape,
|
|
80
|
+
const Biome& default_biome)
|
|
81
|
+
{
|
|
82
|
+
_value = std::make_shared<Biome3DStorage>(
|
|
83
|
+
std::forward<VersionRangeT>(version_range),
|
|
84
|
+
array_shape,
|
|
85
|
+
default_biome);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Serialise the component data
|
|
89
|
+
AMULET_CORE_EXPORT std::optional<std::string> serialise() const;
|
|
90
|
+
// Deserialise the component
|
|
91
|
+
AMULET_CORE_EXPORT void deserialise(std::optional<std::string>);
|
|
92
|
+
|
|
93
|
+
public:
|
|
94
|
+
AMULET_CORE_EXPORT static const std::string ComponentID;
|
|
95
|
+
AMULET_CORE_EXPORT std::shared_ptr<Biome3DStorage> get_biome_storage();
|
|
96
|
+
AMULET_CORE_EXPORT void set_biome_storage(std::shared_ptr<Biome3DStorage> component);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
} // namespace Amulet
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <optional>
|
|
5
|
+
#include <tuple>
|
|
6
|
+
|
|
7
|
+
#include <amulet/io/binary_reader.hpp>
|
|
8
|
+
#include <amulet/io/binary_writer.hpp>
|
|
9
|
+
|
|
10
|
+
#include <amulet/core/block/block.hpp>
|
|
11
|
+
#include <amulet/core/dll.hpp>
|
|
12
|
+
#include <amulet/core/palette/block_palette.hpp>
|
|
13
|
+
#include <amulet/core/version/version.hpp>
|
|
14
|
+
|
|
15
|
+
#include "section_array_map.hpp"
|
|
16
|
+
|
|
17
|
+
namespace Amulet {
|
|
18
|
+
|
|
19
|
+
class BlockStorage {
|
|
20
|
+
private:
|
|
21
|
+
std::shared_ptr<BlockPalette> _palette;
|
|
22
|
+
std::shared_ptr<SectionArrayMap> _sections;
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
template <typename PaletteT, typename SectionsT>
|
|
26
|
+
BlockStorage(
|
|
27
|
+
PaletteT&& palette,
|
|
28
|
+
SectionsT&& sections)
|
|
29
|
+
: _palette(
|
|
30
|
+
[&palette] {
|
|
31
|
+
if constexpr (std::is_same_v<std::shared_ptr<BlockPalette>, std::decay_t<PaletteT>>) {
|
|
32
|
+
return std::forward<PaletteT>(palette);
|
|
33
|
+
} else {
|
|
34
|
+
return std::make_shared<BlockPalette>(palette);
|
|
35
|
+
}
|
|
36
|
+
}())
|
|
37
|
+
, _sections(
|
|
38
|
+
[§ions] {
|
|
39
|
+
if constexpr (std::is_same_v<std::shared_ptr<SectionArrayMap>, std::decay_t<SectionsT>>) {
|
|
40
|
+
return std::forward<SectionsT>(sections);
|
|
41
|
+
} else {
|
|
42
|
+
return std::make_shared<SectionArrayMap>(sections);
|
|
43
|
+
}
|
|
44
|
+
}())
|
|
45
|
+
{
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
template <typename VersionRangeT>
|
|
49
|
+
BlockStorage(
|
|
50
|
+
VersionRangeT&& version_range,
|
|
51
|
+
const SectionShape& array_shape,
|
|
52
|
+
const BlockStack& default_block)
|
|
53
|
+
: BlockStorage(
|
|
54
|
+
std::make_shared<BlockPalette>(std::forward<VersionRangeT>(version_range)),
|
|
55
|
+
std::make_shared<SectionArrayMap>(array_shape, static_cast<std::uint32_t>(0)))
|
|
56
|
+
{
|
|
57
|
+
_palette->block_stack_to_index(default_block);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
AMULET_CORE_EXPORT void serialise(BinaryWriter&) const;
|
|
61
|
+
AMULET_CORE_EXPORT static BlockStorage deserialise(BinaryReader&);
|
|
62
|
+
|
|
63
|
+
BlockPalette& get_palette() const { return *_palette; }
|
|
64
|
+
std::shared_ptr<BlockPalette> get_palette_ptr() const { return _palette; }
|
|
65
|
+
SectionArrayMap& get_sections() const { return *_sections; }
|
|
66
|
+
std::shared_ptr<SectionArrayMap> get_sections_ptr() const { return _sections; }
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
class BlockComponent {
|
|
70
|
+
private:
|
|
71
|
+
std::optional<std::shared_ptr<BlockStorage>> _value;
|
|
72
|
+
|
|
73
|
+
protected:
|
|
74
|
+
// Null constructor
|
|
75
|
+
BlockComponent() = default;
|
|
76
|
+
|
|
77
|
+
// Default constructor
|
|
78
|
+
template <typename VersionRangeT>
|
|
79
|
+
void init(
|
|
80
|
+
VersionRangeT&& version_range,
|
|
81
|
+
const SectionShape& array_shape,
|
|
82
|
+
const BlockStack& default_block)
|
|
83
|
+
{
|
|
84
|
+
_value = std::make_shared<BlockStorage>(
|
|
85
|
+
std::forward<VersionRangeT>(version_range),
|
|
86
|
+
array_shape,
|
|
87
|
+
default_block);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Serialise the component data
|
|
91
|
+
AMULET_CORE_EXPORT std::optional<std::string> serialise() const;
|
|
92
|
+
// Deserialise the component
|
|
93
|
+
AMULET_CORE_EXPORT void deserialise(std::optional<std::string>);
|
|
94
|
+
|
|
95
|
+
public:
|
|
96
|
+
AMULET_CORE_EXPORT static const std::string ComponentID;
|
|
97
|
+
AMULET_CORE_EXPORT std::shared_ptr<BlockStorage> get_block_storage();
|
|
98
|
+
AMULET_CORE_EXPORT void set_block_storage(std::shared_ptr<BlockStorage> component);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
} // namespace Amulet
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import amulet.core.block
|
|
6
|
+
import amulet.core.chunk.component.section_array_map
|
|
7
|
+
import amulet.core.palette.block_palette
|
|
8
|
+
import amulet.core.version
|
|
9
|
+
|
|
10
|
+
__all__: list[str] = ["BlockComponent", "BlockStorage"]
|
|
11
|
+
|
|
12
|
+
class BlockComponent:
|
|
13
|
+
ComponentID: typing.ClassVar[str] = "Amulet::BlockComponent"
|
|
14
|
+
block_storage: BlockStorage
|
|
15
|
+
|
|
16
|
+
class BlockStorage:
|
|
17
|
+
def __init__(
|
|
18
|
+
self,
|
|
19
|
+
version_range: amulet.core.version.VersionRange,
|
|
20
|
+
array_shape: tuple[typing.SupportsInt, typing.SupportsInt, typing.SupportsInt],
|
|
21
|
+
default_block: amulet.core.block.BlockStack,
|
|
22
|
+
) -> None: ...
|
|
23
|
+
@property
|
|
24
|
+
def palette(self) -> amulet.core.palette.block_palette.BlockPalette: ...
|
|
25
|
+
@property
|
|
26
|
+
def sections(
|
|
27
|
+
self,
|
|
28
|
+
) -> amulet.core.chunk.component.section_array_map.SectionArrayMap: ...
|