LeviLamina
Loading...
Searching...
No Matches
Block.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4#include "mc/world/level/block/BlockLegacy.h"
5
6// auto generated inclusion list
7#include "mc/deps/core/utility/optional_ref.h"
8#include "mc/nbt/CompoundTag.h"
9#include "mc/world/level/ShapeType.h"
10#include "mc/world/level/block/CachedComponentData.h"
11#include "mc/world/level/block/components/BlockComponentDirectData.h"
12#include "mc/world/level/block/components/BlockComponentStorage.h"
13
14// auto generated forward declare list
15// clang-format off
16class AABB;
17class Actor;
18class BaseGameVersion;
19class BlockLegacy;
20class BlockPos;
21class BlockSource;
22class BlockState;
25class HashedString;
26class HitResult;
28class ItemActor;
29class ItemInstance;
30class ItemStackBase;
31class Player;
32class Random;
33class RenderParams;
34class Vec3;
35namespace mce { class Color; }
36// clang-format on
37
38class Block {
39public:
40 using BlockStateValueType = std::variant<int, float, bool, std::string>;
41 using BlockStatesType = std::vector<std::pair<std::string, BlockStateValueType>>;
42
43 LLNDAPI static optional_ref<Block const> tryGetFromRegistry(uint runtimeID);
44 LLNDAPI static optional_ref<Block const> tryGetFromRegistry(std::string_view name);
45 LLNDAPI static optional_ref<Block const> tryGetFromRegistry(std::string_view name, ushort legacyData);
46 LLNDAPI static optional_ref<Block const> tryGetFromRegistry(uint legacyBlockID, ushort legacyData);
47 LLNDAPI static optional_ref<Block const> tryGetFromRegistry(std::string_view name, BlockStatesType const& states);
48 LLNDAPI static optional_ref<Block const> tryGetFromRegistry(CompoundTag const& nbt);
49
50 [[nodiscard]] inline std::string const& getTypeName() const { return getLegacyBlock().getTypeName(); }
51
52 [[nodiscard]] inline short getBlockItemId() const { return getLegacyBlock().getBlockItemId(); }
53
54 [[nodiscard]] inline ushort getData() const { return mData; }
55
56 template <typename T>
57 std::optional<T> getState(uint64 id) const {
58 return mLegacyBlock->getState<T>(id, mData);
59 }
60
61 template <typename T>
62 std::optional<T> getState(BlockState const& state) const {
63 return mLegacyBlock->getState<T>(state, mData);
64 }
65
66 template <typename T>
67 optional_ref<Block const> setState(uint64 id, T value) const {
68 return mLegacyBlock->trySetState(id, value, mData);
69 }
70
71 template <typename T>
72 optional_ref<Block const> setState(BlockState const& state, T value) const {
73 return mLegacyBlock->trySetState(state, value, mData);
74 }
75
76public:
77 // member variables
78 // NOLINTBEGIN
79 ::ll::TypedStorage<8, 104, ::BlockComponentStorage> mComponents;
80 ::ll::TypedStorage<2, 2, ushort const> mData;
81 ::ll::TypedStorage<8, 8, ::gsl::not_null<::BlockLegacy*>> mLegacyBlock;
82 ::ll::TypedStorage<4, 8, ::CachedComponentData> mCachedComponentData;
83 ::ll::TypedStorage<8, 104, ::BlockComponentDirectData> mDirectData;
84 ::ll::TypedStorage<8, 24, ::std::vector<::HashedString>> mTags;
85 ::ll::TypedStorage<8, 24, ::CompoundTag> mSerializationId;
86 ::ll::TypedStorage<8, 8, uint64> mSerializationIdHash;
87 ::ll::TypedStorage<4, 4, uint> mSerializationIdHashForNetwork;
88 ::ll::TypedStorage<4, 4, uint> mNetworkId;
89 ::ll::TypedStorage<1, 1, bool> mHasRuntimeId;
90 // NOLINTEND
91
92public:
93 // prevent constructor by default
94 Block();
95
96public:
97 // virtual functions
98 // NOLINTBEGIN
99 // vIndex: 0
100 virtual ~Block() = default;
101 // NOLINTEND
102
103public:
104 // member functions
105 // NOLINTBEGIN
106 MCAPI Block(ushort data, ::gsl::not_null<::BlockLegacy*> oldBlock);
107
108 MCAPI Block(ushort data, ::gsl::not_null<::BlockLegacy*> oldBlock, ::CompoundTag serId, uint const& runId);
109
110 MCAPI bool _isSolid() const;
111
112 MCAPI void _queueForTickBasedOnComponentConfiguration(
113 ::BlockSource& region,
114 ::BlockPos const& pos,
115 ::Random& random,
116 bool placingBlock
117 ) const;
118
119 MCAPI void _removeFromTickingQueues(::BlockSource& region, ::BlockPos const& pos) const;
120
121 MCAPI ::ItemInstance asItemInstance(::BlockSource& region, ::BlockPos const& position, bool withData) const;
122
123 MCAPI bool breaksFallingBlocks(::BaseGameVersion version) const;
124
125 MCAPI ::std::string buildDescriptionName() const;
126
127 MCAPI void buildSerializationId(uint latestUpdaterVersion);
128
129 MCAPI ::std::string buildSerializationIdString() const;
130
131 MCAPI bool canProvideFullSupport(uchar face) const;
132
133 MCAPI bool canSurvive(::BlockSource& region, ::BlockPos const& pos) const;
134
135 MCAPI ::HitResult clip(::BlockPos const& pos, ::Vec3 const& A, ::Vec3 const& B, ::AABB const& aabb) const;
136
137 MCAPI ::HitResult clip(
138 ::BlockSource const& region,
139 ::BlockPos const& pos,
140 ::Vec3 const& A,
141 ::Vec3 const& B,
142 ::ShapeType shapeType,
144 ) const;
145
146 MCAPI uint computeRawSerializationIdHashForNetwork() const;
147
148 MCAPI ::Block const& copyState(::Block const& fromBlock, ::BlockState const& state) const;
149
150 MCAPI ::Block const& copyStates(::Block const& fromBlock) const;
151
152 MCAPI void executeItemEvent(
153 ::ItemStackBase& item,
154 ::std::string const& eventName,
155 ::BlockSource& region,
156 ::BlockPos const& pos,
157 ::Actor* actor
158 ) const;
159
160 MCAPI bool executeTrigger(::DefinitionTrigger const& trigger, ::RenderParams& params) const;
161
162 MCAPI void finalizeBlockComponentStorage();
163
164 MCAPI bool getCollisionShape(
165 ::AABB& outAABB,
166 ::IConstBlockSource const& region,
167 ::BlockPos const& pos,
169 ) const;
170
171 MCAPI ::std::string getDescriptionId() const;
172
173 MCAPI ::BlockLegacy const& getLegacyBlock() const;
174
175 MCAPI ::mce::Color getMapColor(::BlockSource& region, ::BlockPos const& pos) const;
176
177 MCAPI ::Block const& getStateFromLegacyData(ushort data) const;
178
179 MCAPI bool hasState(::BlockState const& stateType) const;
180
181 MCAPI bool hasTag(::HashedString const& tagName) const;
182
183 MCAPI bool isAir() const;
184
185 MCAPI bool isButtonBlock() const;
186
187 MCAPI bool isCropBlock() const;
188
189 MCAPI bool isDoorBlock() const;
190
191 MCFOLD bool isMotionBlockingBlock() const;
192
193 MCAPI bool isPartialBlock(::BlockSource const& region, ::BlockPos const& pos) const;
194
195 MCAPI bool isPreservingMediumWhenPlaced(::Block const& medium) const;
196
197 MCAPI bool isSlabBlock() const;
198
199 MCAPI bool isSolidBlockingBlock() const;
200
201 MCAPI bool isSolidBlockingBlockAndNotSignalSource() const;
202
203 MCAPI bool isTopPartialBlock(::BlockSource const& region, ::BlockPos const& pos) const;
204
205 MCAPI bool isValidAuxValue(int value) const;
206
207 MCAPI bool mayPlace(::BlockSource& region, ::BlockPos const& pos, uchar face) const;
208
209 MCAPI void neighborChanged(::BlockSource& region, ::BlockPos const& pos, ::BlockPos const& neighborPos) const;
210
211 MCAPI void onFallOn(::BlockSource& region, ::BlockPos const& pos, ::Actor& entity, float fallDistance) const;
212
213 MCAPI void onPlace(::BlockSource& region, ::BlockPos const& pos, ::Block const& previousBlock) const;
214
215 MCAPI void onStepOff(::Actor& entity, ::BlockPos const& pos) const;
216
217 MCAPI void onStepOn(::Actor& entity, ::BlockPos const& pos) const;
218
219 MCAPI void playerDestroy(::Player& player, ::BlockPos const& pos) const;
220
221 MCAPI ::ItemActor*
222 popResource(::BlockSource& region, ::BlockPos const& pos, ::ItemInstance const& itemInstance) const;
223
224 MCAPI void queuedTick(::BlockSource& region, ::BlockPos const& pos, ::Random& random) const;
225
226 MCAPI void randomTick(::BlockSource& region, ::BlockPos const& pos, ::Random& random) const;
227
228 MCAPI ::Block const& sanitizeFillBlock() const;
229
230 MCAPI bool shouldRandomTick() const;
231
232 MCAPI ::std::string toDebugString() const;
233
234 MCAPI bool use(::Player& player, ::BlockPos const& pos, uchar face, ::std::optional<::Vec3> hit) const;
235 // NOLINTEND
236
237public:
238 // static variables
239 // NOLINTBEGIN
240 MCAPI static ::std::string const& BLOCK_DESCRIPTION_PREFIX();
241 // NOLINTEND
242
243public:
244 // constructor thunks
245 // NOLINTBEGIN
246 MCAPI void* $ctor(ushort data, ::gsl::not_null<::BlockLegacy*> oldBlock);
247
248 MCAPI void* $ctor(ushort data, ::gsl::not_null<::BlockLegacy*> oldBlock, ::CompoundTag serId, uint const& runId);
249 // NOLINTEND
250
251public:
252 // vftables
253 // NOLINTBEGIN
254 MCNAPI static void** $vftable();
255 // NOLINTEND
256};
Definition AABB.h:18
Definition Actor.h:103
Definition BaseGameVersion.h:8
Definition BlockLegacy.h:86
Definition BlockPos.h:18
Definition BlockSource.h:67
Definition BlockState.h:13
Definition Block.h:38
static MCAPI void ** $vftable()
Definition CompoundTag.h:13
Definition DefinitionTrigger.h:11
Definition GetCollisionShapeInterface.h:13
Definition HashedString.h:5
Definition HitResult.h:19
Definition IConstBlockSource.h:24
Definition ItemActor.h:27
Definition ItemInstance.h:16
Definition ItemStackBase.h:35
Definition Player.h:120
Definition Random.h:11
Definition RenderParams.h:30
Definition Vec3.h:10
Definition optional_ref.h:10