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 // NOLINTEND
77
78 public:
79 // constructor thunks
80 // NOLINTBEGIN
81 MCAPI void* $ctor(::ContainerEnumName containerName, ::Container& container);
82 // NOLINTEND
83 };
84
86 public:
87 // member variables
88 // NOLINTBEGIN
89 ::ll::TypedStorage<1, 1, uchar> mSlot;
90 ::ll::TypedStorage<4, 4, ::ItemStackNetId> mServerNetId;
91 // NOLINTEND
92 };
93
95 public:
96 // member variables
97 // NOLINTBEGIN
98 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mExpireTime;
99 ::ll::TypedStorage<
100 8,
101 64,
102 ::std::unordered_map<
103 ::ContainerRuntimeId,
104 ::std::unordered_map<uchar, ::ItemStackRequestActionHandler::RequestSlotIdAssignment>>>
105 mContainers;
106 // NOLINTEND
107 };
108
109 struct ScreenData {
110 public:
111 // member variables
112 // NOLINTBEGIN
113 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ItemStackRequestActionCraftHandler>> mCraftRequestHandler;
114 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScreenHandlerBase>> mScreenHandler;
115 ::ll::
116 TypedStorage<8, 64, ::std::unordered_map<::ContainerRuntimeId, ::std::shared_ptr<::SimpleSparseContainer>>>
117 mRuntimeIdSparseContainerMap;
118 ::ll::TypedStorage<
119 8,
120 64,
121 ::std::unordered_map<::ItemStackRequestId, ::ItemStackRequestActionHandler::RequestIdAssignments>>
122 mRecentRequests;
123 // NOLINTEND
124
125 public:
126 // member functions
127 // NOLINTBEGIN
128 MCAPI ~ScreenData();
129 // NOLINTEND
130
131 public:
132 // destructor thunk
133 // NOLINTBEGIN
134 MCAPI void $dtor();
135 // NOLINTEND
136 };
137
138public:
139 // member variables
140 // NOLINTBEGIN
141 ::ll::TypedStorage<8, 8, ::Player&> mPlayer;
142 ::ll::TypedStorage<8, 8, ::ItemStackNetManagerServer&> mItemStackNetManager;
143 ::ll::TypedStorage<4, 4, ::ContainerRuntimeId const> mPlayerArmorContainerRuntimeId;
144 ::ll::TypedStorage<4, 4, ::ContainerRuntimeId const> mPlayerHandContainerRuntimeId;
145 ::ll::TypedStorage<4, 4, ::ContainerRuntimeId const> mPlayerUIContainerRuntimeId;
146 ::ll::TypedStorage<8, 96, ::std::array<::ItemStackRequestActionHandler::PlayerLegacyRequestSlotIdAssignment, 3>>
147 mPlayerLegacyRequests;
148 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mLastTime;
149 ::ll::TypedStorage<8, 24, ::WeakRef<::EntityContext>> mCurrentRequestScreen;
150 ::ll::TypedStorage<8, 16, ::ItemStackRequestId> mClientRequestId;
151 ::ll::TypedStorage<8, 24, ::std::vector<::ItemStackResponseContainerInfo>> mResponseContainerInfos;
152 ::ll::TypedStorage<8, 16, ::std::map<::std::string, ::std::vector<::std::string>>> mFilteredStrings;
153 ::ll::TypedStorage<8, 16, ::std::map<::std::string, ::std::vector<::std::string>>> mStrings;
154 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ContainerScreenValidation>> mScreenValidation;
155 // NOLINTEND
156
157public:
158 // prevent constructor by default
159 ItemStackRequestActionHandler& operator=(ItemStackRequestActionHandler const&);
160 ItemStackRequestActionHandler(ItemStackRequestActionHandler const&);
161 ItemStackRequestActionHandler();
162
163public:
164 // member functions
165 // NOLINTBEGIN
166 MCAPI ItemStackRequestActionHandler(::ItemStackNetManagerServer& itemStackNetManager, ::Player& player);
167
168 MCAPI void _addResponseSlotInfo(::ItemStackRequestHandlerSlotInfo const& slotInfo, ::ItemStack const& item);
169
170 MCAPI void _cacheLegacySlotIdAssignment(
171 ::ContainerEnumName containerName,
172 uchar slot,
173 ::ItemStackLegacyRequestId const& legacyClientRequestId,
174 ::ItemStackNetId const& serverNetId
175 );
176
177 MCAPI void _cacheSlotIdAssigment(
178 ::ContainerRuntimeId const& containerRuntimeId,
179 uchar requestSlot,
180 uchar slot,
181 ::ItemStackNetId const& serverNetId
182 );
183
184 MCAPI ::std::unique_ptr<::ScreenHandlerBase> _createScreenHandler(::ContainerScreenContext const& screenContext);
185
186 MCAPI ::std::shared_ptr<::SimpleSparseContainer>
187 _getOrInitSparseContainer(::FullContainerName const& openContainerId);
188
189 MCAPI ::ItemStackNetResult _handleRemove(
190 ::ItemStackRequestActionTransferBase const& requestAction,
191 ::ItemStack& removedItem,
192 ::ItemStackRequestActionHandler::RemoveType removeType
193 );
194
195 MCAPI ::ItemStackNetResult _handleTransfer(
196 ::ItemStackRequestActionTransferBase const& requestAction,
197 bool isSrcHintSlot,
198 bool isDstHintSlot,
199 bool isSwap
200 );
201
202 MCAPI void _initScreen(::ItemStackNetManagerScreen& screen);
203
204 MCAPI void _initScreenValidation();
205
206 MCAPI ::std::optional<::ItemStackRequestActionHandler::RequestSlotIdAssignment> _resolveSlotIdAssignment(
207 ::ItemStackRequestSlotInfo const& requestSlotInfo,
208 ::ContainerRuntimeId const& containerRuntimeId
209 );
210
211 MCAPI ::ItemStackRequestActionHandler::ScreenData* _tryGetCurrentScreenData() const;
212
213 MCAPI ::ItemStackRequestHandlerSlotInfo
214 _validateRequestSlot(::ItemStackRequestSlotInfo const& requestSlotInfo, bool isItemRequired, bool);
215
216 MCAPI void addFilteredStrings(::ItemStackRequestId requestId, ::std::vector<::std::string> filteredStrings);
217
218 MCAPI void addStrings(::ItemStackRequestId requestId, ::std::vector<::std::string> strings);
219
220 MCAPI void beginRequest(::ItemStackRequestId const& clientRequestId, ::ItemStackNetManagerScreen& screen);
221
222 MCAPI ::std::tuple<::ItemStackNetResult, ::std::vector<::ItemStackResponseContainerInfo>>
223 endRequest(::ItemStackNetResult currentResult);
224
225 MCAPI ::std::vector<::std::string> const& getFilteredStrings(::ItemStackRequestId requestId) const;
226
227 MCFOLD ::ItemStackRequestId const& getRequestId() const;
228
229 MCAPI ::ContainerScreenContext const& getScreenContext() const;
230
231 MCAPI ::std::vector<::std::string> const& getStrings(::ItemStackRequestId requestId) const;
232
233 MCAPI ::ItemStackNetResult handleRequestAction(::ItemStackRequestAction const& requestAction);
234
235 MCAPI bool hasFilteredStrings(::ItemStackRequestId requestId) const;
236
237 MCAPI bool isValidationCraftingImplemented();
238
239 MCAPI void normalTick();
240
241 MCAPI void removeFilteredStrings(::ItemStackRequestId requestId);
242
243 MCAPI void removeStrings(::ItemStackRequestId requestId);
244
245 MCAPI ::std::vector<::ItemInstance>
246 tryCraft(::std::unique_ptr<::ContainerValidationCraftInputs> craftInputs, uchar numCrafts);
247
248 MCAPI ~ItemStackRequestActionHandler();
249 // NOLINTEND
250
251public:
252 // constructor thunks
253 // NOLINTBEGIN
254 MCAPI void* $ctor(::ItemStackNetManagerServer& itemStackNetManager, ::Player& player);
255 // NOLINTEND
256
257public:
258 // destructor thunk
259 // NOLINTBEGIN
260 MCAPI void $dtor();
261 // NOLINTEND
262};
Definition ContainerScreenContext.h:19
Definition ContainerScreenValidation.h:29
Definition Container.h:34
Definition EntityContext.h:17
Definition ItemInstance.h:15
Definition ItemStackNetManagerScreen.h:9
Definition ItemStackNetManagerServer.h:32
Definition ItemStackRequestActionCraftHandler.h:24
Definition ItemStackRequestActionTransferBase.h:17
Definition ItemStackRequestAction.h:18
Definition ItemStack.h:35
Definition Player.h:136
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:94
Definition ItemStackRequestActionHandler.h:85
Definition ItemStackRequestActionHandler.h:109
Definition ItemStackRequestHandlerSlotInfo.h:16
Definition ItemStackRequestIdTag.h:5
Definition ItemStackRequestSlotInfo.h:11
Definition ItemStackResponseContainerInfo.h:13