LeviLamina
Loading...
Searching...
No Matches
ShelfBlock.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/core/utility/optional_ref.h"
7#include "mc/world/level/block/ActorBlockBase.h"
8#include "mc/world/level/block/BlockSupportType.h"
9#include "mc/world/level/block/BlockType.h"
10
11// auto generated forward declare list
12// clang-format off
13class AABB;
14class Block;
15class BlockPos;
16class BlockSource;
17class Experiments;
20class Player;
21class ShelfBlockActor;
22class Vec3;
23namespace BlockEvents { class BlockPlaceEvent; }
24namespace BlockEvents { class BlockPlayerInteractEvent; }
25namespace BlockEvents { class BlockQueuedTickEvent; }
26// clang-format on
27
28class ShelfBlock : public ::ActorBlock {
29public:
30 // ShelfBlock inner types define
31 enum class NeighborDirection : uchar {
32 Right = 0,
33 Left = 1,
34 };
35
36 enum class PoweredType : int {
37 Unconnected = 0,
38 Right = 1,
39 Center = 2,
40 Left = 3,
41 Count = 4,
42 };
43
44 enum class SlotState : uchar {
45 Free = 0,
46 Occupied = 1,
47 Invalid = 2,
48 };
49
50 enum class SwapItemResult : int {
51 NoItemsTransferred = 0,
52 SingleItemTransfer = 1,
53 TwoItemsSwapped = 2,
54 };
55
56public:
57 // virtual functions
58 // NOLINTBEGIN
59 virtual void movedByPiston(::BlockSource& region, ::BlockPos const& pos) const /*override*/;
60
61 virtual void neighborChanged(::BlockSource& region, ::BlockPos const& pos, ::BlockPos const& neighborPos) const
62 /*override*/;
63
64 virtual void setupRedstoneComponent(::BlockSource& region, ::BlockPos const& pos) const /*override*/;
65
66 virtual void onRedstoneUpdate(::BlockSource& region, ::BlockPos const& pos, int strength, bool isFirstTime) const
67 /*override*/;
68
69 virtual bool hasComparatorSignal() const /*override*/;
70
71 virtual int getComparatorSignal(::BlockSource& region, ::BlockPos const& pos, ::Block const& block, uchar dir) const
72 /*override*/;
73
74 virtual ::AABB getCollisionShape(
75 ::Block const& block,
77 ::BlockPos const& pos,
79 ) const /*override*/;
80
81 virtual ::AABB const&
82 getOutline(::Block const& block, ::IConstBlockSource const&, ::BlockPos const& pos, ::AABB& bufferValue) const
83 /*override*/;
84
85 virtual ::AABB const& getVisualShapeInWorld(
86 ::Block const& block,
88 ::BlockPos const& pos,
89 ::AABB& bufferAABB
90 ) const /*override*/;
91
92 virtual bool isInteractiveBlock() const /*override*/;
93
94 virtual void onRemove(::BlockSource& region, ::BlockPos const& pos) const /*override*/;
95
96 virtual bool canProvideSupport(::Block const& block, uchar face, ::BlockSupportType) const /*override*/;
97
98 virtual bool liquidCanFlowIntoFromDirection(
99 uchar flowIntoFacing,
100 ::std::function<::Block const&(::BlockPos const&)> const& getBlock,
101 ::BlockPos const& pos
102 ) const /*override*/;
103
104 virtual void _addHardCodedBlockComponents(::Experiments const&) /*override*/;
105
106 virtual ~ShelfBlock() /*override*/ = default;
107 // NOLINTEND
108
109public:
110 // member functions
111 // NOLINTBEGIN
112 MCAPI bool
113 _blockHasPoweredShelfType(::BlockSource const& region, ::BlockPos const& pos, ::ShelfBlock::PoweredType type) const;
114
115 MCAPI ::std::tuple<::ShelfBlockActor*, ::ShelfBlockActor*, ::ShelfBlockActor*>
116 _getPoweredShelfBlockActors(::BlockPos const& pos, ::BlockSource& region) const;
117
118 MCAPI ::std::tuple<::ShelfBlockActor*, ::ShelfBlockActor*, ::ShelfBlockActor*>
119 _getPoweredShelfBlockActorsForDoubleShelf(
120 ::BlockSource& region,
121 ::BlockPos const& shelfLeft,
122 ::BlockPos const& shelfRight
123 ) const;
124
125 MCAPI ::std::tuple<::ShelfBlockActor*, ::ShelfBlockActor*, ::ShelfBlockActor*>
126 _getPoweredShelfBlockActorsForTripleShelf(
127 ::BlockSource& region,
128 ::BlockPos const& shelfLeft,
129 ::BlockPos const& shelfCenter,
130 ::BlockPos const& shelfRight
131 ) const;
132
133 MCAPI ::ShelfBlock::SwapItemResult
134 _getSwapItemWithHandResult(::ShelfBlockActor& shelfActor, int hitSlot, ::Player const& player) const;
135
136 MCAPI bool _isMatchingPoweredShelfInMatchingDirection(
137 ::BlockSource const& region,
138 ::BlockPos const& pos,
139 ::BlockPos const& neighbor
140 ) const;
141
142 MCAPI void _powerOnAndTryConnectNeighbors(::BlockSource& region, ::BlockPos const& pos) const;
143
144 MCAPI void
145 _setShelfData(::BlockSource& region, ::BlockPos const& pos, bool powered, ::ShelfBlock::PoweredType type) const;
146
147 MCAPI void
148 _swapItemWithHand(::ShelfBlockActor& shelfActor, int hitSlot, ::Player& player, ::BlockSource const& region) const;
149
150 MCAPI ::ShelfBlock::SwapItemResult _swapItemsWithHotbar(
151 ::ShelfBlockActor& shelfActor,
152 int shelfSlot,
153 ::Player& player,
154 int inventorySlot,
155 ::BlockSource const& region
156 ) const;
157
158 MCAPI bool _swapItemsWithPoweredShelf(::Player& player, ::BlockPos const& pos, ::BlockSource& region) const;
159
160 MCAPI bool _swapItemsWithUnpoweredShelf(
161 ::Player& player,
162 ::BlockPos const& pos,
163 ::BlockSource& region,
164 ::ShelfBlockActor& blockActor,
165 ::Vec3 const& blockHit,
166 uchar hitFace
167 ) const;
168
169 MCAPI void _unpowerAndDisconnectFromNeighbors(::BlockSource& region, ::BlockPos const& pos) const;
170
171 MCAPI void _updatePoweredShelf(::BlockSource& region, ::BlockPos const& pos, bool isPowered) const;
172
173 MCAPI void _validatePoweredShelfCurrentStateFromNeighbors(::BlockSource& region, ::BlockPos const& pos) const;
174
175 MCFOLD void onPlace(::BlockEvents::BlockPlaceEvent& eventData) const;
176
177 MCAPI void tick(::BlockEvents::BlockQueuedTickEvent& eventData) const;
178
179 MCAPI void use(::BlockEvents::BlockPlayerInteractEvent& eventData) const;
180 // NOLINTEND
181
182public:
183 // static functions
184 // NOLINTBEGIN
185 MCAPI static ::AABB const& _getShape(::BlockPos const& pos, ::Block const& block, ::AABB& bufferValue);
186
187 MCAPI_C static ::ShelfBlock::SlotState
188 getBlockSlotState(::BlockPos const& blockPos, ::Vec3 const& blockHit, uchar faceHit, ::BlockSource const& region);
189 // NOLINTEND
190
191public:
192 // virtual function thunks
193 // NOLINTBEGIN
194 MCFOLD void $movedByPiston(::BlockSource& region, ::BlockPos const& pos) const;
195
196 MCAPI void $neighborChanged(::BlockSource& region, ::BlockPos const& pos, ::BlockPos const& neighborPos) const;
197
198 MCFOLD void $setupRedstoneComponent(::BlockSource& region, ::BlockPos const& pos) const;
199
200 MCAPI void $onRedstoneUpdate(::BlockSource& region, ::BlockPos const& pos, int strength, bool isFirstTime) const;
201
202 MCFOLD bool $hasComparatorSignal() const;
203
204 MCAPI int $getComparatorSignal(::BlockSource& region, ::BlockPos const& pos, ::Block const& block, uchar dir) const;
205
206 MCAPI ::AABB $getCollisionShape(
207 ::Block const& block,
208 ::IConstBlockSource const&,
209 ::BlockPos const& pos,
211 ) const;
212
213 MCFOLD ::AABB const&
214 $getOutline(::Block const& block, ::IConstBlockSource const&, ::BlockPos const& pos, ::AABB& bufferValue) const;
215
216 MCFOLD ::AABB const& $getVisualShapeInWorld(
217 ::Block const& block,
218 ::IConstBlockSource const&,
219 ::BlockPos const& pos,
220 ::AABB& bufferAABB
221 ) const;
222
223 MCFOLD bool $isInteractiveBlock() const;
224
225 MCAPI void $onRemove(::BlockSource& region, ::BlockPos const& pos) const;
226
227 MCAPI bool $canProvideSupport(::Block const& block, uchar face, ::BlockSupportType) const;
228
229 MCAPI bool $liquidCanFlowIntoFromDirection(
230 uchar flowIntoFacing,
231 ::std::function<::Block const&(::BlockPos const&)> const& getBlock,
232 ::BlockPos const& pos
233 ) const;
234
235 MCAPI void $_addHardCodedBlockComponents(::Experiments const&);
236
237
238 // NOLINTEND
239
240public:
241 // vftables
242 // NOLINTBEGIN
243 MCAPI static void** $vftable();
244 // NOLINTEND
245};
Definition AABB.h:18
Definition BlockPlaceEvent.h:16
Definition BlockPlayerInteractEvent.h:17
Definition BlockQueuedTickEvent.h:16
Definition BlockPos.h:19
Definition BlockSource.h:68
Definition Block.h:43
Definition Experiments.h:14
Definition GetCollisionShapeInterface.h:13
Definition IConstBlockSource.h:25
Definition Player.h:125
Definition ShelfBlockActor.h:25
Definition ShelfBlock.h:28
Definition Vec3.h:10
Definition optional_ref.h:10