Skip to content
LeviMC
English
AutoLightDark
LeviLamina
Loading...
Searching...
No Matches
WorldGenerator.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/core/threading/InstancedThreadLocalValue.h"
7#include "mc/deps/core/utility/buffer_span.h"
8#include "mc/world/level/ChunkPos.h"
9#include "mc/world/level/DividedPos2d.h"
10#include "mc/world/level/chunk/ChunkSource.h"
11#include "mc/world/level/levelgen/v1/IPreliminarySurfaceProvider.h"
12
13// auto generated forward declare list
14// clang-format off
15class Biome;
16class BiomeArea;
17class BiomeSource;
18class BlockPos;
19class BlockSource;
20class BlockVolume;
22class BoundingBox;
23class Dimension;
24class HashedString;
25class LevelChunk;
26class Random;
29namespace br::worldgen { class ChunkAccessor; }
30namespace br::worldgen { class StructureInstance; }
31namespace br::worldgen { struct ChunkStructureAccess; }
32namespace br::worldgen { struct Structure; }
33// clang-format on
34
35class WorldGenerator : public ::ChunkSource, public ::IPreliminarySurfaceProvider {
36public:
37 // WorldGenerator inner types declare
38 // clang-format off
40 // clang-format on
41
42 // WorldGenerator inner types define
44 public:
45 // member variables
46 // NOLINTBEGIN
47 ::ll::TypedStorage<4, 4, uint> mWidth;
48 ::ll::TypedStorage<4, 4, uint> mDepth;
49 ::ll::TypedStorage<4, 4, uint> mHeight;
50 // NOLINTEND
51 };
52
53public:
54 // member variables
55 // NOLINTBEGIN
56 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::StructureFeatureRegistry>> mStructureFeatureRegistry;
57 ::ll::TypedStorage<8, 80, ::std::mutex> mCreateStructuresAndVisitedPositionsMutex;
58 ::ll::TypedStorage<8, 72, ::std::condition_variable> mStructureInstanceWaitVar;
59 ::ll::TypedStorage<4, 4, ::std::atomic<int>> mActiveStructureInstanceCreateCount;
60 ::ll::TypedStorage<8, 64, ::std::unordered_set<::ChunkPos>> mVisitedPositions;
61 ::ll::TypedStorage<4, 4, ::Bedrock::Threading::InstancedThreadLocalValue<::br::worldgen::ChunkAccessor*>>
62 mThreadLocalHeightmapProvider;
63 // NOLINTEND
64
65public:
66 // prevent constructor by default
67 WorldGenerator();
68
69public:
70 // virtual functions
71 // NOLINTBEGIN
72 virtual ~WorldGenerator() /*override*/;
73
74 virtual ::HashedString findStructureFeatureTypeAt(::BlockPos const& pos);
75
76 virtual bool isStructureFeatureTypeAt(::BlockPos const& pos, ::HashedString type) const;
77
78 virtual bool findNearestStructureFeature(
79 ::HashedString feature,
80 ::BlockPos const& origin,
81 ::BlockPos& pos,
82 bool mustBeInNewChunks,
83 ::std::optional<::HashedString> biomeTag,
84 int searchRadiusCells
85 );
86
87 virtual ::StructureFeature* getStructureFeatureOfType(::HashedString type) const;
88
89 virtual void garbageCollectBlueprints(::buffer_span<::ChunkPos> activeChunks);
90
91 virtual void prepareHeights(
92 ::BlockVolume& box,
93 ::ChunkPos const& chunkPos,
94 ::std::vector<short>* ZXheights,
95 bool factorInBeardsAndShavers
96 ) = 0;
97
98 virtual ::BiomeArea getBiomeArea(::BoundingBox const& area, uint scale) const = 0;
99
100 virtual ::BiomeSource const& getBiomeSource() const = 0;
101
102 virtual ::WorldGenerator::BlockVolumeDimensions getBlockVolumeDimensions() const = 0;
103
104 virtual ::BlockPos findSpawnPosition() const = 0;
105
106 virtual void
107 postProcessMobsAt(::BlockSource& region, int chunkWestBlock, int chunkNorthBlock, ::Random& random) /*override*/;
108
109 virtual void postProcessMobsAt(::BlockSource& region, ::BoundingBox const& chunkBB) const /*override*/;
110
111 virtual ::std::optional<short> getPreliminarySurfaceLevel(::DividedPos2d<4> worldQuartPos) const /*override*/;
112
113 virtual void debugRender();
114
115 virtual void propagateCombinedChunkSource(::ChunkSource* chunkSource);
116
117 virtual void decorateWorldGenLoadChunk(
118 ::Biome const& biome,
119 ::LevelChunk& lc,
120 ::BlockVolumeTarget& target,
121 ::Random& random,
122 ::ChunkPos const& pos
123 ) const = 0;
124
125 virtual void decorateWorldGenPostProcess(
126 ::Biome const& biome,
127 ::LevelChunk& lc,
128 ::BlockSource& source,
129 ::Random& random
130 ) const = 0;
131
132 virtual ::std::shared_ptr<::br::worldgen::StructureInstance>
133 _tryGetOrLoadStructureInstanceAt(::ChunkPos const& cp, ::br::worldgen::Structure const& structure) /*override*/;
134 // NOLINTEND
135
136public:
137 // member functions
138 // NOLINTBEGIN
139 MCNAPI explicit WorldGenerator(::Dimension& dimension);
140
141 MCNAPI
142 WorldGenerator(::Dimension& dimension, ::std::unique_ptr<::StructureFeatureRegistry> structureFeatureRegistry);
143
145 ::br::worldgen::Structure const& structure,
146 ::ChunkPos const& chunkPos,
148 );
149
150 MCAPI void addHardcodedSpawnAreas(::LevelChunk& lc);
151
152 MCAPI ::std::vector<short> computeChunkHeightMap(::ChunkPos const& pos);
153
154 MCNAPI void
155 postProcessStructureFeatures(::BlockSource& region, ::Random& random, uint seed, int chunkX, int chunkZ);
156
157 MCNAPI void postProcessStructures(::BlockSource& region, ::Random&, int chunkX, int chunkZ);
158
159 MCNAPI void preProcessStructures(::Dimension& dimension, ::ChunkPos const& cp, ::BiomeSource const& biomeSource);
160
162 ::Dimension& dimension,
163 ::ChunkPos const& cp,
164 ::BiomeSource const& biomeSource,
165 ::IPreliminarySurfaceProvider const& preliminarySurfaceProvider
166 );
167
168 MCNAPI void waitForStructures();
169 // NOLINTEND
170
171public:
172 // constructor thunks
173 // NOLINTBEGIN
174 MCNAPI void* $ctor(::Dimension& dimension);
175
176 MCNAPI void* $ctor(::Dimension& dimension, ::std::unique_ptr<::StructureFeatureRegistry> structureFeatureRegistry);
177 // NOLINTEND
178
179public:
180 // destructor thunk
181 // NOLINTBEGIN
182 MCAPI void $dtor();
183 // NOLINTEND
184
185public:
186 // virtual function thunks
187 // NOLINTBEGIN
188 MCAPI ::HashedString $findStructureFeatureTypeAt(::BlockPos const& pos);
189
190 MCAPI bool $isStructureFeatureTypeAt(::BlockPos const& pos, ::HashedString type) const;
191
192 MCAPI bool $findNearestStructureFeature(
193 ::HashedString feature,
194 ::BlockPos const& origin,
195 ::BlockPos& pos,
196 bool mustBeInNewChunks,
197 ::std::optional<::HashedString> biomeTag,
198 int searchRadiusCells
199 );
200
201 MCAPI ::StructureFeature* $getStructureFeatureOfType(::HashedString type) const;
202
203 MCAPI void $garbageCollectBlueprints(::buffer_span<::ChunkPos> activeChunks);
204
205 MCAPI void $postProcessMobsAt(::BlockSource& region, int chunkWestBlock, int chunkNorthBlock, ::Random& random);
206
207 MCAPI void $postProcessMobsAt(::BlockSource& region, ::BoundingBox const& chunkBB) const;
208
209 MCFOLD ::std::optional<short> $getPreliminarySurfaceLevel(::DividedPos2d<4> worldQuartPos) const;
210
211 MCFOLD void $debugRender();
212
213 MCFOLD void $propagateCombinedChunkSource(::ChunkSource* chunkSource);
214
215 MCAPI ::std::shared_ptr<::br::worldgen::StructureInstance>
216 $_tryGetOrLoadStructureInstanceAt(::ChunkPos const& cp, ::br::worldgen::Structure const& structure);
217
218
219 // NOLINTEND
220
221public:
222 // vftables
223 // NOLINTBEGIN
225
226 MCNAPI static void** $vftableForChunkSource();
227 // NOLINTEND
228};
Definition BiomeArea.h:10
Definition BiomeSource.h:23
Definition Biome.h:23
Definition BlockPos.h:14
Definition BlockSource.h:72
Definition BlockVolumeTarget.h:28
Definition BlockVolume.h:14
Definition BoundingBox.h:13
Definition ChunkPos.h:13
Definition Dimension.h:86
Definition DividedPos2d.h:7
Definition HashedString.h:5
Definition IPreliminarySurfaceProvider.h:8
Definition LevelChunk.h:76
Definition Random.h:10
Definition StructureFeatureRegistry.h:19
Definition StructureFeature.h:23
MCAPI void postProcessStructureFeatures(::BlockSource &region, ::Random &random, uint seed, int chunkX, int chunkZ)
MCAPI void prepareStructureFeatureBlueprints(::Dimension &dimension, ::ChunkPos const &cp, ::BiomeSource const &biomeSource, ::IPreliminarySurfaceProvider const &preliminarySurfaceProvider)
MCAPI void postProcessStructures(::BlockSource &region, ::Random &, int chunkX, int chunkZ)
MCAPI void * $ctor(::Dimension &dimension)
MCAPI void * $ctor(::Dimension &dimension, ::std::unique_ptr<::StructureFeatureRegistry > structureFeatureRegistry)
MCAPI WorldGenerator(::Dimension &dimension)
static MCAPI void ** $vftableForChunkSource()
MCAPI void waitForStructures()
static MCAPI void ** $vftableForIPreliminarySurfaceProvider()
MCAPI bool _tryGenerateStructure(::br::worldgen::Structure const &structure, ::ChunkPos const &chunkPos, ::br::worldgen::ChunkStructureAccess &structureAccess)
MCAPI WorldGenerator(::Dimension &dimension, ::std::unique_ptr<::StructureFeatureRegistry > structureFeatureRegistry)
MCAPI void preProcessStructures(::Dimension &dimension, ::ChunkPos const &cp, ::BiomeSource const &biomeSource)
Definition ChunkAccessor.h:19
Definition StructureInstance.h:20
Definition buffer_span.h:6
Definition WorldGenerator.h:43
Definition ChunkStructureAccess.h:14
Definition Structure.h:24