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 BlockPlayerInteractEvent; }
24namespace BlockEvents { class BlockQueuedTickEvent; }
25namespace BlockEvents { class BlockRedstoneUpdateEvent; }
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 bool hasComparatorSignal() const /*override*/;
65
66 virtual int getComparatorSignal(::BlockSource& region, ::BlockPos const& pos, ::Block const& block, uchar dir) const
67 /*override*/;
68
69 virtual ::AABB getCollisionShape(
70 ::Block const& block,
72 ::BlockPos const& pos,
74 ) const /*override*/;
75
76 virtual ::AABB const&
77 getOutline(::Block const& block, ::IConstBlockSource const&, ::BlockPos const& pos, ::AABB& bufferValue) const
78 /*override*/;
79
80 virtual ::AABB const& getVisualShapeInWorld(
81 ::Block const& block,
83 ::BlockPos const& pos,
84 ::AABB& bufferAABB
85 ) const /*override*/;
86
87 virtual bool isInteractiveBlock() const /*override*/;
88
89 virtual void onRemove(::BlockSource& region, ::BlockPos const& pos) const /*override*/;
90
91 virtual bool canProvideSupport(::Block const& block, uchar face, ::BlockSupportType) const /*override*/;
92
93 virtual bool liquidCanFlowIntoFromDirection(
94 uchar flowIntoFacing,
95 ::std::function<::Block const&(::BlockPos const&)> const& getBlock,
96 ::BlockPos const& pos
97 ) const /*override*/;
98
99 virtual void _addHardCodedBlockComponents(::Experiments const&) /*override*/;
100
101 virtual ~ShelfBlock() /*override*/ = default;
102 // NOLINTEND
103
104public:
105 // member functions
106 // NOLINTBEGIN
107 MCAPI bool
108 _blockHasPoweredShelfType(::BlockSource const& region, ::BlockPos const& pos, ::ShelfBlock::PoweredType type) const;
109
110 MCAPI ::std::tuple<::ShelfBlockActor*, ::ShelfBlockActor*, ::ShelfBlockActor*>
111 _getPoweredShelfBlockActors(::BlockPos const& pos, ::BlockSource& region) const;
112
113 MCAPI ::std::tuple<::ShelfBlockActor*, ::ShelfBlockActor*, ::ShelfBlockActor*>
114 _getPoweredShelfBlockActorsForDoubleShelf(
115 ::BlockSource& region,
116 ::BlockPos const& shelfLeft,
117 ::BlockPos const& shelfRight
118 ) const;
119
120 MCAPI ::std::tuple<::ShelfBlockActor*, ::ShelfBlockActor*, ::ShelfBlockActor*>
121 _getPoweredShelfBlockActorsForTripleShelf(
122 ::BlockSource& region,
123 ::BlockPos const& shelfLeft,
124 ::BlockPos const& shelfCenter,
125 ::BlockPos const& shelfRight
126 ) const;
127
128 MCAPI ::ShelfBlock::SwapItemResult
129 _getSwapItemWithHandResult(::ShelfBlockActor& shelfActor, int hitSlot, ::Player const& player) const;
130
131 MCAPI bool _isMatchingPoweredShelfInMatchingDirection(
132 ::BlockSource const& region,
133 ::BlockPos const& pos,
134 ::BlockPos const& neighbor
135 ) const;
136
137 MCAPI void _onRedstoneUpdate(::BlockEvents::BlockRedstoneUpdateEvent& blockEvent) const;
138
139 MCAPI void _powerOnAndTryConnectNeighbors(::BlockSource& region, ::BlockPos const& pos) const;
140
141 MCAPI void
142 _setShelfData(::BlockSource& region, ::BlockPos const& pos, bool powered, ::ShelfBlock::PoweredType type) const;
143
144 MCAPI void
145 _swapItemWithHand(::ShelfBlockActor& shelfActor, int hitSlot, ::Player& player, ::BlockSource const& region) const;
146
147 MCAPI ::ShelfBlock::SwapItemResult _swapItemsWithHotbar(
148 ::ShelfBlockActor& shelfActor,
149 int shelfSlot,
150 ::Player& player,
151 int inventorySlot,
152 ::BlockSource const& region
153 ) const;
154
155 MCAPI bool _swapItemsWithPoweredShelf(::Player& player, ::BlockPos const& pos, ::BlockSource& region) const;
156
157 MCAPI bool _swapItemsWithUnpoweredShelf(
158 ::Player& player,
159 ::BlockPos const& pos,
160 ::BlockSource& region,
161 ::ShelfBlockActor& blockActor,
162 ::Vec3 const& blockHit,
163 uchar hitFace
164 ) const;
165
166 MCAPI void _unpowerAndDisconnectFromNeighbors(::BlockSource& region, ::BlockPos const& pos) const;
167
168 MCAPI void _updatePoweredShelf(::BlockSource& region, ::BlockPos const& pos, bool isPowered) const;
169
170 MCAPI void _validatePoweredShelfCurrentStateFromNeighbors(::BlockSource& region, ::BlockPos const& pos) const;
171
172 MCAPI void tick(::BlockEvents::BlockQueuedTickEvent& eventData) const;
173
174 MCAPI void use(::BlockEvents::BlockPlayerInteractEvent& eventData) const;
175 // NOLINTEND
176
177public:
178 // static functions
179 // NOLINTBEGIN
180 MCAPI static ::AABB const& _getShape(::BlockPos const& pos, ::Block const& block, ::AABB& bufferValue);
181
182#ifdef LL_PLAT_C
183 MCAPI static ::ShelfBlock::SlotState
184 getBlockSlotState(::BlockPos const& blockPos, ::Vec3 const& blockHit, uchar faceHit, ::BlockSource const& region);
185#endif
186 // NOLINTEND
187
188public:
189 // virtual function thunks
190 // NOLINTBEGIN
191 MCFOLD void $movedByPiston(::BlockSource& region, ::BlockPos const& pos) const;
192
193 MCAPI void $neighborChanged(::BlockSource& region, ::BlockPos const& pos, ::BlockPos const& neighborPos) const;
194
195 MCFOLD bool $hasComparatorSignal() const;
196
197 MCAPI int $getComparatorSignal(::BlockSource& region, ::BlockPos const& pos, ::Block const& block, uchar dir) const;
198
199 MCAPI ::AABB $getCollisionShape(
200 ::Block const& block,
201 ::IConstBlockSource const&,
202 ::BlockPos const& pos,
204 ) const;
205
206 MCFOLD ::AABB const&
207 $getOutline(::Block const& block, ::IConstBlockSource const&, ::BlockPos const& pos, ::AABB& bufferValue) const;
208
209 MCFOLD ::AABB const& $getVisualShapeInWorld(
210 ::Block const& block,
211 ::IConstBlockSource const&,
212 ::BlockPos const& pos,
213 ::AABB& bufferAABB
214 ) const;
215
216 MCFOLD bool $isInteractiveBlock() const;
217
218 MCAPI void $onRemove(::BlockSource& region, ::BlockPos const& pos) const;
219
220 MCAPI bool $canProvideSupport(::Block const& block, uchar face, ::BlockSupportType) const;
221
222 MCAPI bool $liquidCanFlowIntoFromDirection(
223 uchar flowIntoFacing,
224 ::std::function<::Block const&(::BlockPos const&)> const& getBlock,
225 ::BlockPos const& pos
226 ) const;
227
228 MCAPI void $_addHardCodedBlockComponents(::Experiments const&);
229
230
231 // NOLINTEND
232
233public:
234 // vftables
235 // NOLINTBEGIN
236 MCAPI static void** $vftable();
237 // NOLINTEND
238};
Definition AABB.h:18
Definition BlockPlayerInteractEvent.h:17
Definition BlockQueuedTickEvent.h:16
Definition BlockRedstoneUpdateEvent.h:15
Definition BlockPos.h:19
Definition BlockSource.h:71
Definition Block.h:43
Definition Experiments.h:14
Definition GetCollisionShapeInterface.h:13
Definition IConstBlockSource.h:25
Definition Player.h:129
Definition ShelfBlockActor.h:25
Definition ShelfBlock.h:28
Definition Vec3.h:10
Definition optional_ref.h:10