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