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/deps/puv/Loader.h"
10#include "mc/network/packet/StructureTemplateResponseType.h"
11#include "mc/platform/threading/Mutex.h"
12#include "mc/world/level/chunk/ChunksLoadedStatus.h"
13#include "mc/world/level/chunk/QueueRequestResult.h"
14#include "mc/world/level/levelgen/structure/IStructureTemplateManager.h"
15#include "mc/world/level/levelgen/structure/StructureDeleteResult.h"
16
17// auto generated forward declare list
18// clang-format off
19class BlockPos;
20class BoundingBox;
22class CommandArea;
23class CompoundTag;
24class Dimension;
27class Level;
28class LevelStorage;
29class PackInstance;
31class ServerLevel;
37struct Tick;
38namespace Core { class Path; }
39namespace SharedTypes::v1_21_80 { struct JigsawStructureMetadata; }
40namespace SharedTypes::v1_21_80 { struct JigsawStructureMetadataFile; }
41namespace SharedTypes::v1_21_80 { struct JigsawStructureMetadataRegistry; }
42namespace cereal { struct ReflectionCtx; }
43namespace mce { class UUID; }
44// clang-format on
45
46class StructureManager : public ::IStructureTemplateManager {
47public:
48 // member variables
49 // NOLINTBEGIN
50 ::ll::TypedStorage<8, 8, ::std::shared_mutex> mRepositoryMutex;
51 ::ll::TypedStorage<8, 64, ::std::unordered_map<::std::string, ::std::unique_ptr<::LegacyStructureTemplate>>>
52 mLegacyStructureRepository;
53 ::ll::TypedStorage<8, 64, ::std::unordered_map<::std::string, ::std::unique_ptr<::StructureTemplate>>>
54 mStructureRepository;
55 ::ll::TypedStorage<8, 24, ::std::vector<::std::unique_ptr<::StructureAnimationData>>> mStructurePlacementQueue;
56 ::ll::TypedStorage<4, 4, uint> mStructurePlacementSaveCounter;
57 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::IUnknownBlockTypeRegistry>> mUnknownBlockRegistry;
58 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::ResourcePackManager> const> mPackManager;
59 ::ll::TypedStorage<
60 8,
61 64,
62 ::std::unordered_map<uint64, ::std::shared_ptr<::SharedTypes::v1_21_80::JigsawStructureMetadata>>>
63 mMetadataRegistry;
64 ::ll::TypedStorage<8, 80, ::Bedrock::Threading::Mutex> mMetadataRegistryMutex;
65 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::cereal::ReflectionCtx>> mCerealContext;
66 // NOLINTEND
67
68public:
69 // prevent constructor by default
70 StructureManager();
71
72public:
73 // virtual functions
74 // NOLINTBEGIN
75 virtual ~StructureManager() /*override*/;
76
77 virtual ::LegacyStructureTemplate& getOrCreateLegacy(::std::string const& structureName) /*override*/;
78
79 virtual ::StructureTemplate& getOrCreate(::std::string const& structureName) /*override*/;
80
81 virtual ::StructureTemplate* getStructure(::std::string const& structureName) const /*override*/;
82
83 virtual bool readStructure(::StructureTemplate& structureTemplate) /*override*/;
84
85 virtual ::std::shared_ptr<::SharedTypes::v1_21_80::JigsawStructureMetadata>
86 getOrCreateJigsawStructureMetadata(::StructurePoolElement const& structurePoolElement) /*override*/;
87 // NOLINTEND
88
89public:
90 // member functions
91 // NOLINTBEGIN
92 MCAPI explicit StructureManager(::ResourcePackManager& packManager);
93
94 MCAPI ::StructureTemplate* _createAndLoadStructure(
95 ::std::string const& structureName,
96 ::ResourcePackManager const* packManager,
97 ::LevelStorage* levelStorage
98 );
99
100 MCAPI ::std::string _createLevelStorageId(::std::string const& dimensionPrefix, ::std::string const& saveId);
101
102 MCAPI bool _findResource(
104 ::PackInstance const& pack,
105 ::std::string& resourceStream
106 );
107
108 MCAPI bool _findResource(
109 ::std::string_view structureNamespace,
112 ::PackInstance const& pack,
113 ::std::string& resourceStream
114 );
115
116 MCAPI ::LegacyStructureTemplate* _getLegacy(::std::string const& structurePath);
117
118 MCAPI bool _placeSegment(::StructureAnimationData& structureAnimationData);
119
120 MCAPI bool _placeSegment(
121 ::Dimension& dimension,
122 ::StructureAnimationData& structureAnimationData,
123 ::ChunkLoadActionList& chunkLoadActionList,
124 ::BoundingBox const& boundingBox,
125 ::std::function<::ChunksLoadedStatus(::Tick)> const& areChunksLoaded
126 );
127
128 MCAPI ::LegacyStructureTemplate* _readLegacyStructure(::std::string const& name);
129
130 MCAPI void
131 _removePlacementQueueItem(::std::string const& dimensionPrefix, ::StructureAnimationData& structureAnimationData);
132
133 MCAPI void
134 _savePlacementQueueItem(::std::string const& dimensionPrefix, ::StructureAnimationData& structureAnimationData);
135
136 MCAPI void clearAndShutdownStructurePlacement();
137
138 MCAPI ::StructureTemplate&
139 cloneStructure(::StructureTemplate const& structureTemplate, ::std::string const& structureName);
140
141 MCAPI ::StructureTemplateDataResponsePacket createStructureDataExportPacket(
142 ::std::string const& structureName,
143 ::ResourcePackManager const* packManager,
144 ::LevelStorage* levelStorage,
145 ::StructureTemplateResponseType responseType
146 );
147
148 MCAPI ::StructureDeleteResult deleteStructure(::std::string const& structureName, ::LevelStorage& levelStorage);
149
150 MCAPI ::StructureTemplate* getOrLoadStructure(
151 ::std::string const& structureName,
152 ::ResourcePackManager const* packManager,
153 ::LevelStorage* levelStorage
154 );
155
156 MCAPI ::std::vector<::std::string> getPackStructureNames(::mce::UUID const& packUUID);
157
158 MCAPI ::std::vector<::std::string> getStructureNames(::LevelStorage& levelStorage, bool includeUnremovable) const;
159
160#ifdef LL_PLAT_C
161 MCAPI ::StructureTemplate* importStructure(::std::string const& structureName, ::Core::Path const& filePath);
162#endif
163
164 MCAPI void importStructureFromTemplate(::std::string name, ::StructureTemplate const& temp);
165
166 MCAPI bool load(
167 ::StructureTemplate& structureTemplate,
168 ::ResourcePackManager const* packManager,
169 ::LevelStorage* levelStorage
170 );
171
172 MCAPI bool loadLegacy(::LegacyStructureTemplate& structure, ::std::string& data);
173
174 MCAPI void loadMetadataRegistries();
175
176 MCAPI void loadPlacementQueue(::LevelStorage& storage, ::Level& level, ::Dimension& dimension);
177
178 MCAPI void
179 loadPlacementQueueItem(::std::string const& key, ::CompoundTag const& tag, ::Level& level, ::Dimension& dimension);
180
181 MCAPI void reset();
182
183 MCAPI void saveToLevel(::StructureTemplate const& structureTemplate, ::LevelStorage& levelStorage);
184
185 MCAPI void setUnknownBlockRegistry(::Bedrock::NonOwnerPointer<::IUnknownBlockTypeRegistry> unknownBlockRegistry);
186
187 MCAPI void tick(::Dimension const& dimension);
188
189 MCAPI ::QueueRequestResult tryPlaceStructureInWorld(
190 ::std::unique_ptr<::CommandArea> cmdArea,
191 ::ServerLevel& level,
192 ::Dimension& dimension,
193 ::BoundingBox const& bounds,
194 ::BlockPos const& loadPosition,
195 ::StructureSettings const& settings,
196 ::StructureTemplate const& structureTemplate,
197 ::std::unique_ptr<::StructureAnimationData> structureAnimationData
198 );
199 // NOLINTEND
200
201public:
202 // static functions
203 // NOLINTBEGIN
204 MCAPI static ::std::unique_ptr<::SharedTypes::v1_21_80::JigsawStructureMetadataRegistry>
205 _loadMetadataRegistries(::cereal::ReflectionCtx const& ctx, ::ResourcePackManager& packManager, bool excludeLatest);
206
207 MCAPI static void _metadataPackForEachCallback(
212 ::PackInstance const& pack,
213 ::std::string& fileData,
214 ::Core::Path const& filenameWithExtension
215 );
216
217#ifdef LL_PLAT_C
218 MCAPI static bool exportStructure(::StructureTemplate const& structureTemplate, ::Core::Path const& filePath);
219#endif
220
221 MCAPI static ::Core::PathBuffer<::Core::BasicStackString<char, 1024>>
222 getStructurePath(::std::string_view structureFullName);
223
224 MCAPI static ::Core::PathBuffer<::Core::BasicStackString<char, 1024>>
225 getStructurePath(::std::string_view structureNamespace, ::std::string_view structureName);
226 // NOLINTEND
227
228public:
229 // static variables
230 // NOLINTBEGIN
231 MCAPI static char const*& BEHAVIOR_PACK_STRUCTURES_FOLDER();
232
233 MCAPI static char const*& LEVEL_STORAGE_STRUCTURE_TEMPLATE_PREFIX();
234 // NOLINTEND
235
236public:
237 // constructor thunks
238 // NOLINTBEGIN
239 MCAPI void* $ctor(::ResourcePackManager& packManager);
240 // NOLINTEND
241
242public:
243 // destructor thunk
244 // NOLINTBEGIN
245 MCAPI void $dtor();
246 // NOLINTEND
247
248public:
249 // virtual function thunks
250 // NOLINTBEGIN
251 MCAPI ::LegacyStructureTemplate& $getOrCreateLegacy(::std::string const& structureName);
252
253 MCAPI ::StructureTemplate& $getOrCreate(::std::string const& structureName);
254
255 MCAPI ::StructureTemplate* $getStructure(::std::string const& structureName) const;
256
257 MCAPI bool $readStructure(::StructureTemplate& structureTemplate);
258
259 MCAPI ::std::shared_ptr<::SharedTypes::v1_21_80::JigsawStructureMetadata>
260 $getOrCreateJigsawStructureMetadata(::StructurePoolElement const& structurePoolElement);
261
262
263 // NOLINTEND
264
265public:
266 // vftables
267 // NOLINTBEGIN
268 MCNAPI static void** $vftable();
269 // NOLINTEND
270};
Definition NonOwnerPointer.h:9
Definition BlockPos.h:21
Definition BoundingBox.h:13
Definition ChunkLoadActionList.h:26
Definition CommandArea.h:11
Definition CompoundTag.h:23
Definition BasicStackString.h:8
Definition PathBuffer.h:8
Definition Path.h:12
Definition Dimension.h:88
Definition IStructureTemplateManager.h:16
Definition IUnknownBlockTypeRegistry.h:14
Definition LegacyStructureTemplate.h:27
Definition LevelStorage.h:26
Definition Level.h:254
Definition PackInstance.h:28
Definition Loader.h:8
Definition ResourcePackManager.h:35
Definition ServerLevel.h:59
Definition StructureAnimationData.h:16
static MCAPI void ** $vftable()
Definition StructurePoolElement.h:39
Definition StructureSettings.h:18
Definition StructureTemplateDataResponsePacket.h:19
Definition StructureTemplate.h:35
Definition UUID.h:7
Definition JigsawStructureMetadataFile.h:15
Definition JigsawStructureMetadataRegistry.h:13
Definition JigsawStructureMetadata.h:16
Definition Tick.h:5
Definition ReflectionCtx.h:11
Definition ctx.h:5