LeviLamina
Loading...
Searching...
No Matches
SparseContainer.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/world/Container.h"
7#include "mc/world/ContainerContentChangeListener.h"
8#include "mc/world/containers/ContainerEnumName.h"
9#include "mc/world/containers/controllers/ItemAddType.h"
10#include "mc/world/containers/controllers/ItemSetType.h"
11#include "mc/world/inventory/simulation/SparseContainerBackingSetType.h"
12
13// auto generated forward declare list
14// clang-format off
15class Actor;
19class ItemStack;
20class ItemStackBase;
22// clang-format on
23
24class SparseContainer : public ::Container, public ::ContainerContentChangeListener {
25public:
26 // SparseContainer inner types define
27 using ItemNetworkChangedCallback = ::std::function<void(int, ::ItemStack const&, ::ItemStack const&)>;
28
29public:
30 // member variables
31 // NOLINTBEGIN
32 ::ll::TypedStorage<4, 4, ::SparseContainerBackingSetType const> mBackingSetType;
33 ::ll::TypedStorage<8, 8, ::Container&> mBackingContainer;
34 ::ll::TypedStorage<8, 64, ::std::unordered_map<int, ::ItemStack>> mItems;
35 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ISparseContainerSetListener>> mNetManagerSetter;
36 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::IPlayerContainerSetter>> mPlayerSetter;
37 ::ll::TypedStorage<
38 8,
39 64,
40 ::std::unordered_map<::ContainerEnumName, ::std::function<void(int, ::ItemStack const&, ::ItemStack const&)>>>
41 mItemNetworkChangedCallbacks;
42 ::ll::TypedStorage<
43 8,
44 64,
45 ::std::unordered_map<::ContainerEnumName, ::std::function<bool(int, ::ItemStackBase const&, int)>>>
46 mItemAllowedInSlotCallbacks;
47 ::ll::TypedStorage<8, 64, ::std::unordered_map<::ContainerEnumName, ::std::function<bool(::ItemStackBase const&)>>>
48 mItemAllowedToAddCallbacks;
49 ::ll::TypedStorage<
50 8,
51 64,
52 ::std::unordered_map<::ContainerEnumName, ::std::function<int(int, ::ItemStackBase const&)>>>
53 mAvailableSetCountCallbacks;
54 ::ll::TypedStorage<8, 64, ::std::unordered_map<::ContainerEnumName, ::std::function<bool(int)>>>
55 mValidSlotForContainerCallbacks;
56 ::ll::TypedStorage<8, 64, ::std::unordered_map<::ContainerEnumName, ::std::function<bool(::ItemStackBase const&)>>>
57 mItemAllowedToRemoveCallbacks;
58 ::ll::TypedStorage<8, 64, ::std::unordered_map<::ContainerEnumName, ::std::function<bool(::ItemStackBase const&)>>>
59 mItemAllowedInContainerCallbacks;
60 ::ll::TypedStorage<1, 1, bool const> mIsClientSide;
61 ::ll::TypedStorage<1, 1, bool const> mIsItemStackNetManagerEnabled;
62 // NOLINTEND
63
64public:
65 // prevent constructor by default
66 SparseContainer& operator=(SparseContainer const&);
67 SparseContainer(SparseContainer const&);
68 SparseContainer();
69
70public:
71 // virtual functions
72 // NOLINTBEGIN
73#ifdef LL_PLAT_S
74 virtual ~SparseContainer() /*override*/ = default;
75#else // LL_PLAT_C
76 virtual ~SparseContainer() /*override*/;
77#endif
78
79#ifdef LL_PLAT_S
80 virtual ::ItemStack const& getItem(int) const /*override*/;
81#else // LL_PLAT_C
82 virtual ::ItemStack const& getItem(int slot) const /*override*/;
83#endif
84
85 virtual int getContainerSize() const /*override*/;
86
87 virtual int getMaxStackSize() const /*override*/;
88
89#ifdef LL_PLAT_S
90 virtual void containerContentChanged(int) /*override*/;
91#else // LL_PLAT_C
92 virtual void containerContentChanged(int slot) /*override*/;
93#endif
94
95#ifdef LL_PLAT_S
96 virtual void setItem(int, ::ItemStack const&) /*override*/;
97#else // LL_PLAT_C
98 virtual void setItem(int slot, ::ItemStack const& item) /*override*/;
99#endif
100
101 virtual void serverInitItemStackIds(int, int, ::std::function<void(int, ::ItemStack const&)>) /*override*/;
102
103#ifdef LL_PLAT_S
104 virtual void startOpen(::Actor&) /*override*/;
105#else // LL_PLAT_C
106 virtual void startOpen(::Actor& actor) /*override*/;
107#endif
108
109 virtual void stopOpen(::Actor& actor) /*override*/;
110
111 virtual void removeItem(int slot, int count) /*override*/;
112 // NOLINTEND
113
114public:
115 // member functions
116 // NOLINTBEGIN
117#ifdef LL_PLAT_C
118 MCAPI SparseContainer(
119 ::Container& backingContainer,
120 ::SparseContainerBackingSetType backingSetType,
121 bool isClientSide,
122 bool isItemStackNetManagerEnabled,
123 ::std::unique_ptr<::ISparseContainerSetListener> netManagerSetter,
124 ::std::unique_ptr<::IPlayerContainerSetter> playerSetter
125 );
126
127 MCFOLD void _clearCreatedItem(int slot);
128
129 MCAPI int _getAvailableAddCount(
130 ::ContainerScreenContext const& name,
131 ::ContainerEnumName itemInSlot,
132 ::ItemStack const&
133 ) const;
134
135 MCAPI bool _isSlotInRange(int slot) const;
136
137 MCAPI void _onItemNetworkChanged(int slot, ::ItemStack const& oldItem, ::ItemStack const& newItem);
138
139 MCAPI void addAvailableSetCountCallback(
140 ::ContainerEnumName name,
141 ::std::function<int(int, ::ItemStackBase const&)> availableSetCountCallback
142 );
143
144 MCAPI void addItemAllowedInContainerCallback(
145 ::ContainerEnumName name,
146 ::std::function<bool(::ItemStackBase const&)> itemAllowedCallback
147 );
148
149 MCAPI void addItemAllowedInSlotCallback(
150 ::ContainerEnumName name,
151 ::std::function<bool(int, ::ItemStackBase const&, int)> itemAllowedCallback
152 );
153
154 MCAPI void addItemAllowedToAddCallback(
155 ::ContainerEnumName name,
156 ::std::function<bool(::ItemStackBase const&)> itemAllowedCallback
157 );
158
159 MCAPI void addItemAllowedToRemoveCallback(
160 ::ContainerEnumName name,
161 ::std::function<bool(::ItemStackBase const&)> itemAllowedCallback
162 );
163#endif
164
165 MCAPI void addItemNetworkChangedCallback(
166 ::ContainerEnumName name,
167 ::std::function<void(int, ::ItemStack const&, ::ItemStack const&)> itemNetworkChangedCallback
168 );
169
170#ifdef LL_PLAT_C
171 MCAPI void addValidSlotForContainerCallback(
172 ::ContainerEnumName name,
173 ::std::function<bool(int)> validSlotForContainerCallback
174 );
175
176 MCAPI ::ItemAddType canAdd(
178 ::FullContainerName const& openContainerNetId,
179 int slot,
180 ::ItemStackBase const& item,
181 int amount
182 ) const;
183
184 MCFOLD bool canConsume(::ContainerEnumName name, int slot, int amount) const;
185
186 MCFOLD bool canDestroy(::ContainerEnumName name, int slot, int amount) const;
187
188 MCFOLD bool canDrop(::ContainerEnumName name, int slot, int amount) const;
189
190 MCAPI bool canRemove(::ContainerEnumName name, int slot, int amount) const;
191
192 MCAPI ::ItemSetType canSet(
194 ::FullContainerName const& name,
195 int slot,
196 ::ItemStackBase const& item,
197 int amount
198 ) const;
199
200 MCAPI int getAvailableAddCount(::ContainerScreenContext const& name, ::ContainerEnumName slot, int) const;
201
202 MCAPI int getAvailableAddCount(
204 ::ContainerEnumName name,
205 int slot,
206 ::ItemStackBase const& itemToAdd
207 ) const;
208
209 MCAPI int getAvailableSetCount(
211 ::FullContainerName const& name,
212 int slot,
213 ::ItemStackBase const& item
214 ) const;
215
216 MCAPI bool isClientSide() const;
217#endif
218
219 MCAPI bool isUsingLegacyScreenTransactions() const;
220
221#ifdef LL_PLAT_C
222 MCAPI bool isValidSlot(::ContainerEnumName name, int slot) const;
223#endif
224
225 MCAPI void removeItemNetworkChangedCallback(::ContainerEnumName name);
226 // NOLINTEND
227
228public:
229 // constructor thunks
230 // NOLINTBEGIN
231#ifdef LL_PLAT_C
232 MCAPI void* $ctor(
233 ::Container& backingContainer,
234 ::SparseContainerBackingSetType backingSetType,
235 bool isClientSide,
236 bool isItemStackNetManagerEnabled,
237 ::std::unique_ptr<::ISparseContainerSetListener> netManagerSetter,
238 ::std::unique_ptr<::IPlayerContainerSetter> playerSetter
239 );
240#endif
241 // NOLINTEND
242
243public:
244 // destructor thunk
245 // NOLINTBEGIN
246 MCAPI void $dtor();
247 // NOLINTEND
248
249public:
250 // virtual function thunks
251 // NOLINTBEGIN
252#ifdef LL_PLAT_C
253 MCAPI ::ItemStack const& $getItem(int slot) const;
254
255 MCAPI int $getContainerSize() const;
256
257 MCAPI int $getMaxStackSize() const;
258
259 MCFOLD void $containerContentChanged(int slot);
260
261 MCAPI void $setItem(int slot, ::ItemStack const& item);
262
263 MCFOLD void $serverInitItemStackIds(int, int, ::std::function<void(int, ::ItemStack const&)>);
264
265 MCAPI void $startOpen(::Actor& actor);
266
267 MCAPI void $stopOpen(::Actor& actor);
268
269 MCFOLD void $removeItem(int slot, int count);
270#endif
271
272
273 // NOLINTEND
274
275public:
276 // vftables
277 // NOLINTBEGIN
278 MCAPI static void** $vftableForContainerContentChangeListener();
279
280 MCAPI static void** $vftableForContainer();
281 // NOLINTEND
282};
Definition Actor.h:125
Definition ContainerContentChangeListener.h:5
Definition ContainerScreenContext.h:19
Definition IPlayerContainerSetter.h:10
Definition ISparseContainerSetListener.h:11
Definition ItemStackBase.h:52
Definition ItemStack.h:35
Definition FullContainerName.h:8
Definition context.h:5