LeviLamina
Loading...
Searching...
No Matches
BlockGraphics.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/client/renderer/texture/IsotropicFaceData.h"
7#include "mc/common/WeakPtr.h"
8#include "mc/world/level/block/BlockRenderLayer.h"
9#include "mc/world/level/block/BlockShape.h"
10#include "mc/world/phys/AABB.h"
11
12// auto generated forward declare list
13// clang-format off
15class Block;
16class BlockPos;
17class BlockSource;
18class BlockType;
19class Experiments;
20class HashedString;
23class SemVersion;
25class Vec3;
26struct TextureItem;
28namespace Bedrock::Threading { class Mutex; }
29namespace BlockGeometry { struct Model; }
30namespace BlockTessellationFallbackUtils { struct TessellationConfigInfo; }
31namespace Json { class Value; }
32namespace Json { class ValueIterator; }
33// clang-format on
34
35class BlockGraphics {
36public:
37 // BlockGraphics inner types declare
38 // clang-format off
39 struct ConstructorToken;
40 // clang-format on
41
42 // BlockGraphics inner types define
43 struct ConstructorToken {};
44
45 using BlockDataValuesMap = ::std::unordered_map<::HashedString, ::std::vector<::Json::Value>>;
46
47 using BlockTessellationInfoMap =
48 ::std::unordered_map<::HashedString, ::BlockTessellationFallbackUtils::TessellationConfigInfo>;
49
50public:
51 // member variables
52 // NOLINTBEGIN
53 ::ll::TypedStorage<8, 8, ::Block const*> mBlock;
54 ::ll::TypedStorage<4, 4, ::BlockShape> mBlockShape;
55 ::ll::TypedStorage<4, 4, float> mAmbientOcclusionExponent;
56 ::ll::TypedStorage<1, 1, bool> mFancy;
57 ::ll::TypedStorage<1, 1, bool> mAllowSame;
58 ::ll::TypedStorage<1, 1, ::BlockRenderLayer> mRenderLayer;
59 ::ll::TypedStorage<1, 1, ::IsotropicFaceData> mIsotropicFaceData;
60 ::ll::TypedStorage<8, 32, ::std::string> mSoundType;
61 ::ll::TypedStorage<4, 24, ::AABB> mVisualShape;
62 ::ll::TypedStorage<8, 24, ::std::vector<::TextureItem>> mTextureItems;
63 ::ll::TypedStorage<8, 8, uint64> mIconTextureIndex;
64 // NOLINTEND
65
66public:
67 // prevent constructor by default
68 BlockGraphics();
69
70public:
71 // virtual functions
72 // NOLINTBEGIN
73 virtual ~BlockGraphics() = default;
74
75 virtual ::BlockRenderLayer getRenderLayer(::BlockSource& region, ::BlockPos const& pos) const;
76
77 virtual int getColor(int auxData) const;
78
79 virtual int getColor(::BlockSource& region, ::BlockPos const& pos) const;
80
81 virtual bool isSeasonTinted(::BlockSource& region, ::BlockPos const& p) const;
82
83 virtual void onGraphicsModeChanged(bool fancy, bool fancyBubbles);
84
85 virtual int getExtraRenderLayers();
86
87 virtual ::TextureUVCoordinateSet const& getCarriedTexture(uint64 textureSlot, int blockVariant) const;
88
89 virtual void setVisualShape(::AABB const& shape);
90
91 virtual void setVisualShape(::Vec3 const& min, ::Vec3 const& max);
92 // NOLINTEND
93
94public:
95 // member functions
96 // NOLINTBEGIN
97 MCAPI explicit BlockGraphics(::std::string const& nameId);
98
99 MCAPI void _logBlockTextureError(::fmt::v11::fstring<char const*> const& error) const;
100
101 MCFOLD ::BlockRenderLayer getRenderLayer() const;
102
103 MCAPI ::TextureUVCoordinateSet const& getTexture(uint64 textureSlot, ::Block const& block) const;
104
105 MCAPI ::TextureUVCoordinateSet const& getTexture(uint64 textureSlot, int blockVariant) const;
106
107 MCAPI ::TextureUVCoordinateSet const& getTexture(::BlockPos const& p, uint64 textureSlot, int blockVariant) const;
108
109 MCAPI ::TextureUVCoordinateSet const&
110 getTexture(::BlockPos const& pos, uint64 textureSlot, ::Block const& block) const;
111
112 MCAPI ::std::vector<::TextureUVCoordinateSet> const&
113 getTextureCarriedVariations(uint64 textureSlot, int blockVariant) const;
114
115 MCAPI ::std::vector<::TextureUVCoordinateSet> const&
116 getTextureDefaultVariations(uint64 textureSlot, int blockVariant) const;
117
118 MCAPI bool isFull() const;
119
120 MCAPI bool isFullAndOpaque() const;
121
122 MCAPI ::BlockGraphics& setCarriedTextureItem(
123 ::std::string const& nameUp,
124 ::std::string const& nameDown,
125 ::std::string const& nameNorth,
126 ::std::string const& nameSouth,
127 ::std::string const& nameWest,
128 ::std::string const& nameEast
129 );
130
131 MCAPI void setDefaultCarriedTextures();
132
133 MCAPI ::BlockGraphics& setTextureItem(
134 ::std::string const& nameUp,
135 ::std::string const& nameDown,
136 ::std::string const& nameNorth,
137 ::std::string const& nameSouth,
138 ::std::string const& nameWest,
139 ::std::string const& nameEast
140 );
141 // NOLINTEND
142
143public:
144 // static functions
145 // NOLINTBEGIN
146 MCAPI static void _extractComplexAliasBlockData(
147 ::HashedString const& blockName,
148 ::Json::Value const& member,
149 ::std::unordered_map<::HashedString, ::std::vector<::Json::Value>>& output,
150 ::std::vector<::WeakPtr<::BlockType>>& blockTypes
151 );
152
153 MCAPI static void _initBlockModels(::ResourcePackManager& packManager);
154
155 MCAPI static ::BlockGraphics* createBlockGraphics(::HashedString const& name, ::BlockShape defaultBlockShape);
156
157 MCAPI static void detectAndRegisterTessellationFallbacks(
158 ::std::unordered_map<::HashedString, ::BlockTessellationFallbackUtils::TessellationConfigInfo>&
159 blockTessellationInfoMap
160 );
161
162 MCAPI static ::std::vector<::WeakPtr<::BlockType>> extractBlockDataValues(
163 ::Json::ValueIterator const& memberIterator,
164 ::std::unordered_map<::HashedString, ::std::vector<::Json::Value>>& output,
165 ::SemVersion const& formatVersion
166 );
167
168 MCAPI static void extractBlockDataValuesFromFileContents(
169 ::Experiments const& experiments,
170 ::std::vector<::LoadedResourceData> const& contents,
171 ::std::unordered_map<::HashedString, ::std::vector<::Json::Value>>& blockDataValuesMap,
172 ::std::unordered_map<::HashedString, ::BlockTessellationFallbackUtils::TessellationConfigInfo>&
173 blockTessellationInfoMap
174 );
175
176 MCAPI static ::BlockGraphics const* getForBlock(::Block const& block);
177
178 MCAPI static ::TextureAtlasItem const& getTextureItem(
179 ::std::string const& name,
180 ::std::weak_ptr<::AtlasItemManager> terrainTextureAtlas,
181 ::std::unordered_map<::std::string, ::TextureAtlasItem>& complexTextureItems
182 );
183
184 MCAPI static ::TextureUVCoordinateSet
185 getTextureUVCoordinateSet(::std::string const& name, int blockVariant, int textureVariant);
186
187 MCAPI static bool hasOldTessellationFallback(::Block const& block);
188
189 MCAPI static void initBlocks(::ResourcePackManager& packManager, ::Experiments const& experiments);
190
191 MCAPI static bool isFullAndOpaque(::Block const& block);
192
193 MCAPI static ::SemVersion loadBlockDataFormatVersion(::Json::Value const& root);
194
195 MCAPI static ::BlockGraphics& registerBlockGraphics(
196 ::std::unordered_map<::HashedString, ::std::vector<::Json::Value>>& blockDataValuesMap,
197 ::HashedString const& name,
198 ::BlockShape defaultBlockShape
199 );
200
201 MCAPI static void
202 registerLooseBlockGraphics(::std::unordered_map<::HashedString, ::std::vector<::Json::Value>>& blockDataValuesMap);
203
204 MCAPI static bool setBlockShape(::BlockGraphics& block, ::Json::Value const& blockShapeData);
205
206 MCAPI static bool setCarriedTextures(::BlockGraphics& block, ::Json::Value const& textureData);
207
208 MCAPI static bool setTextures(::BlockGraphics& block, ::Json::Value const& textureData);
209
210 MCAPI static void teardownBlocks();
211 // NOLINTEND
212
213public:
214 // static variables
215 // NOLINTBEGIN
216 MCAPI static ::std::string const& NORMAL_SOUND();
217
218 MCAPI static ::std::unordered_map<::std::string, ::BlockGraphics*>& mBlockLookupMap();
219
220 MCAPI static ::Bedrock::Threading::Mutex& mBlockModelAccess();
221
222 MCAPI static ::std::unordered_map<uint, ::BlockGraphics*>& mBlocks();
223
224 MCAPI static ::std::unique_ptr<::BlockGraphics>& mDummyBlock();
225
226 MCAPI static bool& mInitialized();
227
228 MCAPI static ::std::map<::std::string, ::std::unique_ptr<::BlockGeometry::Model>>& mModels();
229
230 MCAPI static ::std::vector<::std::unique_ptr<::BlockGraphics>>& mOwnedBlocks();
231
232 MCAPI static ::std::weak_ptr<::AtlasItemManager>& mTerrainTextureAtlas();
233
234 MCAPI static ::std::unordered_set<uint>& mVanillaBlocksWithFallbackToOldTessellation();
235
236 MCAPI static ::std::unordered_map<::std::string, ::TextureAtlasItem>& sComplexTextureItems();
237 // NOLINTEND
238
239public:
240 // constructor thunks
241 // NOLINTBEGIN
242 MCAPI void* $ctor(::std::string const& nameId);
243 // NOLINTEND
244
245public:
246 // virtual function thunks
247 // NOLINTBEGIN
248 MCFOLD ::BlockRenderLayer $getRenderLayer(::BlockSource& region, ::BlockPos const& pos) const;
249
250 MCFOLD int $getColor(int auxData) const;
251
252 MCFOLD int $getColor(::BlockSource& region, ::BlockPos const& pos) const;
253
254 MCFOLD bool $isSeasonTinted(::BlockSource& region, ::BlockPos const& p) const;
255
256 MCAPI void $onGraphicsModeChanged(bool fancy, bool fancyBubbles);
257
258 MCFOLD int $getExtraRenderLayers();
259
260 MCAPI ::TextureUVCoordinateSet const& $getCarriedTexture(uint64 textureSlot, int blockVariant) const;
261
262 MCAPI void $setVisualShape(::AABB const& shape);
263
264 MCAPI void $setVisualShape(::Vec3 const& min, ::Vec3 const& max);
265 // NOLINTEND
266
267public:
268 // vftables
269 // NOLINTBEGIN
270 MCNAPI static void** $vftable();
271 // NOLINTEND
272};
Definition AtlasItemManager.h:5
Definition Mutex.h:10
Definition BlockGraphics.h:5
static MCAPI void ** $vftable()
Definition BlockPos.h:19
Definition BlockSource.h:71
Definition BlockType.h:84
Definition Block.h:43
Definition Experiments.h:14
Definition HashedString.h:5
Definition ValueIterator.h:16
Definition Value.h:16
Definition LoadedResourceData.h:5
Definition ResourcePackManager.h:30
Definition SemVersion.h:15
Definition TextureAtlasItem.h:5
Definition Vec3.h:10
Definition Model.h:7
Definition BlockGraphics.h:13
Definition TessellationConfigInfo.h:7
Definition TextureItem.h:5
Definition TextureUVCoordinateSet.h:5