amulet-core 2.0a8__cp311-cp311-win_amd64.whl → 2.0.1a2.post250529084738__cp311-cp311-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of amulet-core might be problematic. Click here for more details.
- amulet/core/__init__.py +36 -0
- amulet/core/__pyinstaller/hook-amulet.core.py +4 -0
- amulet/core/_amulet_core.cp311-win_amd64.pyd +0 -0
- amulet/core/_amulet_core.pyi +7 -0
- amulet/{_version.py → core/_version.py} +3 -3
- amulet/core/amulet_core.dll +0 -0
- amulet/core/amulet_core.lib +0 -0
- amulet/core/amulet_coreConfig.cmake +18 -0
- amulet/{biome.pyi → core/biome/__init__.pyi} +3 -3
- amulet/core/biome/biome.hpp +53 -0
- amulet/{block.pyi → core/block/__init__.pyi} +25 -26
- amulet/core/block/block.hpp +156 -0
- amulet/{block_entity.pyi → core/block_entity/__init__.pyi} +7 -7
- amulet/core/block_entity/block_entity.hpp +84 -0
- amulet/{errors.py → core/chunk/__init__.pyi} +37 -33
- amulet/core/chunk/chunk.hpp +126 -0
- amulet/core/chunk/component/__init__.pyi +18 -0
- amulet/core/chunk/component/biome_3d_component.hpp +96 -0
- amulet/core/chunk/component/block_component.hpp +101 -0
- amulet/core/chunk/component/block_component.pyi +28 -0
- amulet/core/chunk/component/block_entity_component.hpp +119 -0
- amulet/core/chunk/component/section_array_map.hpp +129 -0
- amulet/{chunk_components.pyi → core/chunk/component/section_array_map.pyi} +4 -24
- amulet/core/dll.hpp +21 -0
- amulet/core/entity/__init__.pyi +105 -0
- amulet/core/entity/entity.hpp +100 -0
- amulet/{palette → core/palette}/__init__.pyi +2 -2
- amulet/core/palette/biome_palette.hpp +65 -0
- amulet/{palette → core/palette}/biome_palette.pyi +8 -8
- amulet/core/palette/block_palette.hpp +71 -0
- amulet/{palette → core/palette}/block_palette.pyi +12 -10
- amulet/core/selection/__init__.pyi +8 -0
- amulet/core/selection/box.hpp +86 -0
- amulet/core/selection/box.pyi +215 -0
- amulet/core/selection/group.hpp +80 -0
- amulet/core/selection/group.pyi +213 -0
- amulet/{version.pyi → core/version/__init__.pyi} +58 -10
- amulet/core/version/version.hpp +204 -0
- {amulet_core-2.0a8.dist-info → amulet_core-2.0.1a2.post250529084738.dist-info}/METADATA +25 -20
- amulet_core-2.0.1a2.post250529084738.dist-info/RECORD +45 -0
- {amulet_core-2.0a8.dist-info → amulet_core-2.0.1a2.post250529084738.dist-info}/WHEEL +1 -1
- amulet_core-2.0.1a2.post250529084738.dist-info/entry_points.txt +2 -0
- amulet/__init__.cp311-win_amd64.pyd +0 -0
- amulet/__init__.py.cpp +0 -45
- amulet/__init__.pyi +0 -30
- amulet/__pyinstaller/hook-amulet.py +0 -4
- amulet/_init.py +0 -26
- amulet/biome.cpp +0 -36
- amulet/biome.hpp +0 -43
- amulet/biome.py.cpp +0 -122
- amulet/block.cpp +0 -435
- amulet/block.hpp +0 -119
- amulet/block.py.cpp +0 -377
- amulet/block_entity.cpp +0 -12
- amulet/block_entity.hpp +0 -56
- amulet/block_entity.py.cpp +0 -115
- amulet/chunk.cpp +0 -16
- amulet/chunk.hpp +0 -100
- amulet/chunk.py.cpp +0 -80
- amulet/chunk.pyi +0 -28
- amulet/chunk_components/biome_3d_component.cpp +0 -5
- amulet/chunk_components/biome_3d_component.hpp +0 -79
- amulet/chunk_components/block_component.cpp +0 -41
- amulet/chunk_components/block_component.hpp +0 -88
- amulet/chunk_components/block_entity_component.cpp +0 -5
- amulet/chunk_components/block_entity_component.hpp +0 -147
- amulet/chunk_components/section_array_map.cpp +0 -129
- amulet/chunk_components/section_array_map.hpp +0 -147
- amulet/collections/eq.py.hpp +0 -37
- amulet/collections/hash.py.hpp +0 -27
- amulet/collections/holder.py.hpp +0 -37
- amulet/collections/iterator.py.hpp +0 -80
- amulet/collections/mapping.py.hpp +0 -199
- amulet/collections/mutable_mapping.py.hpp +0 -226
- amulet/collections/sequence.py.hpp +0 -163
- amulet/collections.pyi +0 -40
- amulet/data_types.py +0 -29
- amulet/entity.py +0 -182
- amulet/game/__init__.py +0 -7
- amulet/game/_game.py +0 -152
- amulet/game/_universal/__init__.py +0 -1
- amulet/game/_universal/_biome.py +0 -17
- amulet/game/_universal/_block.py +0 -47
- amulet/game/_universal/_version.py +0 -68
- amulet/game/abc/__init__.py +0 -22
- amulet/game/abc/_block_specification.py +0 -150
- amulet/game/abc/biome.py +0 -213
- amulet/game/abc/block.py +0 -331
- amulet/game/abc/game_version_container.py +0 -25
- amulet/game/abc/json_interface.py +0 -27
- amulet/game/abc/version.py +0 -44
- amulet/game/bedrock/__init__.py +0 -1
- amulet/game/bedrock/_biome.py +0 -35
- amulet/game/bedrock/_block.py +0 -42
- amulet/game/bedrock/_version.py +0 -165
- amulet/game/java/__init__.py +0 -2
- amulet/game/java/_biome.py +0 -35
- amulet/game/java/_block.py +0 -60
- amulet/game/java/_version.py +0 -176
- amulet/game/translate/__init__.py +0 -12
- amulet/game/translate/_functions/__init__.py +0 -15
- amulet/game/translate/_functions/_code_functions/__init__.py +0 -0
- amulet/game/translate/_functions/_code_functions/_text.py +0 -553
- amulet/game/translate/_functions/_code_functions/banner_pattern.py +0 -67
- amulet/game/translate/_functions/_code_functions/bedrock_chest_connection.py +0 -152
- amulet/game/translate/_functions/_code_functions/bedrock_moving_block_pos.py +0 -88
- amulet/game/translate/_functions/_code_functions/bedrock_sign.py +0 -152
- amulet/game/translate/_functions/_code_functions/bedrock_skull_rotation.py +0 -16
- amulet/game/translate/_functions/_code_functions/custom_name.py +0 -146
- amulet/game/translate/_functions/_frozen.py +0 -66
- amulet/game/translate/_functions/_state.py +0 -54
- amulet/game/translate/_functions/_typing.py +0 -98
- amulet/game/translate/_functions/abc.py +0 -123
- amulet/game/translate/_functions/carry_nbt.py +0 -160
- amulet/game/translate/_functions/carry_properties.py +0 -80
- amulet/game/translate/_functions/code.py +0 -143
- amulet/game/translate/_functions/map_block_name.py +0 -66
- amulet/game/translate/_functions/map_nbt.py +0 -111
- amulet/game/translate/_functions/map_properties.py +0 -93
- amulet/game/translate/_functions/multiblock.py +0 -112
- amulet/game/translate/_functions/new_block.py +0 -42
- amulet/game/translate/_functions/new_entity.py +0 -43
- amulet/game/translate/_functions/new_nbt.py +0 -206
- amulet/game/translate/_functions/new_properties.py +0 -64
- amulet/game/translate/_functions/sequence.py +0 -51
- amulet/game/translate/_functions/walk_input_nbt.py +0 -331
- amulet/game/translate/_translator.py +0 -433
- amulet/img/__init__.py +0 -10
- amulet/img/missing_no.png +0 -0
- amulet/img/missing_pack.png +0 -0
- amulet/img/missing_world.png +0 -0
- amulet/io/binary_reader.hpp +0 -45
- amulet/io/binary_writer.hpp +0 -30
- amulet/item.py +0 -75
- amulet/level/__init__.pyi +0 -23
- amulet/level/_load.py +0 -100
- amulet/level/abc/__init__.py +0 -12
- amulet/level/abc/_chunk_handle.py +0 -358
- amulet/level/abc/_dimension.py +0 -86
- amulet/level/abc/_history/__init__.py +0 -1
- amulet/level/abc/_history/_cache.py +0 -224
- amulet/level/abc/_history/_history_manager.py +0 -291
- amulet/level/abc/_level/__init__.py +0 -5
- amulet/level/abc/_level/_compactable_level.py +0 -10
- amulet/level/abc/_level/_creatable_level.py +0 -28
- amulet/level/abc/_level/_disk_level.py +0 -17
- amulet/level/abc/_level/_level.py +0 -449
- amulet/level/abc/_level/_loadable_level.py +0 -42
- amulet/level/abc/_player_storage.py +0 -7
- amulet/level/abc/_raw_level.py +0 -187
- amulet/level/abc/_registry.py +0 -40
- amulet/level/java/__init__.pyi +0 -16
- amulet/level/java/_chunk_handle.py +0 -17
- amulet/level/java/_dimension.py +0 -20
- amulet/level/java/_level.py +0 -184
- amulet/level/java/_raw/__init__.pyi +0 -15
- amulet/level/java/_raw/_chunk.pyi +0 -23
- amulet/level/java/_raw/_constant.py +0 -9
- amulet/level/java/_raw/_data_pack/__init__.py +0 -2
- amulet/level/java/_raw/_data_pack/data_pack.py +0 -241
- amulet/level/java/_raw/_data_pack/data_pack_manager.py +0 -77
- amulet/level/java/_raw/_dimension.py +0 -86
- amulet/level/java/_raw/_level.py +0 -507
- amulet/level/java/_raw/_typing.py +0 -3
- amulet/level/java/_raw/java_chunk_decode.cpp +0 -531
- amulet/level/java/_raw/java_chunk_decode.hpp +0 -23
- amulet/level/java/_raw/java_chunk_encode.cpp +0 -25
- amulet/level/java/_raw/java_chunk_encode.hpp +0 -23
- amulet/level/java/anvil/__init__.py +0 -2
- amulet/level/java/anvil/_dimension.py +0 -170
- amulet/level/java/anvil/_region.py +0 -421
- amulet/level/java/anvil/_sector_manager.py +0 -223
- amulet/level/java/chunk.pyi +0 -81
- amulet/level/java/chunk_/_chunk.py +0 -260
- amulet/level/java/chunk_/components/inhabited_time.py +0 -12
- amulet/level/java/chunk_/components/last_update.py +0 -12
- amulet/level/java/chunk_/components/legacy_version.py +0 -12
- amulet/level/java/chunk_/components/light_populated.py +0 -12
- amulet/level/java/chunk_/components/named_height_2d.py +0 -37
- amulet/level/java/chunk_/components/status.py +0 -11
- amulet/level/java/chunk_/components/terrain_populated.py +0 -12
- amulet/level/java/chunk_components/data_version_component.cpp +0 -32
- amulet/level/java/chunk_components/data_version_component.hpp +0 -31
- amulet/level/java/chunk_components/java_raw_chunk_component.cpp +0 -56
- amulet/level/java/chunk_components/java_raw_chunk_component.hpp +0 -45
- amulet/level/java/chunk_components.pyi +0 -22
- amulet/level/java/java_chunk.cpp +0 -170
- amulet/level/java/java_chunk.hpp +0 -141
- amulet/level/java/long_array.hpp +0 -175
- amulet/level/java/long_array.pyi +0 -39
- amulet/level/temporary_level/__init__.py +0 -1
- amulet/level/temporary_level/_level.py +0 -16
- amulet/mesh/__init__.py +0 -0
- amulet/mesh/block/__init__.pyi +0 -301
- amulet/mesh/block/_cube.py +0 -198
- amulet/mesh/block/_missing_block.py +0 -20
- amulet/mesh/block/block_mesh.cpp +0 -107
- amulet/mesh/block/block_mesh.hpp +0 -207
- amulet/mesh/util.py +0 -17
- amulet/palette/biome_palette.hpp +0 -85
- amulet/palette/block_palette.cpp +0 -32
- amulet/palette/block_palette.hpp +0 -93
- amulet/player.py +0 -62
- amulet/pybind11/collections.hpp +0 -118
- amulet/pybind11/numpy.hpp +0 -26
- amulet/pybind11/py_module.hpp +0 -34
- amulet/pybind11/type_hints.hpp +0 -51
- amulet/pybind11/types.hpp +0 -25
- amulet/pybind11/typing.hpp +0 -7
- amulet/resource_pack/__init__.py +0 -63
- amulet/resource_pack/abc/__init__.py +0 -2
- amulet/resource_pack/abc/resource_pack.py +0 -38
- amulet/resource_pack/abc/resource_pack_manager.py +0 -85
- amulet/resource_pack/java/__init__.py +0 -2
- amulet/resource_pack/java/download_resources.py +0 -212
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_black.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_blue.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_brown.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_cyan.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_gray.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_green.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_light_blue.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_light_gray.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_lime.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_magenta.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_orange.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_pink.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_purple.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_red.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_white.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/banner/banner_yellow.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/barrier.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/end_portal.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/grass.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/lava.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/structure_void.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/assets/minecraft/textures/block/water.png +0 -0
- amulet/resource_pack/java/java_vanilla_fix/pack.png +0 -0
- amulet/resource_pack/java/resource_pack.py +0 -44
- amulet/resource_pack/java/resource_pack_manager.py +0 -563
- amulet/resource_pack/unknown_resource_pack.py +0 -10
- amulet/selection/__init__.py +0 -2
- amulet/selection/abstract_selection.py +0 -342
- amulet/selection/box.py +0 -852
- amulet/selection/group.py +0 -481
- amulet/utils/__init__.pyi +0 -23
- amulet/utils/call_spec/__init__.py +0 -24
- amulet/utils/call_spec/_call_spec.py +0 -257
- amulet/utils/cast.py +0 -10
- amulet/utils/comment_json.py +0 -188
- amulet/utils/format_utils.py +0 -41
- amulet/utils/generator.py +0 -18
- amulet/utils/matrix.py +0 -243
- amulet/utils/numpy.hpp +0 -36
- amulet/utils/numpy.pyi +0 -11
- amulet/utils/numpy_helpers.py +0 -19
- amulet/utils/shareable_lock.py +0 -335
- amulet/utils/signal/__init__.py +0 -10
- amulet/utils/signal/_signal.py +0 -228
- amulet/utils/task_manager.py +0 -235
- amulet/utils/typed_property.py +0 -111
- amulet/utils/weakref.py +0 -70
- amulet/utils/world_utils.py +0 -102
- amulet/version.cpp +0 -136
- amulet/version.hpp +0 -142
- amulet/version.py.cpp +0 -281
- amulet_core-2.0a8.dist-info/RECORD +0 -241
- amulet_core-2.0a8.dist-info/entry_points.txt +0 -2
- /amulet/{__pyinstaller → core/__pyinstaller}/__init__.py +0 -0
- /amulet/{py.typed → core/py.typed} +0 -0
- {amulet_core-2.0a8.dist-info → amulet_core-2.0.1a2.post250529084738.dist-info}/top_level.txt +0 -0
amulet/chunk.py.cpp
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
#include <amulet/chunk.hpp>
|
|
2
|
-
|
|
3
|
-
#include <pybind11/pybind11.h>
|
|
4
|
-
#include <pybind11/stl.h>
|
|
5
|
-
#include <pybind11/operators.h>
|
|
6
|
-
#include <pybind11/typing.h>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
namespace py = pybind11;
|
|
10
|
-
|
|
11
|
-
void init_chunk(py::module m_parent) {
|
|
12
|
-
auto m = m_parent.def_submodule("chunk");
|
|
13
|
-
py::class_<Amulet::Chunk, std::shared_ptr<Amulet::Chunk>> Chunk(m, "Chunk",
|
|
14
|
-
"A base class for all chunk classes."
|
|
15
|
-
);
|
|
16
|
-
Chunk.def_property_readonly(
|
|
17
|
-
"chunk_id",
|
|
18
|
-
&Amulet::Chunk::get_chunk_id
|
|
19
|
-
);
|
|
20
|
-
Chunk.def_property_readonly(
|
|
21
|
-
"component_ids",
|
|
22
|
-
&Amulet::Chunk::get_component_ids
|
|
23
|
-
);
|
|
24
|
-
auto py_serialise = [](const Amulet::Chunk& self) -> py::typing::Dict<py::str, py::typing::Optional<py::bytes>> {
|
|
25
|
-
py::dict data;
|
|
26
|
-
for (const auto& [k, v] : self.serialise_chunk()) {
|
|
27
|
-
if (v) {
|
|
28
|
-
data[py::str(k)] = py::bytes(v.value());
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
data[py::str(k)] = py::none();
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return data;
|
|
35
|
-
};
|
|
36
|
-
Chunk.def(
|
|
37
|
-
"serialise_chunk",
|
|
38
|
-
py_serialise,
|
|
39
|
-
py::doc("This is private. Do not use this. It will be removed in the future.")
|
|
40
|
-
);
|
|
41
|
-
auto py_deserialise = [](Amulet::Chunk& self, py::typing::Dict<py::str, py::typing::Optional<py::bytes>> data) {
|
|
42
|
-
Amulet::SerialisedComponents component_data;
|
|
43
|
-
for (const auto& [k, v] : data) {
|
|
44
|
-
if (v.is(py::none())) {
|
|
45
|
-
component_data[k.cast<std::string>()];
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
component_data[k.cast<std::string>()] = v.cast<std::string>();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
self.reconstruct_chunk(component_data);
|
|
52
|
-
};
|
|
53
|
-
Chunk.def(
|
|
54
|
-
"reconstruct_chunk",
|
|
55
|
-
py_deserialise,
|
|
56
|
-
py::doc("This is private. Do not use this. It will be removed in the future.")
|
|
57
|
-
);
|
|
58
|
-
Chunk.def(
|
|
59
|
-
py::pickle(
|
|
60
|
-
[py_serialise](const Amulet::Chunk& self) {
|
|
61
|
-
return py::make_tuple(
|
|
62
|
-
self.get_chunk_id(),
|
|
63
|
-
py_serialise(self)
|
|
64
|
-
);
|
|
65
|
-
},
|
|
66
|
-
[py_deserialise](py::tuple state) {
|
|
67
|
-
if (state.size() != 2) { throw std::runtime_error("Invalid state!"); }
|
|
68
|
-
auto self = Amulet::get_null_chunk(state[0].cast<std::string>());
|
|
69
|
-
py_deserialise(*self, state[1]);
|
|
70
|
-
return self;
|
|
71
|
-
}
|
|
72
|
-
)
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
m.def(
|
|
76
|
-
"get_null_chunk",
|
|
77
|
-
&Amulet::get_null_chunk,
|
|
78
|
-
py::doc("This is a private function")
|
|
79
|
-
);
|
|
80
|
-
}
|
amulet/chunk.pyi
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
__all__ = ["Chunk", "get_null_chunk"]
|
|
4
|
-
|
|
5
|
-
class Chunk:
|
|
6
|
-
"""
|
|
7
|
-
A base class for all chunk classes.
|
|
8
|
-
"""
|
|
9
|
-
|
|
10
|
-
def reconstruct_chunk(self, arg0: dict[str, bytes | None]) -> None:
|
|
11
|
-
"""
|
|
12
|
-
This is private. Do not use this. It will be removed in the future.
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
def serialise_chunk(self) -> dict[str, bytes | None]:
|
|
16
|
-
"""
|
|
17
|
-
This is private. Do not use this. It will be removed in the future.
|
|
18
|
-
"""
|
|
19
|
-
|
|
20
|
-
@property
|
|
21
|
-
def chunk_id(self) -> str: ...
|
|
22
|
-
@property
|
|
23
|
-
def component_ids(self) -> list[str]: ...
|
|
24
|
-
|
|
25
|
-
def get_null_chunk(arg0: str) -> Chunk:
|
|
26
|
-
"""
|
|
27
|
-
This is a private function
|
|
28
|
-
"""
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <memory>
|
|
4
|
-
#include <tuple>
|
|
5
|
-
#include <optional>
|
|
6
|
-
#include <cstdint>
|
|
7
|
-
#include <memory>
|
|
8
|
-
|
|
9
|
-
#include <amulet/version.hpp>
|
|
10
|
-
#include <amulet/biome.hpp>
|
|
11
|
-
#include <amulet/palette/biome_palette.hpp>
|
|
12
|
-
#include <amulet/chunk_components/section_array_map.hpp>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
namespace Amulet {
|
|
16
|
-
class Biome3DComponentData {
|
|
17
|
-
private:
|
|
18
|
-
std::shared_ptr<BiomePalette> _palette;
|
|
19
|
-
std::shared_ptr<SectionArrayMap> _sections;
|
|
20
|
-
public:
|
|
21
|
-
Biome3DComponentData(
|
|
22
|
-
std::shared_ptr<VersionRange> version_range,
|
|
23
|
-
const SectionShape& array_shape,
|
|
24
|
-
std::shared_ptr<Biome> default_biome
|
|
25
|
-
):
|
|
26
|
-
_palette(std::make_shared<BiomePalette>(version_range)),
|
|
27
|
-
_sections(std::make_shared<SectionArrayMap>(array_shape, static_cast<std::uint32_t>(0)))
|
|
28
|
-
{
|
|
29
|
-
_palette->biome_to_index(default_biome);
|
|
30
|
-
}
|
|
31
|
-
std::shared_ptr<BiomePalette> get_palette() {
|
|
32
|
-
return _palette;
|
|
33
|
-
}
|
|
34
|
-
std::shared_ptr<SectionArrayMap> get_sections() {
|
|
35
|
-
return _sections;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
class Biome3DComponent {
|
|
40
|
-
private:
|
|
41
|
-
std::optional<std::shared_ptr<Biome3DComponentData>> _value;
|
|
42
|
-
protected:
|
|
43
|
-
// Null constructor
|
|
44
|
-
Biome3DComponent() {};
|
|
45
|
-
// Default constructor
|
|
46
|
-
void init(
|
|
47
|
-
std::shared_ptr<VersionRange> version_range,
|
|
48
|
-
const SectionShape& array_shape,
|
|
49
|
-
std::shared_ptr<Biome> default_biome
|
|
50
|
-
) { _value = std::make_shared<Biome3DComponentData>(version_range, array_shape, default_biome); }
|
|
51
|
-
|
|
52
|
-
// Serialise the component data
|
|
53
|
-
std::optional<std::string> serialise() const;
|
|
54
|
-
// Deserialise the component
|
|
55
|
-
void deserialise(std::optional<std::string>);
|
|
56
|
-
public:
|
|
57
|
-
static const std::string ComponentID;
|
|
58
|
-
std::shared_ptr<Biome3DComponentData> get_biome() {
|
|
59
|
-
if (_value) {
|
|
60
|
-
return *_value;
|
|
61
|
-
}
|
|
62
|
-
throw std::runtime_error("BiomeComponent has not been loaded.");
|
|
63
|
-
};
|
|
64
|
-
void set_biome(std::shared_ptr<Biome3DComponentData> component) {
|
|
65
|
-
if (_value) {
|
|
66
|
-
if ((*_value)->get_sections()->get_array_shape() != component->get_sections()->get_array_shape()) {
|
|
67
|
-
throw std::invalid_argument("New biome array shape does not match old array shape.");
|
|
68
|
-
}
|
|
69
|
-
if ((*_value)->get_palette()->get_version_range() != component->get_palette()->get_version_range()) {
|
|
70
|
-
throw std::invalid_argument("New biome version range does not match old version range.");
|
|
71
|
-
}
|
|
72
|
-
_value = component;
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
throw std::runtime_error("BiomeComponent has not been loaded.");
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
#include <amulet/chunk_components/block_component.hpp>
|
|
2
|
-
|
|
3
|
-
namespace Amulet {
|
|
4
|
-
void BlockComponentData::serialise(BinaryWriter& writer) const {
|
|
5
|
-
writer.writeNumeric<std::uint8_t>(1);
|
|
6
|
-
get_palette()->serialise(writer);
|
|
7
|
-
get_sections()->serialise(writer);
|
|
8
|
-
}
|
|
9
|
-
std::shared_ptr<BlockComponentData> BlockComponentData::deserialise(BinaryReader& reader) {
|
|
10
|
-
auto version = reader.readNumeric<std::uint8_t>();
|
|
11
|
-
switch (version) {
|
|
12
|
-
case 1:
|
|
13
|
-
{
|
|
14
|
-
auto palette = BlockPalette::deserialise(reader);
|
|
15
|
-
auto sections = SectionArrayMap::deserialise(reader);
|
|
16
|
-
return std::make_shared<BlockComponentData>(palette, sections);
|
|
17
|
-
}
|
|
18
|
-
default:
|
|
19
|
-
throw std::invalid_argument("Unsupported BlockComponentData version " + std::to_string(version));
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const std::string BlockComponent::ComponentID = "Amulet::BlockComponent";
|
|
24
|
-
|
|
25
|
-
std::optional<std::string> BlockComponent::serialise() const {
|
|
26
|
-
if (_value) {
|
|
27
|
-
return Amulet::serialise(**_value);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
return std::nullopt;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
void BlockComponent::deserialise(std::optional<std::string> data) {
|
|
34
|
-
if (data) {
|
|
35
|
-
_value = Amulet::deserialise<BlockComponentData>(*data);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
_value = std::nullopt;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <memory>
|
|
4
|
-
#include <tuple>
|
|
5
|
-
#include <optional>
|
|
6
|
-
|
|
7
|
-
#include <amulet/version.hpp>
|
|
8
|
-
#include <amulet/block.hpp>
|
|
9
|
-
#include <amulet/palette/block_palette.hpp>
|
|
10
|
-
#include <amulet/chunk_components/section_array_map.hpp>
|
|
11
|
-
#include <amulet/io/binary_writer.hpp>
|
|
12
|
-
#include <amulet/io/binary_reader.hpp>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
namespace Amulet {
|
|
16
|
-
class BlockComponentData {
|
|
17
|
-
private:
|
|
18
|
-
std::shared_ptr<BlockPalette> _palette;
|
|
19
|
-
std::shared_ptr<SectionArrayMap> _sections;
|
|
20
|
-
public:
|
|
21
|
-
BlockComponentData(
|
|
22
|
-
std::shared_ptr<VersionRange> version_range,
|
|
23
|
-
const SectionShape& array_shape,
|
|
24
|
-
std::shared_ptr<BlockStack> default_block
|
|
25
|
-
):
|
|
26
|
-
_palette(std::make_shared<BlockPalette>(version_range)),
|
|
27
|
-
_sections(std::make_shared<SectionArrayMap>(array_shape, static_cast<std::uint32_t>(0)))
|
|
28
|
-
{
|
|
29
|
-
_palette->block_stack_to_index(default_block);
|
|
30
|
-
}
|
|
31
|
-
BlockComponentData(
|
|
32
|
-
std::shared_ptr<BlockPalette> palette,
|
|
33
|
-
std::shared_ptr<SectionArrayMap> sections
|
|
34
|
-
): _palette(palette), _sections(sections){}
|
|
35
|
-
|
|
36
|
-
void serialise(BinaryWriter&) const;
|
|
37
|
-
static std::shared_ptr<BlockComponentData> deserialise(BinaryReader&);
|
|
38
|
-
|
|
39
|
-
std::shared_ptr<BlockPalette> get_palette() const {
|
|
40
|
-
return _palette;
|
|
41
|
-
}
|
|
42
|
-
std::shared_ptr<SectionArrayMap> get_sections() const {
|
|
43
|
-
return _sections;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
class BlockComponent {
|
|
49
|
-
private:
|
|
50
|
-
std::optional<std::shared_ptr<BlockComponentData>> _value;
|
|
51
|
-
protected:
|
|
52
|
-
// Null constructor
|
|
53
|
-
BlockComponent() {};
|
|
54
|
-
// Default constructor
|
|
55
|
-
void init(
|
|
56
|
-
std::shared_ptr<VersionRange> version_range,
|
|
57
|
-
const SectionShape& array_shape,
|
|
58
|
-
std::shared_ptr<BlockStack> default_block
|
|
59
|
-
) { _value = std::make_shared<BlockComponentData>(version_range, array_shape, default_block); }
|
|
60
|
-
|
|
61
|
-
// Serialise the component data
|
|
62
|
-
std::optional<std::string> serialise() const;
|
|
63
|
-
// Deserialise the component
|
|
64
|
-
void deserialise(std::optional<std::string>);
|
|
65
|
-
public:
|
|
66
|
-
static const std::string ComponentID;
|
|
67
|
-
std::shared_ptr<BlockComponentData> get_block() {
|
|
68
|
-
if (_value) {
|
|
69
|
-
return *_value;
|
|
70
|
-
}
|
|
71
|
-
throw std::runtime_error("BlockComponent has not been loaded.");
|
|
72
|
-
};
|
|
73
|
-
void set_block(std::shared_ptr<BlockComponentData> component) {
|
|
74
|
-
if (_value) {
|
|
75
|
-
if ((*_value)->get_sections()->get_array_shape() != component->get_sections()->get_array_shape()) {
|
|
76
|
-
throw std::invalid_argument("New block array shape does not match old array shape.");
|
|
77
|
-
}
|
|
78
|
-
if ((*_value)->get_palette()->get_version_range() != component->get_palette()->get_version_range()) {
|
|
79
|
-
throw std::invalid_argument("New block version range does not match old version range.");
|
|
80
|
-
}
|
|
81
|
-
_value = component;
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
throw std::runtime_error("BlockComponent has not been loaded.");
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <memory>
|
|
4
|
-
#include <tuple>
|
|
5
|
-
#include <optional>
|
|
6
|
-
#include <cstdint>
|
|
7
|
-
#include <memory>
|
|
8
|
-
#include <map>
|
|
9
|
-
|
|
10
|
-
#include <amulet/version.hpp>
|
|
11
|
-
#include <amulet/block_entity.hpp>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
namespace Amulet {
|
|
15
|
-
typedef std::tuple<std::uint16_t, std::int64_t, std::uint16_t> BlockEntityChunkCoord;
|
|
16
|
-
class BlockEntityComponentData: public VersionRangeContainer {
|
|
17
|
-
private:
|
|
18
|
-
std::uint16_t _x_size;
|
|
19
|
-
std::uint16_t _z_size;
|
|
20
|
-
std::map<
|
|
21
|
-
BlockEntityChunkCoord,
|
|
22
|
-
std::shared_ptr<BlockEntity>
|
|
23
|
-
> _block_entities;
|
|
24
|
-
public:
|
|
25
|
-
BlockEntityComponentData(
|
|
26
|
-
std::shared_ptr<VersionRange> version_range,
|
|
27
|
-
const std::uint16_t& x_size,
|
|
28
|
-
const std::uint16_t& z_size
|
|
29
|
-
) :
|
|
30
|
-
VersionRangeContainer(version_range),
|
|
31
|
-
_x_size(x_size),
|
|
32
|
-
_z_size(z_size),
|
|
33
|
-
_block_entities()
|
|
34
|
-
{}
|
|
35
|
-
|
|
36
|
-
std::uint16_t get_x_size() const { return _x_size; }
|
|
37
|
-
std::uint16_t get_z_size() const { return _z_size; }
|
|
38
|
-
|
|
39
|
-
const std::map<
|
|
40
|
-
BlockEntityChunkCoord,
|
|
41
|
-
std::shared_ptr<BlockEntity>
|
|
42
|
-
>& get_block_entities() const {
|
|
43
|
-
return _block_entities;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
size_t get_size() const { return _block_entities.size(); }
|
|
47
|
-
|
|
48
|
-
bool contains(
|
|
49
|
-
const BlockEntityChunkCoord& coord
|
|
50
|
-
) const {
|
|
51
|
-
return _block_entities.contains(coord);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
std::shared_ptr<BlockEntity> get(
|
|
55
|
-
const BlockEntityChunkCoord& coord
|
|
56
|
-
) const {
|
|
57
|
-
return _block_entities.at(coord);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
void set(
|
|
61
|
-
const BlockEntityChunkCoord& coord,
|
|
62
|
-
std::shared_ptr<BlockEntity> block_entity
|
|
63
|
-
) {
|
|
64
|
-
if (
|
|
65
|
-
std::get<0>(coord) < 0 ||
|
|
66
|
-
std::get<2>(coord) < 0 ||
|
|
67
|
-
_x_size <= std::get<0>(coord) ||
|
|
68
|
-
_z_size <= std::get<2>(coord)
|
|
69
|
-
){
|
|
70
|
-
throw std::invalid_argument(
|
|
71
|
-
"Coord must be 0 <= " +
|
|
72
|
-
std::to_string(std::get<0>(coord)) +
|
|
73
|
-
" < " +
|
|
74
|
-
std::to_string(_x_size) +
|
|
75
|
-
"and 0 <= " +
|
|
76
|
-
std::to_string(std::get<1>(coord)) +
|
|
77
|
-
" < " +
|
|
78
|
-
std::to_string(_z_size)
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
if (!(
|
|
82
|
-
get_version_range()->contains(
|
|
83
|
-
block_entity->get_platform(),
|
|
84
|
-
*block_entity->get_version()
|
|
85
|
-
)
|
|
86
|
-
)){
|
|
87
|
-
throw std::invalid_argument(
|
|
88
|
-
"BlockEntity is incompatible with VersionRange."
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
_block_entities[coord] = block_entity;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
void del(
|
|
95
|
-
const BlockEntityChunkCoord& coord
|
|
96
|
-
) {
|
|
97
|
-
_block_entities.erase(coord);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
class BlockEntityComponent {
|
|
103
|
-
private:
|
|
104
|
-
std::optional<std::shared_ptr<BlockEntityComponentData>> _value;
|
|
105
|
-
protected:
|
|
106
|
-
// Null constructor
|
|
107
|
-
BlockEntityComponent() {};
|
|
108
|
-
// Default constructor
|
|
109
|
-
void init(
|
|
110
|
-
std::shared_ptr<VersionRange> version_range,
|
|
111
|
-
const std::uint16_t& x_size,
|
|
112
|
-
const std::uint16_t& z_size
|
|
113
|
-
) {
|
|
114
|
-
_value = std::make_shared<BlockEntityComponentData>(version_range, x_size, z_size);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Serialise the component data
|
|
118
|
-
std::optional<std::string> serialise() const;
|
|
119
|
-
// Deserialise the component
|
|
120
|
-
void deserialise(std::optional<std::string>);
|
|
121
|
-
public:
|
|
122
|
-
static const std::string ComponentID;
|
|
123
|
-
std::shared_ptr<BlockEntityComponentData> get_block_entity() {
|
|
124
|
-
if (_value) {
|
|
125
|
-
return *_value;
|
|
126
|
-
}
|
|
127
|
-
throw std::runtime_error("BlockEntityComponent has not been loaded.");
|
|
128
|
-
};
|
|
129
|
-
void set_block_entity(std::shared_ptr<BlockEntityComponentData> component) {
|
|
130
|
-
if (_value) {
|
|
131
|
-
if (
|
|
132
|
-
(*_value)->get_x_size() != component->get_x_size() ||
|
|
133
|
-
(*_value)->get_z_size() != component->get_z_size()
|
|
134
|
-
) {
|
|
135
|
-
throw std::invalid_argument("New BlockEntityComponent shape does not match old shape.");
|
|
136
|
-
}
|
|
137
|
-
if ((*_value)->get_version_range() != component->get_version_range()) {
|
|
138
|
-
throw std::invalid_argument("New BlockEntityComponent version range does not match old version range.");
|
|
139
|
-
}
|
|
140
|
-
_value = component;
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
throw std::runtime_error("BlockEntityComponent has not been loaded.");
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
};
|
|
147
|
-
}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
#include <string>
|
|
2
|
-
|
|
3
|
-
#include <amulet/io/binary_writer.hpp>
|
|
4
|
-
#include <amulet/io/binary_reader.hpp>
|
|
5
|
-
|
|
6
|
-
#include "section_array_map.hpp"
|
|
7
|
-
|
|
8
|
-
namespace Amulet {
|
|
9
|
-
void IndexArray3D::serialise(BinaryWriter& writer) const {
|
|
10
|
-
writer.writeNumeric<std::uint8_t>(1);
|
|
11
|
-
|
|
12
|
-
// Write array shape
|
|
13
|
-
const auto& array_shape = get_shape();
|
|
14
|
-
writer.writeNumeric<std::uint16_t>(std::get<0>(array_shape));
|
|
15
|
-
writer.writeNumeric<std::uint16_t>(std::get<1>(array_shape));
|
|
16
|
-
writer.writeNumeric<std::uint16_t>(std::get<2>(array_shape));
|
|
17
|
-
|
|
18
|
-
// Write array
|
|
19
|
-
const auto& size = get_size();
|
|
20
|
-
const auto* buffer = get_buffer();
|
|
21
|
-
for (auto i = 0; i < size; i++) {
|
|
22
|
-
writer.writeNumeric<std::uint32_t>(buffer[i]);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
std::shared_ptr<IndexArray3D> IndexArray3D::deserialise(BinaryReader& reader) {
|
|
26
|
-
auto version = reader.readNumeric<std::uint8_t>();
|
|
27
|
-
switch (version) {
|
|
28
|
-
case 1:
|
|
29
|
-
{
|
|
30
|
-
// Read array shape
|
|
31
|
-
auto array_shape = std::make_tuple(
|
|
32
|
-
reader.readNumeric<std::uint16_t>(),
|
|
33
|
-
reader.readNumeric<std::uint16_t>(),
|
|
34
|
-
reader.readNumeric<std::uint16_t>()
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
// Construct instance
|
|
38
|
-
auto self = std::make_shared<IndexArray3D>(array_shape);
|
|
39
|
-
|
|
40
|
-
// Read array
|
|
41
|
-
const auto& size = self->get_size();
|
|
42
|
-
auto* buffer = self->get_buffer();
|
|
43
|
-
for (auto i = 0; i < size; i++) {
|
|
44
|
-
buffer[i] = reader.readNumeric<std::uint32_t>();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return self;
|
|
48
|
-
}
|
|
49
|
-
default:
|
|
50
|
-
throw std::invalid_argument("Unsupported IndexArray3D version " + std::to_string(version));
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
void SectionArrayMap::serialise(BinaryWriter& writer) const {
|
|
55
|
-
writer.writeNumeric<std::uint8_t>(1);
|
|
56
|
-
|
|
57
|
-
// Write array shape
|
|
58
|
-
const auto& array_shape = get_array_shape();
|
|
59
|
-
writer.writeNumeric<std::uint16_t>(std::get<0>(array_shape));
|
|
60
|
-
writer.writeNumeric<std::uint16_t>(std::get<1>(array_shape));
|
|
61
|
-
writer.writeNumeric<std::uint16_t>(std::get<2>(array_shape));
|
|
62
|
-
|
|
63
|
-
// Write default array
|
|
64
|
-
std::visit(
|
|
65
|
-
[&writer](auto&& arg) {
|
|
66
|
-
using T = std::decay_t<decltype(arg)>;
|
|
67
|
-
if constexpr (std::is_same_v<T, std::uint32_t>) {
|
|
68
|
-
writer.writeNumeric<std::uint8_t>(0);
|
|
69
|
-
writer.writeNumeric<std::uint32_t>(arg);
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
writer.writeNumeric<std::uint8_t>(1);
|
|
73
|
-
arg->serialise(writer);
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
get_default_array()
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
// Write arrays
|
|
80
|
-
const auto& arrays = get_arrays();
|
|
81
|
-
writer.writeNumeric<std::uint64_t>(arrays.size());
|
|
82
|
-
for (const auto& [cy, arr] : arrays) {
|
|
83
|
-
writer.writeNumeric<std::int64_t>(cy);
|
|
84
|
-
arr->serialise(writer);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
std::shared_ptr<SectionArrayMap> SectionArrayMap::deserialise(BinaryReader& reader) {
|
|
88
|
-
auto version = reader.readNumeric<std::uint8_t>();
|
|
89
|
-
switch (version) {
|
|
90
|
-
case 1:
|
|
91
|
-
{
|
|
92
|
-
// Read array shape
|
|
93
|
-
auto array_shape = std::make_tuple(
|
|
94
|
-
reader.readNumeric<std::uint16_t>(),
|
|
95
|
-
reader.readNumeric<std::uint16_t>(),
|
|
96
|
-
reader.readNumeric<std::uint16_t>()
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
// Read default array
|
|
100
|
-
auto default_array_state = reader.readNumeric<std::uint8_t>();
|
|
101
|
-
std::variant<std::uint32_t, std::shared_ptr<IndexArray3D>> default_array;
|
|
102
|
-
switch (default_array_state) {
|
|
103
|
-
case 0:
|
|
104
|
-
default_array = reader.readNumeric<std::uint32_t>();
|
|
105
|
-
break;
|
|
106
|
-
case 1:
|
|
107
|
-
default_array = IndexArray3D::deserialise(reader);
|
|
108
|
-
break;
|
|
109
|
-
default:
|
|
110
|
-
throw std::invalid_argument("Invalid default array state value " + std::to_string(default_array_state));
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// Construct instance
|
|
114
|
-
auto self = std::make_shared<SectionArrayMap>(array_shape, default_array);
|
|
115
|
-
|
|
116
|
-
// Populate arrays
|
|
117
|
-
auto array_count = reader.readNumeric<std::uint64_t>();
|
|
118
|
-
for (auto i = 0; i < array_count; i++) {
|
|
119
|
-
auto cy = reader.readNumeric<std::int64_t>();
|
|
120
|
-
self->set_section(cy, IndexArray3D::deserialise(reader));
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return self;
|
|
124
|
-
}
|
|
125
|
-
default:
|
|
126
|
-
throw std::invalid_argument("Unsupported BlockComponentData version " + std::to_string(version));
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|