Skip to content
LeviMC
English
AutoLightDark
LeviLamina
Loading...
Searching...
No Matches
ContainerManagerModel.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/core/utility/pub_sub/Publisher.h"
7#include "mc/deps/game_refs/WeakRef.h"
8#include "mc/deps/shared_types/legacy/ContainerType.h"
9#include "mc/world/ContainerID.h"
10#include "mc/world/containers/ContainerEnumName.h"
11#include "mc/world/containers/managers/IContainerManager.h"
12#include "mc/world/containers/managers/controllers/ContainerManagerController.h"
13#include "mc/world/inventory/network/ContainerScreenContext.h"
14
15// auto generated forward declare list
16// clang-format off
17class BlockPos;
18class ContainerModel;
20class HashedString;
22class ItemStack;
23class Player;
24struct ActorUniqueID;
27namespace Bedrock::PubSub { class Subscription; }
28namespace Bedrock::PubSub::ThreadModel { struct MultiThreaded; }
29namespace Bedrock::PubSub::ThreadModel { struct SingleThreaded; }
30// clang-format on
31
32class ContainerManagerModel : public ::IContainerManager {
33public:
34 // ContainerManagerModel inner types define
35 using DynamicContainerPublisher =
37
38public:
39 // member variables
40 // NOLINTBEGIN
41 ::ll::TypedStorage<8, 8, ::gsl::not_null<::std::unique_ptr<::PlayerContainerRefresher>>> mContainerRefresher;
42 ::ll::TypedStorage<8, 16, ::gsl::not_null<::std::shared_ptr<::DynamicContainerTracker>>> mDynamicContainerTracker;
43 ::ll::TypedStorage<8, 16, ::WeakRef<::IContainerRegistryAccess>> mRegistryAccess;
44 ::ll::TypedStorage<8, 8, ::Player&> mPlayer;
45 ::ll::TypedStorage<8, 24, ::std::vector<::ItemStack>> mLastSlots;
46 ::ll::TypedStorage<1, 1, ::ContainerID> mContainerId;
47 ::ll::TypedStorage<1, 1, ::SharedTypes::Legacy::ContainerType> mContainerType;
48 ::ll::TypedStorage<
49 8,
50 8,
51 ::std::unique_ptr<::Bedrock::PubSub::Publisher<
52 void(::SharedTypes::Legacy::ContainerType),
54 0>>>
55 mContainerTypeSubscribers;
56 ::ll::TypedStorage<
57 8,
58 64,
59 ::std::unordered_map<::ContainerManagerController const*, ::std::function<void(::ContainerManagerModel&)>>>
60 mInformControllerOfDestructionCallbacks;
61 ::ll::TypedStorage<8, 40, ::ContainerScreenContext> mScreenContext;
62 ::ll::TypedStorage<8, 64, ::std::unordered_map<::std::string, ::std::shared_ptr<::ContainerModel>>> mContainers;
64 mOnDynamicContainerChangePublisher;
65 // NOLINTEND
66
67public:
68 // prevent constructor by default
69 ContainerManagerModel& operator=(ContainerManagerModel const&);
70 ContainerManagerModel(ContainerManagerModel const&);
71 ContainerManagerModel();
72
73public:
74 // virtual functions
75 // NOLINTBEGIN
76 virtual ~ContainerManagerModel() /*override*/;
77
78 virtual bool tick();
79
80 virtual ::ContainerID getContainerId() const /*override*/;
81
82 virtual void setContainerId(::ContainerID id) /*override*/;
83
84 virtual ::SharedTypes::Legacy::ContainerType getContainerType() const /*override*/;
85
86 virtual void setContainerType(::SharedTypes::Legacy::ContainerType type) /*override*/;
87
88 virtual ::Bedrock::PubSub::Subscription
89 registerContainerTypeListener(::std::function<void(::SharedTypes::Legacy::ContainerType)> callback) const
90 /*override*/;
91
92 virtual void debitPlayerLevels(int levels);
93
94 virtual bool isCreativeMode() const;
95
96 virtual bool isClientSide() const;
97
98 virtual bool isServerAuthoritative() const;
99
100 virtual bool isValid(float pickRange);
101
102 virtual void serverInitItemStackIds() /*override*/;
103
104 virtual void
105 setFullContainerSlot(int slot, ::FullContainerName const& name, ::ItemStack const& item, bool) /*override*/;
106
107 virtual ::ItemStack const& getFullContainerSlot(int slot, ::FullContainerName const& name) const /*override*/;
108
109 virtual void broadcastChanges() /*override*/;
110
111 virtual ::ContainerScreenContext _postInit() = 0;
112
113 virtual void _onDynamicContainerContentsChanged();
114
115 virtual void setSelectedRecipeIndex(int recipeIndex, bool fromNetwork) /*override*/;
116
117 virtual ::std::optional<int> getSelectedRecipeIndex() const /*override*/;
118 // NOLINTEND
119
120public:
121 // member functions
122 // NOLINTBEGIN
123 MCAPI ContainerManagerModel(::ContainerID containerId, ::Player& player);
124
125 MCNAPI void _addContainer(::std::shared_ptr<::ContainerModel> containerModel);
126
127 MCAPI ::std::shared_ptr<::ContainerModel> _getContainer(::ContainerEnumName collectionEnumName) const;
128
129 MCNAPI void addDynamicContainer(::std::shared_ptr<::ContainerModel> model);
130
131#ifdef LL_PLAT_C
132 MCNAPI ::std::string getBlockDisplayName(::BlockPos const& blockPos) const;
133
134 MCNAPI ::HashedString getBlockLocName(::BlockPos const& blockPos) const;
135
136 MCNAPI ::HashedString getEntityLocName(::ActorUniqueID const& actorUniqueID) const;
137
138 MCNAPI ::std::string getEntityName(::ActorUniqueID const& actorUniqueID) const;
139#endif
140
141 MCAPI void postInit();
142 // NOLINTEND
143
144public:
145 // constructor thunks
146 // NOLINTBEGIN
147 MCAPI void* $ctor(::ContainerID containerId, ::Player& player);
148 // NOLINTEND
149
150public:
151 // destructor thunk
152 // NOLINTBEGIN
153 MCAPI void $dtor();
154 // NOLINTEND
155
156public:
157 // virtual function thunks
158 // NOLINTBEGIN
159 MCFOLD bool $tick();
160
161 MCFOLD ::ContainerID $getContainerId() const;
162
163 MCAPI void $setContainerId(::ContainerID id);
164
165 MCFOLD ::SharedTypes::Legacy::ContainerType $getContainerType() const;
166
167 MCAPI void $setContainerType(::SharedTypes::Legacy::ContainerType type);
168
169 MCAPI ::Bedrock::PubSub::Subscription
170 $registerContainerTypeListener(::std::function<void(::SharedTypes::Legacy::ContainerType)> callback) const;
171
172 MCAPI void $debitPlayerLevels(int levels);
173
174 MCAPI bool $isCreativeMode() const;
175
176 MCAPI bool $isClientSide() const;
177
178 MCAPI bool $isServerAuthoritative() const;
179
180 MCNAPI bool $isValid(float pickRange);
181
182 MCAPI void $serverInitItemStackIds();
183
184 MCAPI void $setFullContainerSlot(int slot, ::FullContainerName const& name, ::ItemStack const& item, bool);
185
186 MCAPI ::ItemStack const& $getFullContainerSlot(int slot, ::FullContainerName const& name) const;
187
188 MCAPI void $broadcastChanges();
189
191
192 MCNAPI void $setSelectedRecipeIndex(int recipeIndex, bool fromNetwork);
193
194 MCNAPI ::std::optional<int> $getSelectedRecipeIndex() const;
195
196
197 // NOLINTEND
198};
Definition Publisher.h:25
Definition Subscription.h:10
Definition BlockPos.h:14
Definition ContainerManagerController.h:46
MCAPI bool $isValid(float pickRange)
MCAPI void $setSelectedRecipeIndex(int recipeIndex, bool fromNetwork)
MCAPI void $_onDynamicContainerContentsChanged()
MCAPI ::std::optional< int > $getSelectedRecipeIndex() const
MCAPI void _addContainer(::std::shared_ptr<::ContainerModel > containerModel)
MCAPI void addDynamicContainer(::std::shared_ptr<::ContainerModel > model)
Definition ContainerModel.h:23
Definition DynamicContainerTracker.h:20
Definition HashedString.h:5
Definition IContainerManager.h:16
Definition IContainerRegistryAccess.h:14
Definition ItemStack.h:26
Definition Player.h:131
Definition ActorUniqueID.h:5
Definition FullContainerName.h:8
Definition PlayerContainerRefresher.h:13