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