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 void _queueForTickBasedOnComponentConfiguration(
111 ::BlockSource& region,
112 ::BlockPos const& pos,
113 ::Random& random,
114 bool placingBlock
115 ) const;
116
117 MCAPI void _removeFromTickingQueues(::BlockSource& region, ::BlockPos const& pos) const;
118
119 MCAPI ::ItemInstance asItemInstance(::BlockSource& region, ::BlockPos const& position, bool withData) const;
120
121 MCAPI bool breaksFallingBlocks(::BaseGameVersion version) const;
122
123 MCAPI ::std::string buildDescriptionName() const;
124
125 MCAPI void buildSerializationId(uint latestUpdaterVersion);
126
127 MCAPI ::std::string buildSerializationIdString() const;
128
129 MCAPI bool canProvideFullSupport(uchar face) const;
130
131 MCAPI bool canSurvive(::BlockSource& region, ::BlockPos const& pos) const;
132
133 MCAPI ::HitResult clip(::BlockPos const& pos, ::Vec3 const& A, ::Vec3 const& B, ::AABB const& aabb) const;
134
135 MCAPI ::HitResult clip(
136 ::BlockSource const& region,
137 ::BlockPos const& pos,
138 ::Vec3 const& A,
139 ::Vec3 const& B,
140 ::ShapeType shapeType,
142 ) const;
143
144 MCAPI uint computeRawSerializationIdHashForNetwork() const;
145
146 MCAPI ::Block const& copyState(::Block const& fromBlock, ::BlockState const& state) const;
147
148 MCAPI void executeItemEvent(
149 ::ItemStackBase& item,
150 ::std::string const& eventName,
151 ::BlockSource& region,
152 ::BlockPos const& pos,
153 ::Actor* actor
154 ) const;
155
156 MCAPI bool executeTrigger(::DefinitionTrigger const& trigger, ::RenderParams& params) const;
157
158 MCAPI bool getCollisionShape(
159 ::AABB& outAABB,
160 ::IConstBlockSource const& region,
161 ::BlockPos const& pos,
163 ) const;
164
165 MCAPI ::std::string getDescriptionId() const;
166
167 MCAPI ::BlockLegacy const& getLegacyBlock() const;
168
169 MCAPI ::mce::Color getMapColor(::BlockSource& region, ::BlockPos const& pos) const;
170
171 MCAPI ::Block const& getStateFromLegacyData(ushort data) const;
172
173 MCAPI bool hasState(::BlockState const& stateType) const;
174
175 MCAPI bool hasTag(::HashedString const& tagName) const;
176
177 MCAPI bool isAir() const;
178
179 MCAPI bool isButtonBlock() const;
180
181 MCAPI bool isCropBlock() const;
182
183 MCAPI bool isDoorBlock() const;
184
185 MCFOLD bool isMotionBlockingBlock() const;
186
187 MCAPI bool isPartialBlock(::BlockSource const& region, ::BlockPos const& pos) const;
188
189 MCAPI bool isPreservingMediumWhenPlaced(::Block const& medium) const;
190
191 MCAPI bool isSlabBlock() const;
192
193 MCAPI bool isSolidBlockingBlock() const;
194
195 MCAPI bool isSolidBlockingBlockAndNotSignalSource() const;
196
197 MCAPI bool isTopPartialBlock(::BlockSource const& region, ::BlockPos const& pos) const;
198
199 MCAPI bool isValidAuxValue(int value) const;
200
201 MCAPI bool mayPlace(::BlockSource& region, ::BlockPos const& pos, uchar face) const;
202
203 MCAPI void neighborChanged(::BlockSource& region, ::BlockPos const& pos, ::BlockPos const& neighborPos) const;
204
205 MCAPI void onFallOn(::BlockSource& region, ::BlockPos const& pos, ::Actor& entity, float fallDistance) const;
206
207 MCAPI void onPlace(::BlockSource& region, ::BlockPos const& pos, ::Block const& previousBlock) const;
208
209 MCAPI void onStepOff(::Actor& entity, ::BlockPos const& pos) const;
210
211 MCAPI void onStepOn(::Actor& entity, ::BlockPos const& pos) const;
212
213 MCAPI void playerDestroy(::Player& player, ::BlockPos const& pos) const;
214
215 MCAPI ::ItemActor*
216 popResource(::BlockSource& region, ::BlockPos const& pos, ::ItemInstance const& itemInstance) const;
217
218 MCAPI void queuedTick(::BlockSource& region, ::BlockPos const& pos, ::Random& random) const;
219
220 MCAPI void randomTick(::BlockSource& region, ::BlockPos const& pos, ::Random& random) const;
221
222 MCAPI ::Block const& sanitizeFillBlock() const;
223
224 MCAPI bool shouldRandomTick() const;
225
226 MCAPI ::std::string toDebugString() const;
227
228 MCAPI bool use(::Player& player, ::BlockPos const& pos, uchar face, ::std::optional<::Vec3> hit) const;
229 // NOLINTEND
230
231public:
232 // static variables
233 // NOLINTBEGIN
234 MCAPI static ::std::string const& BLOCK_DESCRIPTION_PREFIX();
235 // NOLINTEND
236
237public:
238 // constructor thunks
239 // NOLINTBEGIN
240 MCAPI void* $ctor(ushort data, ::gsl::not_null<::BlockLegacy*> oldBlock);
241
242 MCAPI void* $ctor(ushort data, ::gsl::not_null<::BlockLegacy*> oldBlock, ::CompoundTag serId, uint const& runId);
243 // NOLINTEND
244
245public:
246 // vftables
247 // NOLINTBEGIN
248 MCNAPI static void** $vftable();
249 // NOLINTEND
250};
Definition AABB.h:18
Definition Actor.h:103
Definition BaseGameVersion.h:8
Definition BlockLegacy.h:88
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:119
Definition Random.h:11
Definition RenderParams.h:30
Definition Vec3.h:10
Definition optional_ref.h:10