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 virtual ~SparseContainer() /*override*/ = default;
74
75 virtual ::ItemStack const& getItem(int slot) const /*override*/;
76
77 virtual int getContainerSize() const /*override*/;
78
79 virtual int getMaxStackSize() const /*override*/;
80
81 virtual void containerContentChanged(int slot) /*override*/;
82
83 virtual void setItem(int slot, ::ItemStack const& item) /*override*/;
84
85 virtual void serverInitItemStackIds(int, int, ::std::function<void(int, ::ItemStack const&)>) /*override*/;
86
87 virtual void startOpen(::Actor& actor) /*override*/;
88
89 virtual void stopOpen(::Actor& actor) /*override*/;
90
91 virtual void removeItem(int slot, int count) /*override*/;
92 // NOLINTEND
93
94public:
95 // member functions
96 // NOLINTBEGIN
97#ifdef LL_PLAT_C
98 MCAPI SparseContainer(
99 ::Container& backingContainer,
100 ::SparseContainerBackingSetType backingSetType,
101 bool isClientSide,
102 bool isItemStackNetManagerEnabled,
103 ::std::unique_ptr<::ISparseContainerSetListener> netManagerSetter,
104 ::std::unique_ptr<::IPlayerContainerSetter> playerSetter
105 );
106
107 MCAPI int _getAvailableAddCount(
109 ::ContainerEnumName name,
110 ::ItemStack const& itemInSlot
111 ) const;
112
113 MCAPI void _onItemNetworkChanged(int slot, ::ItemStack const& oldItem, ::ItemStack const& newItem);
114
115 MCAPI void addAvailableSetCountCallback(
116 ::ContainerEnumName name,
117 ::std::function<int(int, ::ItemStackBase const&)> availableSetCountCallback
118 );
119
120 MCAPI void addItemAllowedInContainerCallback(
121 ::ContainerEnumName name,
122 ::std::function<bool(::ItemStackBase const&)> itemAllowedCallback
123 );
124
125 MCAPI void addItemAllowedInSlotCallback(
126 ::ContainerEnumName name,
127 ::std::function<bool(int, ::ItemStackBase const&, int)> itemAllowedCallback
128 );
129
130 MCAPI void addItemAllowedToAddCallback(
131 ::ContainerEnumName name,
132 ::std::function<bool(::ItemStackBase const&)> itemAllowedCallback
133 );
134
135 MCAPI void addItemAllowedToRemoveCallback(
136 ::ContainerEnumName name,
137 ::std::function<bool(::ItemStackBase const&)> itemAllowedCallback
138 );
139#endif
140
141 MCAPI void addItemNetworkChangedCallback(
142 ::ContainerEnumName name,
143 ::std::function<void(int, ::ItemStack const&, ::ItemStack const&)> itemNetworkChangedCallback
144 );
145
146#ifdef LL_PLAT_C
147 MCAPI void addValidSlotForContainerCallback(
148 ::ContainerEnumName name,
149 ::std::function<bool(int)> validSlotForContainerCallback
150 );
151
152 MCAPI ::ItemAddType canAdd(
154 ::FullContainerName const& openContainerNetId,
155 int slot,
156 ::ItemStackBase const& item,
157 int amount
158 ) const;
159
160 MCAPI bool canRemove(::ContainerEnumName name, int slot, int amount) const;
161
162 MCAPI ::ItemSetType canSet(
164 ::FullContainerName const& name,
165 int slot,
166 ::ItemStackBase const& item,
167 int amount
168 ) const;
169
170 MCAPI int getAvailableAddCount(::ContainerScreenContext const& context, ::ContainerEnumName name, int slot) const;
171
172 MCAPI int getAvailableAddCount(
174 ::ContainerEnumName name,
175 int slot,
176 ::ItemStackBase const& itemToAdd
177 ) const;
178
179 MCAPI int getAvailableSetCount(
181 ::FullContainerName const& name,
182 int slot,
183 ::ItemStackBase const& item
184 ) const;
185#endif
186
187 MCAPI void removeItemNetworkChangedCallback(::ContainerEnumName name);
188 // NOLINTEND
189
190public:
191 // constructor thunks
192 // NOLINTBEGIN
193#ifdef LL_PLAT_C
194 MCAPI void* $ctor(
195 ::Container& backingContainer,
196 ::SparseContainerBackingSetType backingSetType,
197 bool isClientSide,
198 bool isItemStackNetManagerEnabled,
199 ::std::unique_ptr<::ISparseContainerSetListener> netManagerSetter,
200 ::std::unique_ptr<::IPlayerContainerSetter> playerSetter
201 );
202#endif
203 // NOLINTEND
204
205public:
206 // virtual function thunks
207 // NOLINTBEGIN
208#ifdef LL_PLAT_C
209 MCAPI ::ItemStack const& $getItem(int slot) const;
210
211 MCAPI int $getContainerSize() const;
212
213 MCAPI int $getMaxStackSize() const;
214
215 MCFOLD void $containerContentChanged(int slot);
216
217 MCAPI void $setItem(int slot, ::ItemStack const& item);
218
219 MCFOLD void $serverInitItemStackIds(int, int, ::std::function<void(int, ::ItemStack const&)>);
220
221 MCAPI void $startOpen(::Actor& actor);
222
223 MCAPI void $stopOpen(::Actor& actor);
224
225 MCFOLD void $removeItem(int slot, int count);
226#endif
227
228
229 // NOLINTEND
230};
Definition Actor.h:113
Definition ContainerContentChangeListener.h:5
Definition ContainerScreenContext.h:16
Definition IPlayerContainerSetter.h:10
Definition ISparseContainerSetListener.h:11
Definition ItemStackBase.h:44
Definition ItemStack.h:26
Definition FullContainerName.h:8
Definition context.h:5