LeviLamina
Loading...
Searching...
No Matches
ItemStackRequestActionHandler.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4#include "mc/world/actor/player/Player.h"
5
6// auto generated inclusion list
7#include "mc/deps/game_refs/WeakRef.h"
8#include "mc/world/TypedRuntimeId.h"
9#include "mc/world/containers/ContainerEnumName.h"
10#include "mc/world/inventory/network/ItemStackNetResult.h"
11#include "mc/world/inventory/network/TypedClientNetId.h"
12#include "mc/world/inventory/network/TypedServerNetId.h"
13
14// auto generated forward declare list
15// clang-format off
16class Container;
19class EntityContext;
20class ItemInstance;
21class ItemStack;
27class Player;
39// clang-format on
40
41class ItemStackRequestActionHandler {
42public:
43 // ItemStackRequestActionHandler inner types declare
44 // clang-format off
48 struct ScreenData;
49 // clang-format on
50
51 // ItemStackRequestActionHandler inner types define
52 enum class RemoveType : int {
53 Drop = 0,
54 DropRandomly = 1,
55 Destroy = 2,
56 Consume = 3,
57 };
58
59 struct PlayerLegacyRequestSlotIdAssignment {
60 public:
61 // member variables
62 // NOLINTBEGIN
63 ::ll::TypedStorage<1, 1, ::ContainerEnumName const> mContainerName;
64 ::ll::TypedStorage<4, 4, ::ContainerRuntimeId const> mContainerRuntimeId;
65 ::ll::TypedStorage<8, 24, ::std::vector<::std::pair<::ItemStackLegacyRequestId, ::ItemStackNetId>>> mSlots;
66 // NOLINTEND
67
68 public:
69 // prevent constructor by default
70 PlayerLegacyRequestSlotIdAssignment();
71
72 public:
73 // member functions
74 // NOLINTBEGIN
75 MCAPI PlayerLegacyRequestSlotIdAssignment(::ContainerEnumName containerName, ::Container& container);
76
77 MCAPI ~PlayerLegacyRequestSlotIdAssignment();
78 // NOLINTEND
79
80 public:
81 // constructor thunks
82 // NOLINTBEGIN
83 MCAPI void* $ctor(::ContainerEnumName containerName, ::Container& container);
84 // NOLINTEND
85
86 public:
87 // destructor thunk
88 // NOLINTBEGIN
89 MCAPI void $dtor();
90 // NOLINTEND
91 };
92
94 public:
95 // member variables
96 // NOLINTBEGIN
97 ::ll::TypedStorage<1, 1, uchar> mSlot;
98 ::ll::TypedStorage<4, 4, ::ItemStackNetId> mServerNetId;
99 // NOLINTEND
100 };
101
103 public:
104 // member variables
105 // NOLINTBEGIN
106 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mExpireTime;
107 ::ll::TypedStorage<
108 8,
109 64,
110 ::std::unordered_map<
111 ::ContainerRuntimeId,
112 ::std::unordered_map<uchar, ::ItemStackRequestActionHandler::RequestSlotIdAssignment>>>
113 mContainers;
114 // NOLINTEND
115 };
116
117 struct ScreenData {
118 public:
119 // member variables
120 // NOLINTBEGIN
121 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ItemStackRequestActionCraftHandler>> mCraftRequestHandler;
122 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScreenHandlerBase>> mScreenHandler;
123 ::ll::
124 TypedStorage<8, 64, ::std::unordered_map<::ContainerRuntimeId, ::std::shared_ptr<::SimpleSparseContainer>>>
125 mRuntimeIdSparseContainerMap;
126 ::ll::TypedStorage<
127 8,
128 64,
129 ::std::unordered_map<::ItemStackRequestId, ::ItemStackRequestActionHandler::RequestIdAssignments>>
130 mRecentRequests;
131 // NOLINTEND
132
133 public:
134 // prevent constructor by default
135 ScreenData& operator=(ScreenData const&);
136 ScreenData(ScreenData const&);
137 ScreenData();
138
139 public:
140 // member functions
141 // NOLINTBEGIN
143
144 MCAPI ::ItemStackRequestActionHandler::ScreenData& operator=(::ItemStackRequestActionHandler::ScreenData&&);
145
146 MCAPI ~ScreenData();
147 // NOLINTEND
148
149 public:
150 // constructor thunks
151 // NOLINTBEGIN
153 // NOLINTEND
154
155 public:
156 // destructor thunk
157 // NOLINTBEGIN
158 MCAPI void $dtor();
159 // NOLINTEND
160 };
161
162public:
163 // member variables
164 // NOLINTBEGIN
165 ::ll::TypedStorage<8, 8, ::Player&> mPlayer;
166 ::ll::TypedStorage<8, 8, ::ItemStackNetManagerServer&> mItemStackNetManager;
167 ::ll::TypedStorage<4, 4, ::ContainerRuntimeId const> mPlayerArmorContainerRuntimeId;
168 ::ll::TypedStorage<4, 4, ::ContainerRuntimeId const> mPlayerHandContainerRuntimeId;
169 ::ll::TypedStorage<4, 4, ::ContainerRuntimeId const> mPlayerUIContainerRuntimeId;
170 ::ll::TypedStorage<8, 96, ::std::array<::ItemStackRequestActionHandler::PlayerLegacyRequestSlotIdAssignment, 3>>
171 mPlayerLegacyRequests;
172 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mLastTime;
173 ::ll::TypedStorage<8, 24, ::WeakRef<::EntityContext>> mCurrentRequestScreen;
174 ::ll::TypedStorage<4, 16, ::ItemStackRequestId> mClientRequestId;
175 ::ll::TypedStorage<8, 24, ::std::vector<::ItemStackResponseContainerInfo>> mResponseContainerInfos;
176 ::ll::TypedStorage<8, 16, ::std::map<::std::string, ::std::vector<::std::string>>> mFilteredStrings;
177 ::ll::TypedStorage<8, 16, ::std::map<::std::string, ::std::vector<::std::string>>> mStrings;
178 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ContainerScreenValidation>> mScreenValidation;
179 // NOLINTEND
180
181public:
182 // prevent constructor by default
183 ItemStackRequestActionHandler& operator=(ItemStackRequestActionHandler const&);
184 ItemStackRequestActionHandler(ItemStackRequestActionHandler const&);
185 ItemStackRequestActionHandler();
186
187public:
188 // member functions
189 // NOLINTBEGIN
190 MCAPI ItemStackRequestActionHandler(::ItemStackNetManagerServer& itemStackNetManager, ::Player& player);
191
192 MCAPI void _addResponseSlotInfo(::ItemStackRequestHandlerSlotInfo const& slotInfo, ::ItemStack const& item);
193
194 MCAPI void _cacheLegacySlotIdAssignment(
195 ::ContainerEnumName containerName,
196 uchar slot,
197 ::ItemStackLegacyRequestId const& legacyClientRequestId,
198 ::ItemStackNetId const& serverNetId
199 );
200
201 MCAPI void _cacheSlotIdAssigment(
202 ::ContainerRuntimeId const& containerRuntimeId,
203 uchar requestSlot,
204 uchar slot,
205 ::ItemStackNetId const& serverNetId
206 );
207
208 MCAPI ::std::unique_ptr<::ScreenHandlerBase> _createScreenHandler(::ContainerScreenContext const& screenContext);
209
210 MCAPI ::std::shared_ptr<::SimpleSparseContainer>
211 _getOrInitSparseContainer(::FullContainerName const& openContainerId);
212
213 MCAPI ::ItemStackNetResult _handleRemove(
214 ::ItemStackRequestActionTransferBase const& requestAction,
215 ::ItemStack& removedItem,
216 ::ItemStackRequestActionHandler::RemoveType removeType
217 );
218
219 MCAPI ::ItemStackNetResult _handleTransfer(
220 ::ItemStackRequestActionTransferBase const& requestAction,
221 bool isSrcHintSlot,
222 bool isDstHintSlot,
223 bool isSwap
224 );
225
226 MCAPI void _initScreen(::ItemStackNetManagerScreen& screen);
227
228 MCAPI ::std::optional<::ItemStackRequestActionHandler::RequestSlotIdAssignment> _resolveSlotIdAssignment(
229 ::ItemStackRequestSlotInfo const& requestSlotInfo,
230 ::ContainerRuntimeId const& containerRuntimeId
231 );
232
233 MCAPI ::ItemStackRequestActionHandler::ScreenData* _tryGetCurrentScreenData() const;
234
235 MCAPI ::ItemStackRequestHandlerSlotInfo
236 _validateRequestSlot(::ItemStackRequestSlotInfo const& requestSlotInfo, bool isItemRequired, bool isHintSlot);
237
238 MCAPI void addStrings(::ItemStackRequestId requestId, ::std::vector<::std::string> strings);
239
240 MCAPI void beginRequest(::ItemStackRequestId const& clientRequestId, ::ItemStackNetManagerScreen& screen);
241
242 MCAPI ::std::tuple<::ItemStackNetResult, ::std::vector<::ItemStackResponseContainerInfo>>
243 endRequest(::ItemStackNetResult currentResult);
244
245 MCAPI ::std::vector<::std::string> const& getFilteredStrings(::ItemStackRequestId requestId) const;
246
247 MCAPI ::std::vector<::std::string> const& getStrings(::ItemStackRequestId requestId) const;
248
249 MCAPI ::ItemStackNetResult handleRequestAction(::ItemStackRequestAction const& requestAction);
250
251 MCAPI ::std::vector<::ItemInstance>
252 tryCraft(::std::unique_ptr<::ContainerValidationCraftInputs> craftInputs, uchar numCrafts);
253 // NOLINTEND
254
255public:
256 // constructor thunks
257 // NOLINTBEGIN
258 MCAPI void* $ctor(::ItemStackNetManagerServer& itemStackNetManager, ::Player& player);
259 // NOLINTEND
260};
Definition ContainerScreenContext.h:17
Definition ContainerScreenValidation.h:27
Definition Container.h:33
Definition EntityContext.h:16
Definition ItemInstance.h:15
Definition ItemStackNetManagerScreen.h:9
Definition ItemStackNetManagerServer.h:29
Definition ItemStackRequestActionCraftHandler.h:22
Definition ItemStackRequestActionTransferBase.h:17
Definition ItemStackRequestAction.h:18
Definition ItemStack.h:26
Definition Player.h:125
Definition ScreenHandlerBase.h:14
Definition SimpleSparseContainer.h:18
Definition ContainerRuntimeIdTag.h:5
Definition ContainerValidationCraftInputs.h:5
Definition FullContainerName.h:8
Definition ItemStackLegacyRequestIdTag.h:5
Definition ItemStackNetIdTag.h:5
Definition ItemStackRequestActionHandler.h:59
Definition ItemStackRequestActionHandler.h:102
Definition ItemStackRequestActionHandler.h:93
Definition ItemStackRequestActionHandler.h:117
Definition ItemStackRequestHandlerSlotInfo.h:16
Definition ItemStackRequestIdTag.h:5
Definition ItemStackRequestSlotInfo.h:11
Definition ItemStackResponseContainerInfo.h:13