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