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