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