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