LeviLamina
Loading...
Searching...
No Matches
ScriptBlockCustomComponentsRegistry.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/core/container/EnumSet.h"
7#include "mc/deps/core/string/HashedString.h"
8#include "mc/deps/core/utility/NonOwnerPointer.h"
9#include "mc/deps/core/utility/pub_sub/Subscription.h"
10#include "mc/deps/script_core/lifetime_registry/scripting/StrongTypedObjectHandle.h"
11#include "mc/deps/script_core/runtime/scripting/Result.h"
12#include "mc/deps/script_core/scripting/Version.h"
13#include "mc/scripting/modules/minecraft/ScriptCustomComponentRegistry.h"
14#include "mc/scripting/modules/minecraft/block/IScriptBlockCustomComponentReader.h"
15#include "mc/scripting/modules/minecraft/events/ScriptBlockCustomComponentEventTypes.h"
16#include "mc/scripting/modules/minecraft/events/ScriptBlockCustomComponentInterface.h"
17#include "mc/scripting/modules/minecraft/events/metadata/ScriptCustomComponentAfterEventList.h"
18#include "mc/scripting/modules/minecraft/events/metadata/ScriptCustomComponentEventMetadata.h"
19#include "mc/world/events/ScriptDeferredEventListener.h"
20
21// auto generated forward declare list
22// clang-format off
23class Block;
25class BlockType;
29namespace BlockEvents { class ActorEvent; }
30namespace BlockEvents { class BlockBreakEvent; }
31namespace BlockEvents { class BlockEntityFallOnEvent; }
32namespace BlockEvents { class BlockPlaceEvent; }
33namespace BlockEvents { class BlockPlayerDestroyEvent; }
34namespace BlockEvents { class BlockPlayerInteractEvent; }
35namespace BlockEvents { class BlockPlayerPlacingEvent; }
36namespace BlockEvents { class BlockQueuedTickEvent; }
37namespace BlockEvents { class BlockRandomTickEvent; }
38namespace BlockEvents { class BlockRandomTickLegacyEvent; }
39namespace BlockEvents { class BlockRedstoneUpdateEvent; }
40namespace BlockEvents { class BlockStateChangeEvent; }
41namespace BlockEvents { class BlockStepOffEvent; }
42namespace BlockEvents { class BlockStepOnEvent; }
43namespace Json { class Value; }
44namespace ScriptModuleMinecraft { class ScriptBlockPermutation; }
45namespace ScriptModuleMinecraft { class ScriptCustomComponentParameterCache; }
46namespace ScriptModuleMinecraft { struct ScriptBlockCustomComponentAlreadyRegisteredError; }
47namespace ScriptModuleMinecraft { struct ScriptBlockCustomComponentReloadNewComponentError; }
48namespace ScriptModuleMinecraft { struct ScriptBlockCustomComponentReloadNewEventError; }
49namespace ScriptModuleMinecraft { struct ScriptBlockCustomComponentReloadVersionError; }
50namespace ScriptModuleMinecraft { struct ScriptCustomComponentInvalidRegistryError; }
51namespace ScriptModuleMinecraft { struct ScriptCustomComponentParameters; }
52namespace Scripting { class ModuleBindingBuilder; }
53namespace Scripting { class WeakLifetimeScope; }
54namespace Scripting { struct ModuleDescriptor; }
55namespace cereal { struct ReflectionCtx; }
56// clang-format on
57
58namespace ScriptModuleMinecraft {
59
60class ScriptBlockCustomComponentsRegistry : public ::ScriptModuleMinecraft::IScriptBlockCustomComponentReader,
63public:
64 // ScriptBlockCustomComponentsRegistry inner types declare
65 // clang-format off
67 // clang-format on
68
69 // ScriptBlockCustomComponentsRegistry inner types define
71 public:
72 // member variables
73 // NOLINTBEGIN
74 ::ll::TypedStorage<2, 2, ::Bedrock::EnumSet<::ScriptModuleMinecraft::ScriptBlockCustomComponentEventTypes, 14>>
75 mEventsUsed;
76 ::ll::TypedStorage<8, 288, ::std::optional<::ScriptModuleMinecraft::ScriptBlockCustomComponentInterface>>
77 mClosures;
78 ::ll::TypedStorage<8, 40, ::Scripting::Version> mVersionBoundWith;
79 ::ll::TypedStorage<1, 1, bool> mInitialized;
80 ::ll::TypedStorage<1, 1, bool> mUsedByBlock;
81 // NOLINTEND
82
83 public:
84 // member functions
85 // NOLINTBEGIN
86 MCAPI void setClosureData(
89 );
90 // NOLINTEND
91 };
92
93public:
94 // member variables
95 // NOLINTBEGIN
96 ::ll::TypedStorage<8, 8, ::ScriptDeferredEventCoordinator&> mDeferredEventCoordinator;
97 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::cereal::ReflectionCtx>> mCerealContext;
98 ::ll::TypedStorage<8, 24, ::std::vector<::Bedrock::PubSub::Subscription>> mBlockSubscriptions;
99 ::ll::TypedStorage<
100 8,
101 64,
102 ::std::unordered_map<
105 mComponents;
106 ::ll::TypedStorage<8, 24, ::ScriptModuleMinecraft::ScriptCustomComponentAfterEventList> mAsyncEventQueues;
107 ::ll::TypedStorage<2, 2, ::Bedrock::EnumSet<::ScriptModuleMinecraft::ScriptBlockCustomComponentEventTypes, 14>>
108 mV1EventSubscriptionList;
109 ::ll::TypedStorage<8, 8, ::ScriptModuleMinecraft::ScriptCustomComponentParameterCache&>
110 mCustomComponentParameterCache;
111 // NOLINTEND
112
113public:
114 // prevent constructor by default
115 ScriptBlockCustomComponentsRegistry& operator=(ScriptBlockCustomComponentsRegistry const&);
116 ScriptBlockCustomComponentsRegistry(ScriptBlockCustomComponentsRegistry const&);
117 ScriptBlockCustomComponentsRegistry();
118
119public:
120 // virtual functions
121 // NOLINTBEGIN
122 virtual void onPreFlushAfterEvents() /*override*/;
123
124 virtual void onFlushBlockCustomComponentAfterEvents(::ScriptDeferredFlushTracker& deferredTracker) /*override*/;
125
126 virtual void onPostFlushAfterEvents() /*override*/;
127
128 virtual void _onScriptInitializationComplete() /*override*/;
129
130 virtual void _onReload() /*override*/;
131
132 virtual ~ScriptBlockCustomComponentsRegistry() /*override*/ = default;
133
134 virtual ::std::vector<::std::string_view> getValidComponentsForBlock(
136 ) const /*override*/;
137
138 virtual ::Scripting::StrongTypedObjectHandle<::ScriptModuleMinecraft::ScriptCustomComponentParameters> const&
139 tryGetCustomComponentParametersForBlock(
140 ::Block const& block,
141 ::std::string_view componentName,
143 ) const /*override*/;
144 // NOLINTEND
145
146public:
147 // member functions
148 // NOLINTBEGIN
149 MCAPI ScriptBlockCustomComponentsRegistry(
151 ::ScriptDeferredEventCoordinator& deferredEventCoordinator,
153 );
154
155 MCAPI ::Scripting::Result<
156 void,
162 _componentRegistrationValidatorsCommon(
163 ::std::_List_iterator<::std::_List_val<::std::_List_simple_types<::std::pair<
164 ::HashedString const,
166 compIt,
167 ::HashedString const& name
168 );
169
170 MCAPI ::Scripting::Result<
171 void,
177 _componentReloadRegistrationValidators(
178 ::std::_List_iterator<::std::_List_val<::std::_List_simple_types<::std::pair<
179 ::HashedString const,
181 compIt,
182 ::HashedString const& name,
184 );
185
186 MCAPI void _registerBlockForEventing(
187 ::BlockType& block,
188 ::std::vector<::gsl::not_null<::BlockCustomComponentsComponent*>> const& comps
189 );
190
191 MCAPI void beforeOnPlayerPlace(::BlockEvents::BlockPlayerPlacingEvent& eventData) const;
192
193 MCAPI bool
194 hasSubscriptionFor(::ScriptModuleMinecraft::ScriptBlockCustomComponentEventTypes type, ::Block const& block) const;
195
196 MCAPI void onActor(::BlockEvents::ActorEvent const& eventData) const;
197
198 MCAPI void onBlockStateChange(::BlockEvents::BlockStateChangeEvent const& eventData) const;
199
200 MCAPI void onBreak(::BlockEvents::BlockBreakEvent const& eventData) const;
201
202 MCAPI void onEntityFallOn(::BlockEvents::BlockEntityFallOnEvent& eventData) const;
203
204 MCAPI void onPlace(::BlockEvents::BlockPlaceEvent const& eventData) const;
205
206 MCAPI void onPlayerBreak(::BlockEvents::BlockPlayerDestroyEvent const& eventData) const;
207
208 MCAPI void onPlayerInteract(::BlockEvents::BlockPlayerInteractEvent& eventData) const;
209
210 MCAPI void onQueuedTick(::BlockEvents::BlockQueuedTickEvent const& eventData) const;
211
212 MCAPI void onRandomTick(::BlockEvents::BlockRandomTickEvent const& eventData) const;
213
214 MCAPI void onRandomTickLegacy(::BlockEvents::BlockRandomTickLegacyEvent const& eventData) const;
215
216 MCAPI void onRedstoneUpdate(::BlockEvents::BlockRedstoneUpdateEvent const& eventData) const;
217
218 MCAPI void onStepOff(::BlockEvents::BlockStepOffEvent const& eventData) const;
219
220 MCAPI void onStepOn(::BlockEvents::BlockStepOnEvent const& eventData) const;
221
222 MCAPI ::ScriptModuleMinecraft::ScriptBlockCustomComponentInterface const*
223 tryGetRegisteredComponent(::HashedString const& name) const;
224
225 MCAPI ::Scripting::Result<
226 void,
232 tryRegisterCustomComponent(
233 ::HashedString const& name,
236 );
237
238 MCAPI ::Scripting::Result<
239 void,
245 tryRegisterCustomComponentV1(
246 ::HashedString const& name,
249 );
250 // NOLINTEND
251
252public:
253 // static functions
254 // NOLINTBEGIN
255 MCAPI static ::ScriptModuleMinecraft::ScriptCustomComponentEventMetadata<
257 _getEventMetadata();
258
259 MCAPI static void bind(::Scripting::ModuleBindingBuilder& moduleBuilder);
260
261 MCAPI static void generateOrderDocumentationForVersion(
262 ::Scripting::ModuleDescriptor const& moduleToDocumentFor,
263 ::Json::Value& eventOrderArray
264 );
265 // NOLINTEND
266
267public:
268 // constructor thunks
269 // NOLINTBEGIN
270 MCAPI void* $ctor(
272 ::ScriptDeferredEventCoordinator& deferredEventCoordinator,
274 );
275 // NOLINTEND
276
277public:
278 // virtual function thunks
279 // NOLINTBEGIN
280 MCAPI void $onPreFlushAfterEvents();
281
282 MCAPI void $onFlushBlockCustomComponentAfterEvents(::ScriptDeferredFlushTracker& deferredTracker);
283
284 MCAPI void $onPostFlushAfterEvents();
285
286 MCAPI void $_onScriptInitializationComplete();
287
288 MCAPI void $_onReload();
289
290 MCAPI ::std::vector<::std::string_view> $getValidComponentsForBlock(
292 ) const;
293
294 MCAPI ::Scripting::StrongTypedObjectHandle<::ScriptModuleMinecraft::ScriptCustomComponentParameters> const&
295 $tryGetCustomComponentParametersForBlock(
296 ::Block const& block,
297 ::std::string_view componentName,
299 ) const;
300
301
302 // NOLINTEND
303};
304
305} // namespace ScriptModuleMinecraft
Definition BlockCustomComponentsComponent.h:20
Definition ActorEvent.h:17
Definition BlockBreakEvent.h:17
Definition BlockEntityFallOnEvent.h:17
Definition BlockPlaceEvent.h:16
Definition BlockPlayerDestroyEvent.h:17
Definition BlockPlayerInteractEvent.h:18
Definition BlockPlayerPlacingEvent.h:18
Definition BlockQueuedTickEvent.h:16
Definition BlockRandomTickEvent.h:16
Definition BlockRandomTickLegacyEvent.h:16
Definition BlockRedstoneUpdateEvent.h:15
Definition BlockStateChangeEvent.h:16
Definition BlockStepOffEvent.h:16
Definition BlockStepOnEvent.h:16
Definition BlockType.h:79
Definition Block.h:41
Definition HashedString.h:5
Definition Value.h:16
Definition ScriptDeferredEventCoordinator.h:18
Definition ScriptDeferredEventListener.h:10
Definition ScriptDeferredFlushTracker.h:13
Definition IScriptBlockCustomComponentReader.h:18
Definition ScriptBlockCustomComponentInterface.h:10
Definition ScriptBlockPermutation.h:22
Definition ScriptCustomComponentParameterCache.h:21
Definition ScriptCustomComponentRegistry.h:10
Definition ModuleBindingBuilder.h:22
Definition StrongTypedObjectHandle.h:8
Definition WeakLifetimeScope.h:12
Definition ScriptBlockCustomComponentAlreadyRegisteredError.h:15
Definition ScriptBlockCustomComponentReloadNewComponentError.h:15
Definition ScriptBlockCustomComponentReloadNewEventError.h:15
Definition ScriptBlockCustomComponentReloadVersionError.h:15
Definition ScriptCustomComponentInvalidRegistryError.h:17
Definition ScriptCustomComponentParameters.h:15
Definition ModuleDescriptor.h:7
Definition ServerScriptManagerEvents.h:13
Definition ReflectionCtx.h:11