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/util/BidirectionalUnorderedMap.h"
12#include "mc/world/TypedRuntimeId.h"
13
14// auto generated forward declare list
15// clang-format off
16class BlockSource;
17class CompoundTag;
21class ItemStack;
22class Player;
23class Random;
24class Vec3;
25struct ContainerOwner;
27namespace Bedrock::Safety { class RedactableString; }
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
54 MCAPI ~PublisherWrapper();
55 // NOLINTEND
56
57 public:
58 // destructor thunk
59 // NOLINTBEGIN
60 MCFOLD 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 // virtual functions
112 // NOLINTBEGIN
113 // vIndex: 0
114 virtual ~Container();
115
116 // vIndex: 1
117 virtual void init();
118
119 // vIndex: 2
120 virtual void serverInitItemStackIds(int, int, ::std::function<void(int, ::ItemStack const&)>) = 0;
121
122 // vIndex: 3
123 virtual void addContentChangeListener(::ContainerContentChangeListener* listener);
124
125 // vIndex: 4
126 virtual void removeContentChangeListener(::ContainerContentChangeListener* listener);
127
128 // vIndex: 5
129 virtual ::Bedrock::PubSub::Connector<void()>* getContainerRemovedConnector();
130
131 // vIndex: 6
132 virtual bool hasRemovedSubscribers() const;
133
134 // vIndex: 7
135 virtual ::ItemStack const& getItem(int) const = 0;
136
137 // vIndex: 8
138 virtual bool hasRoomForItem(::ItemStack const& item);
139
140 // vIndex: 9
141 virtual bool addItem(::ItemStack& item);
142
143 // vIndex: 10
144 virtual bool addItemWithForceBalance(::ItemStack& item);
145
146 // vIndex: 11
147 virtual bool addItemToFirstEmptySlot(::ItemStack const& item);
148
149 // vIndex: 12
150 virtual void setItem(int modelSlot, ::ItemStack const& item) = 0;
151
152 // vIndex: 13
153 virtual void setItemWithForceBalance(int slot, ::ItemStack const& item, bool forceBalanced);
154
155 // vIndex: 14
156 virtual void removeItem(int slot, int count);
157
158 // vIndex: 15
159 virtual void removeAllItems();
160
161 // vIndex: 16
162 virtual void removeAllItemsWithForceBalance();
163
164 // vIndex: 17
165 virtual void containerRemoved();
166
167 // vIndex: 18
168 virtual void dropSlotContent(::BlockSource& region, ::Vec3 const& pos, bool randomizeDrop, int slot);
169
170 // vIndex: 19
171 virtual void dropContents(::BlockSource& region, ::Vec3 const& pos, bool randomizeDrop);
172
173 // vIndex: 20
174 virtual int getContainerSize() const = 0;
175
176 // vIndex: 21
177 virtual int getMaxStackSize() const = 0;
178
179 // vIndex: 22
180 virtual void startOpen(::Player&) = 0;
181
182 // vIndex: 23
183 virtual void stopOpen(::Player& player);
184
185 // vIndex: 24
186 virtual ::std::vector<::ItemStack> getSlotCopies() const;
187
188 // vIndex: 25
189 virtual ::std::vector<::ItemStack const*> const getSlots() const;
190
191 // vIndex: 26
192 virtual int getEmptySlotsCount() const;
193
194 // vIndex: 27
195 virtual int getItemCount(::ItemStack const& compare) const;
196
197 // vIndex: 28
198 virtual int findFirstSlotForItem(::ItemStack const& item) const;
199
200 // vIndex: 29
201 virtual bool canPushInItem(int, int, ::ItemStack const&) const;
202
203 // vIndex: 30
204 virtual bool canPullOutItem(int, int, ::ItemStack const&) const;
205
206 // vIndex: 31
207 virtual void setContainerChanged(int slot);
208
209 // vIndex: 32
210 virtual void setContainerMoved();
211
212 // vIndex: 33
213 virtual void setCustomName(::Bedrock::Safety::RedactableString const& name);
214
215 // vIndex: 34
216 virtual bool hasCustomName() const;
217
218 // vIndex: 35
219 virtual void readAdditionalSaveData(::CompoundTag const& tag);
220
221 // vIndex: 36
222 virtual void addAdditionalSaveData(::CompoundTag& tag);
223
224 // vIndex: 37
225 virtual void createTransactionContext(
226 ::std::function<void(::Container&, int, ::ItemStack const&, ::ItemStack const&)> callback,
227 ::std::function<void()> execute
228 );
229
230 // vIndex: 38
231 virtual void initializeContainerContents(::BlockSource& region);
232
233 // vIndex: 39
234 virtual bool isEmpty() const;
235
236 // vIndex: 40
237 virtual bool isSlotDisabled(int) const;
238 // NOLINTEND
239
240public:
241 // member functions
242 // NOLINTBEGIN
243 MCAPI Container(::Container const&);
244
245 MCAPI explicit Container(::SharedTypes::Legacy::ContainerType type);
246
247 MCAPI Container(::SharedTypes::Legacy::ContainerType type, ::std::string const& name, bool customName);
248
249 MCAPI void
250 _dropSlotContent(::BlockSource& region, ::Random& random, ::Vec3 const& pos, bool randomizeDrop, int slot);
251
252 MCAPI void
253 _serverInitId(int slot, ::ItemStack& item, ::std::function<void(int, ::ItemStack const&)> onNetIdChanged);
254
255 MCAPI int getItemCount(::std::function<bool(::ItemStack const&)> comparator);
256
257 MCAPI int getRedstoneSignalFromContainer(::BlockSource& region);
258
259 MCAPI ::Container& operator=(::Container const&);
260
261 MCAPI void removeCloseListener(::ContainerCloseListener* listener);
262
263 MCAPI void triggerTransactionChange(int slot, ::ItemStack const& oldItem, ::ItemStack const& newItem);
264 // NOLINTEND
265
266public:
267 // static functions
268 // NOLINTBEGIN
269 MCAPI static ::SharedTypes::Legacy::ContainerType getContainerTypeId(::std::string const& name);
270 // NOLINTEND
271
272public:
273 // static variables
274 // NOLINTBEGIN
275 MCAPI static ::BidirectionalUnorderedMap<::SharedTypes::Legacy::ContainerType, ::std::string> const&
276 containerTypeMap();
277 // NOLINTEND
278
279public:
280 // constructor thunks
281 // NOLINTBEGIN
282 MCAPI void* $ctor(::Container const&);
283
284 MCAPI void* $ctor(::SharedTypes::Legacy::ContainerType type);
285
286 MCAPI void* $ctor(::SharedTypes::Legacy::ContainerType type, ::std::string const& name, bool customName);
287 // NOLINTEND
288
289public:
290 // destructor thunk
291 // NOLINTBEGIN
292 MCAPI void $dtor();
293 // NOLINTEND
294
295public:
296 // virtual function thunks
297 // NOLINTBEGIN
298 MCFOLD void $init();
299
300 MCAPI void $addContentChangeListener(::ContainerContentChangeListener* listener);
301
302 MCAPI void $removeContentChangeListener(::ContainerContentChangeListener* listener);
303
304 MCFOLD ::Bedrock::PubSub::Connector<void()>* $getContainerRemovedConnector();
305
306 MCAPI bool $hasRemovedSubscribers() const;
307
308 MCAPI bool $hasRoomForItem(::ItemStack const& item);
309
310 MCAPI bool $addItem(::ItemStack& item);
311
312 MCAPI bool $addItemWithForceBalance(::ItemStack& item);
313
314 MCAPI bool $addItemToFirstEmptySlot(::ItemStack const& item);
315
316 MCFOLD void $setItemWithForceBalance(int slot, ::ItemStack const& item, bool forceBalanced);
317
318 MCAPI void $removeItem(int slot, int count);
319
320 MCAPI void $removeAllItems();
321
322 MCAPI void $removeAllItemsWithForceBalance();
323
324 MCAPI void $containerRemoved();
325
326 MCAPI void $dropSlotContent(::BlockSource& region, ::Vec3 const& pos, bool randomizeDrop, int slot);
327
328 MCAPI void $dropContents(::BlockSource& region, ::Vec3 const& pos, bool randomizeDrop);
329
330 MCAPI void $stopOpen(::Player& player);
331
332 MCAPI ::std::vector<::ItemStack> $getSlotCopies() const;
333
334 MCAPI ::std::vector<::ItemStack const*> const $getSlots() const;
335
336 MCFOLD int $getEmptySlotsCount() const;
337
338 MCAPI int $getItemCount(::ItemStack const& compare) const;
339
340 MCAPI int $findFirstSlotForItem(::ItemStack const& item) const;
341
342 MCFOLD bool $canPushInItem(int, int, ::ItemStack const&) const;
343
344 MCFOLD bool $canPullOutItem(int, int, ::ItemStack const&) const;
345
346 MCAPI void $setContainerChanged(int slot);
347
348 MCAPI void $setContainerMoved();
349
350 MCAPI void $setCustomName(::Bedrock::Safety::RedactableString const& name);
351
352 MCAPI bool $hasCustomName() const;
353
354 MCAPI void $readAdditionalSaveData(::CompoundTag const& tag);
355
356 MCAPI void $addAdditionalSaveData(::CompoundTag& tag);
357
358 MCAPI void $createTransactionContext(
359 ::std::function<void(::Container&, int, ::ItemStack const&, ::ItemStack const&)> callback,
360 ::std::function<void()> execute
361 );
362
363 MCFOLD void $initializeContainerContents(::BlockSource& region);
364
365 MCAPI bool $isEmpty() const;
366
367 MCFOLD bool $isSlotDisabled(int) const;
368 // NOLINTEND
369
370public:
371 // vftables
372 // NOLINTBEGIN
373 MCAPI static void** $vftable();
374 // NOLINTEND
375};
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
Definition ItemStack.h:25
Definition Player.h:119
Definition Random.h:16
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