Skip to content
LeviMC
English
AutoLightDark
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 MCNAPI 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 MCNAPI void _onItemNetworkChanged(int slot, ::ItemStack const& oldItem, ::ItemStack const& newItem);
108
109 MCNAPI void addAvailableSetCountCallback(
110 ::ContainerEnumName name,
111 ::std::function<int(int, ::ItemStackBase const&)> availableSetCountCallback
112 );
113
114 MCNAPI void addItemAllowedInContainerCallback(
115 ::ContainerEnumName name,
116 ::std::function<bool(::ItemStackBase const&)> itemAllowedCallback
117 );
118
119 MCNAPI void addItemAllowedInSlotCallback(
120 ::ContainerEnumName name,
121 ::std::function<bool(int, ::ItemStackBase const&, int)> itemAllowedCallback
122 );
123
124 MCNAPI void addItemAllowedToAddCallback(
125 ::ContainerEnumName name,
126 ::std::function<bool(::ItemStackBase const&)> itemAllowedCallback
127 );
128
129 MCNAPI void addItemAllowedToRemoveCallback(
130 ::ContainerEnumName name,
131 ::std::function<bool(::ItemStackBase const&)> itemAllowedCallback
132 );
133#endif
134
136 ::ContainerEnumName name,
137 ::std::function<void(int, ::ItemStack const&, ::ItemStack const&)> itemNetworkChangedCallback
138 );
139
140#ifdef LL_PLAT_C
141 MCNAPI void addValidSlotForContainerCallback(
142 ::ContainerEnumName name,
143 ::std::function<bool(int)> validSlotForContainerCallback
144 );
145
146 MCNAPI ::ItemAddType canAdd(
148 ::FullContainerName const& openContainerNetId,
149 int slot,
150 ::ItemStackBase const& item,
151 int amount
152 ) const;
153
154 MCAPI bool canRemove(::ContainerEnumName name, int slot, int amount) const;
155
156 MCNAPI ::ItemSetType canSet(
158 ::FullContainerName const& name,
159 int slot,
160 ::ItemStackBase const& item,
161 int amount
162 ) const;
163
164 MCNAPI int getAvailableAddCount(::ContainerScreenContext const& context, ::ContainerEnumName name, int slot) const;
165
166 MCNAPI int getAvailableAddCount(
168 ::ContainerEnumName name,
169 int slot,
170 ::ItemStackBase const& itemToAdd
171 ) const;
172
173 MCNAPI int getAvailableSetCount(
175 ::FullContainerName const& name,
176 int slot,
177 ::ItemStackBase const& item
178 ) const;
179#endif
180
181 MCNAPI void removeItemNetworkChangedCallback(::ContainerEnumName name);
182 // NOLINTEND
183
184public:
185 // constructor thunks
186 // NOLINTBEGIN
187#ifdef LL_PLAT_C
188 MCNAPI void* $ctor(
189 ::Container& backingContainer,
190 ::SparseContainerBackingSetType backingSetType,
191 bool isClientSide,
192 bool isItemStackNetManagerEnabled,
193 ::std::unique_ptr<::ISparseContainerSetListener> netManagerSetter,
194 ::std::unique_ptr<::IPlayerContainerSetter> playerSetter
195 );
196#endif
197 // NOLINTEND
198
199public:
200 // virtual function thunks
201 // NOLINTBEGIN
202#ifdef LL_PLAT_C
203 MCNAPI ::ItemStack const& $getItem(int slot) const;
204
205 MCNAPI int $getContainerSize() const;
206
207 MCNAPI int $getMaxStackSize() const;
208
209 MCNAPI void $containerContentChanged(int slot);
210
211 MCNAPI void $setItem(int slot, ::ItemStack const& item);
212
213 MCNAPI void $serverInitItemStackIds(int, int, ::std::function<void(int, ::ItemStack const&)>);
214
215 MCNAPI void $startOpen(::Actor& actor);
216
217 MCNAPI void $stopOpen(::Actor& actor);
218
219 MCNAPI void $removeItem(int slot, int count);
220#endif
221
222
223 // NOLINTEND
224};
Definition Actor.h:116
Definition ContainerContentChangeListener.h:5
Definition ContainerScreenContext.h:16
MCAPI void * $ctor(::Container const &)
Definition IPlayerContainerSetter.h:10
Definition ISparseContainerSetListener.h:11
Definition ItemStackBase.h:45
Definition ItemStack.h:26
MCAPI void addItemNetworkChangedCallback(::ContainerEnumName name, ::std::function< void(int, ::ItemStack const &, ::ItemStack const &)> itemNetworkChangedCallback)
MCAPI void removeItemNetworkChangedCallback(::ContainerEnumName name)
Definition FullContainerName.h:8
Definition context.h:5