LeviLamina
Loading...
Searching...
No Matches
StructureManager.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/core/file/PathBuffer.h"
7#include "mc/deps/core/string/BasicStackString.h"
8#include "mc/deps/core/utility/NonOwnerPointer.h"
9#include "mc/world/level/chunk/QueueRequestResult.h"
10#include "mc/world/level/levelgen/structure/IStructureTemplateManager.h"
11#include "mc/world/level/levelgen/structure/StructureDeleteResult.h"
12
13// auto generated forward declare list
14// clang-format off
15class BlockPos;
16class BoundingBox;
17class CommandArea;
18class Dimension;
21class Level;
22class LevelStorage;
23class PackInstance;
25class ServerLevel;
30namespace Core { class Path; }
31namespace SharedTypes::v1_21_80 { struct JigsawStructureMetadata; }
32namespace cereal { struct ReflectionCtx; }
33namespace mce { class UUID; }
34// clang-format on
35
36class StructureManager : public ::IStructureTemplateManager {
37public:
38 // member variables
39 // NOLINTBEGIN
40 ::ll::TypedStorage<8, 8, ::std::shared_mutex> mRepositoryMutex;
41 ::ll::TypedStorage<8, 64, ::std::unordered_map<::std::string, ::std::unique_ptr<::LegacyStructureTemplate>>>
42 mLegacyStructureRepository;
43 ::ll::TypedStorage<8, 64, ::std::unordered_map<::std::string, ::std::unique_ptr<::StructureTemplate>>>
44 mStructureRepository;
45 ::ll::TypedStorage<8, 24, ::std::vector<::std::unique_ptr<::StructureAnimationData>>> mStructurePlacementQueue;
46 ::ll::TypedStorage<4, 4, uint> mStructurePlacementSaveCounter;
47 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::IUnknownBlockTypeRegistry>> mUnknownBlockRegistry;
48 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::ResourcePackManager> const> mPackManager;
49 ::ll::TypedStorage<
50 8,
51 64,
52 ::std::unordered_map<uint64, ::std::shared_ptr<::SharedTypes::v1_21_80::JigsawStructureMetadata>>>
53 mMetadataRegistry;
54 ::ll::TypedStorage<8, 80, ::std::mutex> mMetadataRegistryMutex;
55 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::cereal::ReflectionCtx>> mCerealContext;
56 // NOLINTEND
57
58public:
59 // prevent constructor by default
60 StructureManager();
61
62public:
63 // virtual functions
64 // NOLINTBEGIN
65 virtual ~StructureManager() /*override*/ = default;
66
67 virtual ::LegacyStructureTemplate& getOrCreateLegacy(::std::string const& structureName) /*override*/;
68
69 virtual ::StructureTemplate& getOrCreate(::std::string const& structureName) /*override*/;
70
71 virtual ::StructureTemplate* getStructure(::std::string const& structureName) const /*override*/;
72
73 virtual bool readStructure(::StructureTemplate& structureTemplate) /*override*/;
74
75 virtual ::std::shared_ptr<::SharedTypes::v1_21_80::JigsawStructureMetadata>
76 getOrCreateJigsawStructureMetadata(::StructurePoolElement const& structurePoolElement) /*override*/;
77 // NOLINTEND
78
79public:
80 // member functions
81 // NOLINTBEGIN
82 MCAPI explicit StructureManager(::ResourcePackManager& packManager);
83
84 MCAPI ::StructureTemplate* _createAndLoadStructure(
85 ::std::string const& structureName,
86 ::ResourcePackManager const* packManager,
87 ::LevelStorage* levelStorage
88 );
89
90 MCAPI ::std::string _createLevelStorageId(::std::string const& dimensionPrefix, ::std::string const& saveId);
91
92 MCAPI ::StructureTemplate&
93 cloneStructure(::StructureTemplate const& structureTemplate, ::std::string const& structureName);
94
95 MCAPI ::StructureDeleteResult deleteStructure(::std::string const& structureName, ::LevelStorage& levelStorage);
96
97 MCAPI ::std::vector<::std::string> getPackStructureNames(::mce::UUID const& packUUID);
98
99 MCAPI ::std::vector<::std::string> getStructureNames(::LevelStorage& levelStorage, bool includeUnremovable) const;
100
101#ifdef LL_PLAT_C
102 MCAPI ::StructureTemplate* importStructure(::std::string const& structureName, ::Core::Path const& filePath);
103#endif
104
105 MCAPI void importStructureFromTemplate(::std::string name, ::StructureTemplate const& temp);
106
107 MCAPI bool load(
108 ::StructureTemplate& structureTemplate,
109 ::ResourcePackManager const* packManager,
110 ::LevelStorage* levelStorage
111 );
112
113 MCAPI void loadMetadataRegistries();
114
115 MCAPI void loadPlacementQueue(::LevelStorage& storage, ::Level& level, ::Dimension& dimension);
116
117 MCAPI void reset();
118
119 MCAPI void saveToLevel(::StructureTemplate const& structureTemplate, ::LevelStorage& levelStorage);
120
121 MCAPI void setUnknownBlockRegistry(::Bedrock::NonOwnerPointer<::IUnknownBlockTypeRegistry> unknownBlockRegistry);
122
123 MCAPI void tick(::Dimension const& dimension);
124
125 MCAPI ::QueueRequestResult tryPlaceStructureInWorld(
126 ::std::unique_ptr<::CommandArea> cmdArea,
127 ::ServerLevel& level,
128 ::Dimension& dimension,
129 ::BoundingBox const& bounds,
130 ::BlockPos const& loadPosition,
131 ::StructureSettings const& settings,
132 ::StructureTemplate const& structureTemplate,
133 ::std::unique_ptr<::StructureAnimationData> structureAnimationData
134 );
135 // NOLINTEND
136
137public:
138 // static functions
139 // NOLINTBEGIN
140 MCAPI static bool _findResource(
142 ::PackInstance const& pack,
143 ::std::string& resourceStream
144 );
145
146 MCAPI static void
147 _removePlacementQueueItem(::std::string const& dimensionPrefix, ::StructureAnimationData& structureAnimationData);
148
149#ifdef LL_PLAT_C
150 MCAPI static bool exportStructure(::StructureTemplate const& structureTemplate, ::Core::Path const& filePath);
151#endif
152
153 MCAPI static ::Core::PathBuffer<::Core::BasicStackString<char, 1024>>
154 getStructurePath(::std::string_view structureFullName);
155
156 MCAPI static ::Core::PathBuffer<::Core::BasicStackString<char, 1024>>
157 getStructurePath(::std::string_view structureNamespace, ::std::string_view structureName);
158 // NOLINTEND
159
160public:
161 // constructor thunks
162 // NOLINTBEGIN
163 MCAPI void* $ctor(::ResourcePackManager& packManager);
164 // NOLINTEND
165
166public:
167 // virtual function thunks
168 // NOLINTBEGIN
169 MCAPI ::LegacyStructureTemplate& $getOrCreateLegacy(::std::string const& structureName);
170
171 MCAPI ::StructureTemplate& $getOrCreate(::std::string const& structureName);
172
173 MCAPI ::StructureTemplate* $getStructure(::std::string const& structureName) const;
174
175 MCAPI bool $readStructure(::StructureTemplate& structureTemplate);
176
177 MCAPI ::std::shared_ptr<::SharedTypes::v1_21_80::JigsawStructureMetadata>
178 $getOrCreateJigsawStructureMetadata(::StructurePoolElement const& structurePoolElement);
179
180
181 // NOLINTEND
182};
Definition NonOwnerPointer.h:9
Definition BlockPos.h:17
Definition BoundingBox.h:13
Definition CommandArea.h:10
Definition BasicStackString.h:8
Definition PathBuffer.h:8
Definition Path.h:11
Definition Dimension.h:86
Definition IStructureTemplateManager.h:16
Definition IUnknownBlockTypeRegistry.h:14
Definition LegacyStructureTemplate.h:27
Definition LevelStorage.h:25
Definition Level.h:254
Definition PackInstance.h:16
Definition ResourcePackManager.h:36
Definition ServerLevel.h:57
Definition StructureAnimationData.h:16
Definition StructurePoolElement.h:39
Definition StructureSettings.h:18
Definition StructureTemplate.h:34
Definition UUID.h:8
Definition JigsawStructureMetadata.h:15
Definition ReflectionCtx.h:11