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