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