LeviLamina
Loading...
Searching...
No Matches
Container.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4#include "mc/safety/RedactableString.h"
5#include "mc/world/ContainerIterator.h"
6#include "mc/world/ContainerOwner.h"
7
8// auto generated inclusion list
9#include "mc/deps/core/utility/pub_sub/Connector.h"
10#include "mc/deps/shared_types/legacy/ContainerType.h"
11#include "mc/safety/RedactableString.h"
12#include "mc/util/BidirectionalUnorderedMap.h"
13#include "mc/world/ContainerOwner.h"
14#include "mc/world/TypedRuntimeId.h"
15
16// auto generated forward declare list
17// clang-format off
18class Actor;
19class BlockSource;
20class CompoundTag;
24class ItemDescriptor;
25class ItemStack;
26class Random;
27class Vec3;
29// clang-format on
30
31class Container {
32public:
33 // Container inner types declare
34 // clang-format off
35 struct PublisherWrapper;
36 // clang-format on
37
38 // Container inner types define
40 public:
41 // member variables
42 // NOLINTBEGIN
44 // NOLINTEND
45
46 public:
47 // prevent constructor by default
48 PublisherWrapper& operator=(PublisherWrapper const&);
51
52 public:
53 // member functions
54 // NOLINTBEGIN
56 // NOLINTEND
57
58 public:
59 // destructor thunk
60 // NOLINTBEGIN
61 MCNAPI void $dtor();
62 // NOLINTEND
63 };
64
65 using ItemStackNetIdChangedCallback = ::std::function<void(int, ::ItemStack const&)>;
66
67public:
68 [[nodiscard]] std::string const& getTypeName() const { return containerTypeMap().at(mContainerType); }
69
70 LLNDAPI optional_ref<ItemStack> getItemNonConst(int index);
71
72 [[nodiscard]] ItemStack& operator[](int index) { return this->getItemNonConst(index); }
73
74 [[nodiscard]] ItemStack const& operator[](int index) const { return this->getItem(index); }
75
76 using TransactionContext = std::function<void(::Container&, int, ::ItemStack const&, ::ItemStack const&)>;
77
78public:
79 using Iterator = ContainerIterator<Container>;
80 using ConstIterator = ContainerIterator<Container const>;
81
82 using ReverseIterator = std::reverse_iterator<Iterator>;
83 using ConstReverseIterator = std::reverse_iterator<ConstIterator>;
84
85 [[nodiscard]] constexpr Iterator begin() noexcept { return {this, 0}; }
86 [[nodiscard]] constexpr ConstIterator cbegin() const noexcept { return {this, 0}; }
87 [[nodiscard]] constexpr Iterator end() noexcept { return {this, getContainerSize()}; }
88 [[nodiscard]] constexpr ConstIterator cend() const noexcept { return {this, getContainerSize()}; }
89
90 [[nodiscard]] constexpr ReverseIterator rbegin() noexcept { return ReverseIterator{end()}; }
91 [[nodiscard]] constexpr ConstReverseIterator crbegin() const noexcept { return ConstReverseIterator{cend()}; }
92 [[nodiscard]] constexpr ReverseIterator rend() noexcept { return ReverseIterator{begin()}; }
93 [[nodiscard]] constexpr ConstReverseIterator crend() const noexcept { return ConstReverseIterator{cbegin()}; }
94
95public:
96 // member variables
97 // NOLINTBEGIN
98 ::SharedTypes::Legacy::ContainerType mContainerType;
99 ::SharedTypes::Legacy::ContainerType mGameplayContainerType;
100 ::std::unordered_set<::ContainerContentChangeListener*> mContentChangeListeners;
101 ::std::unordered_set<::ContainerSizeChangeListener*> mSizeChangeListeners;
102 ::std::unordered_set<::ContainerCloseListener*> mCloseListeners;
103 ::Container::PublisherWrapper mRemovedPublisher;
104 ::std::deque<TransactionContext> mTransactionContextStack;
106 bool mCustomName;
107 ::ContainerOwner mContainerOwner;
108 ::ContainerRuntimeId mContainerRuntimeId;
109 // NOLINTEND
110
111public:
112 // prevent constructor by default
113 Container();
114
115public:
116 // virtual functions
117 // NOLINTBEGIN
118 // vIndex: 0
119 virtual ~Container();
120
121 // vIndex: 1
122 virtual void init();
123
124 // vIndex: 2
125 virtual void serverInitItemStackIds(int, int, ::std::function<void(int, ::ItemStack const&)>) = 0;
126
127 // vIndex: 3
128 virtual void addContentChangeListener(::ContainerContentChangeListener* listener);
129
130 // vIndex: 4
131 virtual void removeContentChangeListener(::ContainerContentChangeListener* listener);
132
133 // vIndex: 5
134 virtual ::Bedrock::PubSub::Connector<void()>* getContainerRemovedConnector();
135
136 // vIndex: 6
137 virtual bool hasRemovedSubscribers() const;
138
139 // vIndex: 7
140 virtual ::ItemStack const& getItem(int) const = 0;
141
142 // vIndex: 8
143 virtual bool hasRoomForItem(::ItemStack const& item) const;
144
145 // vIndex: 9
146 virtual bool addItem(::ItemStack& item);
147
148 // vIndex: 10
149 virtual bool addItemWithForceBalance(::ItemStack& item);
150
151 // vIndex: 11
152 virtual bool addItemToFirstEmptySlot(::ItemStack const& item);
153
154 // vIndex: 12
155 virtual void setItem(int modelSlot, ::ItemStack const& item) = 0;
156
157 // vIndex: 13
158 virtual void setItemWithForceBalance(int slot, ::ItemStack const& item, bool forceBalanced);
159
160 // vIndex: 14
161 virtual void removeItem(int slot, int count);
162
163 // vIndex: 15
164 virtual void removeAllItems();
165
166 // vIndex: 16
167 virtual void removeAllItemsWithForceBalance();
168
169 // vIndex: 17
170 virtual void containerRemoved();
171
172 // vIndex: 18
173 virtual void dropSlotContent(::BlockSource& region, ::Vec3 const& pos, bool randomizeDrop, int slot);
174
175 // vIndex: 19
176 virtual void dropContents(::BlockSource& region, ::Vec3 const& pos, bool randomizeDrop);
177
178 // vIndex: 20
179 virtual int getContainerSize() const = 0;
180
181 // vIndex: 21
182 virtual int getMaxStackSize() const = 0;
183
184 // vIndex: 22
185 virtual void startOpen(::Actor&) = 0;
186
187 // vIndex: 23
188 virtual void stopOpen(::Actor& actor);
189
190 // vIndex: 24
191 virtual ::std::vector<::ItemStack> getSlotCopies() const;
192
193 // vIndex: 25
194 virtual ::std::vector<::ItemStack const*> const getSlots() const;
195
196 // vIndex: 26
197 virtual int getEmptySlotsCount() const;
198
199 // vIndex: 27
200 virtual int getItemCount(::ItemStack const& compare) const;
201
202 // vIndex: 28
203 virtual int firstEmptySlot() const;
204
205 // vIndex: 29
206 virtual int firstItem() const;
207
208 // vIndex: 30
209 virtual int findFirstSlotForItem(::ItemStack const& item) const;
210
211 // vIndex: 31
212 virtual int reverseFindFirstSlotForItem(::ItemStack const& item) const;
213
214 // vIndex: 32
215 virtual bool canPushInItem(int, int, ::ItemStack const&) const;
216
217 // vIndex: 33
218 virtual bool canPullOutItem(int, int, ::ItemStack const&) const;
219
220 // vIndex: 34
221 virtual void setContainerChanged(int slot);
222
223 // vIndex: 35
224 virtual void setContainerMoved();
225
226 // vIndex: 36
227 virtual void setCustomName(::Bedrock::Safety::RedactableString const& name);
228
229 // vIndex: 37
230 virtual bool hasCustomName() const;
231
232 // vIndex: 38
233 virtual void readAdditionalSaveData(::CompoundTag const& tag);
234
235 // vIndex: 39
236 virtual void addAdditionalSaveData(::CompoundTag& tag);
237
238 // vIndex: 40
239 virtual void createTransactionContext(
240 ::std::function<void(::Container&, int, ::ItemStack const&, ::ItemStack const&)> callback,
241 ::std::function<void()> execute
242 );
243
244 // vIndex: 41
245 virtual void initializeContainerContents(::BlockSource& region);
246
247 // vIndex: 42
248 virtual bool isEmpty() const;
249
250 // vIndex: 43
251 virtual bool isSlotDisabled(int) const;
252 // NOLINTEND
253
254public:
255 // member functions
256 // NOLINTBEGIN
257 MCAPI Container(::Container const&);
258
259 MCAPI explicit Container(::SharedTypes::Legacy::ContainerType type);
260
261 MCAPI Container(::SharedTypes::Legacy::ContainerType type, ::std::string const& name, bool customName);
262
263 MCAPI void
264 _dropSlotContent(::BlockSource& region, ::Random& random, ::Vec3 const& pos, bool randomizeDrop, int slot);
265
266 MCAPI void
267 _serverInitId(int slot, ::ItemStack& item, ::std::function<void(int, ::ItemStack const&)> onNetIdChanged);
268
269 MCAPI int getItemCount(::std::function<bool(::ItemStack const&)> comparator) const;
270
271 MCAPI int getRedstoneSignalFromContainer(::BlockSource& region);
272
273 MCAPI ::Container& operator=(::Container const&);
274
275 MCAPI void removeCloseListener(::ContainerCloseListener* listener);
276
277 MCAPI void triggerTransactionChange(int slot, ::ItemStack const& oldItem, ::ItemStack const& newItem);
278 // NOLINTEND
279
280public:
281 // static functions
282 // NOLINTBEGIN
283 MCAPI static ::SharedTypes::Legacy::ContainerType getContainerTypeId(::std::string const& name);
284
285 MCAPI static ::std::function<bool(::ItemStack const&)> sameItemAndAuxComparator(::ItemDescriptor const& descriptor);
286 // NOLINTEND
287
288public:
289 // static variables
290 // NOLINTBEGIN
291 MCAPI static ::BidirectionalUnorderedMap<::SharedTypes::Legacy::ContainerType, ::std::string> const&
292 containerTypeMap();
293 // NOLINTEND
294
295public:
296 // constructor thunks
297 // NOLINTBEGIN
298 MCAPI void* $ctor(::Container const&);
299
300 MCAPI void* $ctor(::SharedTypes::Legacy::ContainerType type);
301
302 MCAPI void* $ctor(::SharedTypes::Legacy::ContainerType type, ::std::string const& name, bool customName);
303 // NOLINTEND
304
305public:
306 // destructor thunk
307 // NOLINTBEGIN
308 MCAPI void $dtor();
309 // NOLINTEND
310
311public:
312 // virtual function thunks
313 // NOLINTBEGIN
314 MCFOLD void $init();
315
316 MCAPI void $addContentChangeListener(::ContainerContentChangeListener* listener);
317
318 MCAPI void $removeContentChangeListener(::ContainerContentChangeListener* listener);
319
320 MCFOLD ::Bedrock::PubSub::Connector<void()>* $getContainerRemovedConnector();
321
322 MCAPI bool $hasRemovedSubscribers() const;
323
324 MCAPI bool $hasRoomForItem(::ItemStack const& item) const;
325
326 MCAPI bool $addItem(::ItemStack& item);
327
328 MCAPI bool $addItemWithForceBalance(::ItemStack& item);
329
330 MCAPI bool $addItemToFirstEmptySlot(::ItemStack const& item);
331
332 MCFOLD void $setItemWithForceBalance(int slot, ::ItemStack const& item, bool forceBalanced);
333
334 MCAPI void $removeItem(int slot, int count);
335
336 MCAPI void $removeAllItems();
337
338 MCAPI void $removeAllItemsWithForceBalance();
339
340 MCAPI void $containerRemoved();
341
342 MCAPI void $dropSlotContent(::BlockSource& region, ::Vec3 const& pos, bool randomizeDrop, int slot);
343
344 MCAPI void $dropContents(::BlockSource& region, ::Vec3 const& pos, bool randomizeDrop);
345
346 MCAPI void $stopOpen(::Actor& actor);
347
348 MCAPI ::std::vector<::ItemStack> $getSlotCopies() const;
349
350 MCAPI ::std::vector<::ItemStack const*> const $getSlots() const;
351
352 MCFOLD int $getEmptySlotsCount() const;
353
354 MCAPI int $getItemCount(::ItemStack const& compare) const;
355
356 MCAPI int $firstEmptySlot() const;
357
358 MCAPI int $firstItem() const;
359
360 MCAPI int $findFirstSlotForItem(::ItemStack const& item) const;
361
362 MCAPI int $reverseFindFirstSlotForItem(::ItemStack const& item) const;
363
364 MCFOLD bool $canPushInItem(int, int, ::ItemStack const&) const;
365
366 MCFOLD bool $canPullOutItem(int, int, ::ItemStack const&) const;
367
368 MCAPI void $setContainerChanged(int slot);
369
370 MCAPI void $setContainerMoved();
371
372 MCAPI void $setCustomName(::Bedrock::Safety::RedactableString const& name);
373
374 MCAPI bool $hasCustomName() const;
375
376 MCAPI void $readAdditionalSaveData(::CompoundTag const& tag);
377
378 MCAPI void $addAdditionalSaveData(::CompoundTag& tag);
379
380 MCAPI void $createTransactionContext(
381 ::std::function<void(::Container&, int, ::ItemStack const&, ::ItemStack const&)> callback,
382 ::std::function<void()> execute
383 );
384
385 MCFOLD void $initializeContainerContents(::BlockSource& region);
386
387 MCAPI bool $isEmpty() const;
388
389 MCFOLD bool $isSlotDisabled(int) const;
390 // NOLINTEND
391
392public:
393 // vftables
394 // NOLINTBEGIN
395 MCNAPI static void** $vftable();
396 // NOLINTEND
397};
Definition Actor.h:102
Definition RedactableString.h:10
Definition BlockSource.h:66
Definition CompoundTag.h:13
Definition ContainerCloseListener.h:10
Definition ContainerContentChangeListener.h:5
Definition ContainerIterator.h:8
Definition ContainerSizeChangeListener.h:5
Definition Container.h:31
static MCAPI void ** $vftable()
Definition ItemDescriptor.h:22
Definition ItemStack.h:23
Definition Random.h:10
Definition TransactionContext.h:5
Definition Vec3.h:10
Definition optional_ref.h:10
Definition ContainerOwner.h:10
Definition ContainerRuntimeIdTag.h:5
Definition Container.h:39
Definition Alias.h:14