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/scripting/Version.h"
11#include "mc/deps/scripting/lifetime_registry/StrongTypedObjectHandle.h"
12#include "mc/deps/scripting/runtime/Result.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
70 struct ScriptBlockCustomComponentData {
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 // prevent constructor by default
85 ScriptBlockCustomComponentData& operator=(ScriptBlockCustomComponentData const&);
86 ScriptBlockCustomComponentData();
87
88 public:
89 // member functions
90 // NOLINTBEGIN
91 MCAPI ScriptBlockCustomComponentData(
93 );
94
95 MCAPI void setClosureData(
98 );
99
100 MCAPI ~ScriptBlockCustomComponentData();
101 // NOLINTEND
102
103 public:
104 // constructor thunks
105 // NOLINTBEGIN
106 MCAPI void*
108 // NOLINTEND
109
110 public:
111 // destructor thunk
112 // NOLINTBEGIN
113 MCAPI void $dtor();
114 // NOLINTEND
115 };
116
117public:
118 // member variables
119 // NOLINTBEGIN
120 ::ll::TypedStorage<8, 8, ::ScriptDeferredEventCoordinator&> mDeferredEventCoordinator;
121 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::cereal::ReflectionCtx>> mCerealContext;
122 ::ll::TypedStorage<8, 24, ::std::vector<::Bedrock::PubSub::Subscription>> mBlockSubscriptions;
123 ::ll::TypedStorage<
124 8,
125 64,
126 ::std::unordered_map<
129 mComponents;
130 ::ll::TypedStorage<8, 24, ::ScriptModuleMinecraft::ScriptCustomComponentAfterEventList> mAsyncEventQueues;
131 ::ll::TypedStorage<2, 2, ::Bedrock::EnumSet<::ScriptModuleMinecraft::ScriptBlockCustomComponentEventTypes, 14>>
132 mV1EventSubscriptionList;
133 ::ll::TypedStorage<8, 8, ::ScriptModuleMinecraft::ScriptCustomComponentParameterCache&>
134 mCustomComponentParameterCache;
135 // NOLINTEND
136
137public:
138 // prevent constructor by default
139 ScriptBlockCustomComponentsRegistry& operator=(ScriptBlockCustomComponentsRegistry const&);
140 ScriptBlockCustomComponentsRegistry(ScriptBlockCustomComponentsRegistry const&);
141 ScriptBlockCustomComponentsRegistry();
142
143public:
144 // virtual functions
145 // NOLINTBEGIN
146 virtual void onPreFlushAfterEvents() /*override*/;
147
148 virtual void onFlushBlockCustomComponentAfterEvents(::ScriptDeferredFlushTracker& deferredTracker) /*override*/;
149
150 virtual void onPostFlushAfterEvents() /*override*/;
151
152 virtual void _onScriptInitializationComplete() /*override*/;
153
154 virtual void _onReload() /*override*/;
155
156 virtual ~ScriptBlockCustomComponentsRegistry() /*override*/;
157
158 virtual ::std::vector<::std::string_view> getValidComponentsForBlock(
160 ) const /*override*/;
161
162 virtual ::Scripting::StrongTypedObjectHandle<::ScriptModuleMinecraft::ScriptCustomComponentParameters> const&
163 tryGetCustomComponentParametersForBlock(
164 ::Block const& block,
165 ::std::string_view componentName,
167 ) const /*override*/;
168 // NOLINTEND
169
170public:
171 // member functions
172 // NOLINTBEGIN
173 MCAPI ScriptBlockCustomComponentsRegistry(
175 ::ScriptDeferredEventCoordinator& deferredEventCoordinator,
177 );
178
179 MCAPI void _bindComponentToCereal(
180 ::HashedString const& compName,
182 );
183
184 MCAPI bool _checkDifferentEventRegistered(
187 );
188
189 MCAPI ::Scripting::Result<
190 void,
196 _componentRegistrationValidators(
197 ::std::_List_iterator<::std::_List_val<::std::_List_simple_types<::std::pair<
198 ::HashedString const,
200 compIt,
201 ::HashedString const& name
202 );
203
204 MCAPI ::Scripting::Result<
205 void,
211 _componentRegistrationValidatorsCommon(
212 ::std::_List_iterator<::std::_List_val<::std::_List_simple_types<::std::pair<
213 ::HashedString const,
215 compIt,
216 ::HashedString const& name
217 );
218
219 MCAPI ::Scripting::Result<
220 void,
226 _componentRegistrationValidatorsV1(
227 ::std::_List_iterator<::std::_List_val<::std::_List_simple_types<::std::pair<
228 ::HashedString const,
230 compIt,
231 ::HashedString const& name,
233 );
234
235 MCAPI ::Scripting::Result<
236 void,
242 _componentReloadRegistrationValidators(
243 ::std::_List_iterator<::std::_List_val<::std::_List_simple_types<::std::pair<
244 ::HashedString const,
246 compIt,
247 ::HashedString const& name,
249 );
250
251 MCAPI void _registerBlockForEventing(
252 ::BlockType& block,
253 ::std::vector<::gsl::not_null<::BlockCustomComponentsComponent*>> const& comps
254 );
255
256 MCAPI void _validateBlockQueuedTickingComponentPresentWithClosure(::Block const& block) const;
257
258 MCAPI void _validateBlockRedstoneConsumerComponentPresentWithClosure(::Block const& block) const;
259
260 MCAPI void _validateBlockStateChangeComponentPresentWithClosure(::Block const& block) const;
261
262 MCAPI void beforeOnPlayerPlace(::BlockEvents::BlockPlayerPlacingEvent& eventData) const;
263
264 MCFOLD ::ScriptModuleMinecraft::ScriptCustomComponentParameterCache& getCustomComponentParameterCache() const;
265
266 MCAPI bool
267 hasSubscriptionFor(::ScriptModuleMinecraft::ScriptBlockCustomComponentEventTypes type, ::Block const& block) const;
268
269 MCAPI void onActor(::BlockEvents::ActorEvent const& eventData) const;
270
271 MCAPI void onBlockStateChange(::BlockEvents::BlockStateChangeEvent const& eventData) const;
272
273 MCAPI void onBreak(::BlockEvents::BlockBreakEvent const& eventData) const;
274
275 MCAPI void onEntityFallOn(::BlockEvents::BlockEntityFallOnEvent& eventData) const;
276
277 MCAPI void onPlace(::BlockEvents::BlockPlaceEvent const& eventData) const;
278
279 MCAPI void onPlayerBreak(::BlockEvents::BlockPlayerDestroyEvent const& eventData) const;
280
281 MCAPI void onPlayerInteract(::BlockEvents::BlockPlayerInteractEvent& eventData) const;
282
283 MCAPI void onQueuedTick(::BlockEvents::BlockQueuedTickEvent const& eventData) const;
284
285 MCAPI void onRandomTick(::BlockEvents::BlockRandomTickEvent const& eventData) const;
286
287 MCAPI void onRandomTickLegacy(::BlockEvents::BlockRandomTickLegacyEvent const& eventData) const;
288
289 MCAPI void onRedstoneUpdate(::BlockEvents::BlockRedstoneUpdateEvent const& eventData) const;
290
291 MCAPI void onStepOff(::BlockEvents::BlockStepOffEvent const& eventData) const;
292
293 MCAPI void onStepOn(::BlockEvents::BlockStepOnEvent const& eventData) const;
294
295 MCAPI void setCerealContext(::cereal::ReflectionCtx& ctx);
296
297 MCAPI ::ScriptModuleMinecraft::ScriptBlockCustomComponentInterface const*
298 tryGetRegisteredComponent(::HashedString const& name) const;
299
300 MCAPI ::Scripting::Result<
301 void,
307 tryRegisterCustomComponent(
308 ::HashedString const& name,
311 );
312
313 MCAPI ::Scripting::Result<
314 void,
320 tryRegisterCustomComponentV1(
321 ::HashedString const& name,
324 );
325 // NOLINTEND
326
327public:
328 // static functions
329 // NOLINTBEGIN
330 MCAPI static ::ScriptModuleMinecraft::ScriptCustomComponentEventMetadata<
332 _getEventMetadata();
333
334 MCAPI static void bind(::Scripting::ModuleBindingBuilder& moduleBuilder);
335
336 MCAPI static void generateOrderDocumentationForVersion(
337 ::Scripting::ModuleDescriptor const& moduleToDocumentFor,
338 ::Json::Value& eventOrderArray
339 );
340 // NOLINTEND
341
342public:
343 // constructor thunks
344 // NOLINTBEGIN
345 MCAPI void* $ctor(
347 ::ScriptDeferredEventCoordinator& deferredEventCoordinator,
349 );
350 // NOLINTEND
351
352public:
353 // destructor thunk
354 // NOLINTBEGIN
355 MCAPI void $dtor();
356 // NOLINTEND
357
358public:
359 // virtual function thunks
360 // NOLINTBEGIN
361 MCAPI void $onPreFlushAfterEvents();
362
363 MCAPI void $onFlushBlockCustomComponentAfterEvents(::ScriptDeferredFlushTracker& deferredTracker);
364
365 MCAPI void $onPostFlushAfterEvents();
366
367 MCAPI void $_onScriptInitializationComplete();
368
369 MCAPI void $_onReload();
370
371 MCAPI ::std::vector<::std::string_view> $getValidComponentsForBlock(
373 ) const;
374
375 MCAPI ::Scripting::StrongTypedObjectHandle<::ScriptModuleMinecraft::ScriptCustomComponentParameters> const&
376 $tryGetCustomComponentParametersForBlock(
377 ::Block const& block,
378 ::std::string_view componentName,
380 ) const;
381
382
383 // NOLINTEND
384
385public:
386 // vftables
387 // NOLINTBEGIN
389
391
393 // NOLINTEND
394};
395
396} // namespace ScriptModuleMinecraft
Definition EnumSet.h:8
Definition BlockCustomComponentsComponent.h:20
Definition ActorEvent.h:17
Definition BlockBreakEvent.h:19
Definition BlockEntityFallOnEvent.h:20
Definition BlockPlaceEvent.h:18
Definition BlockPlayerDestroyEvent.h:19
Definition BlockPlayerInteractEvent.h:20
Definition BlockPlayerPlacingEvent.h:20
Definition BlockQueuedTickEvent.h:18
Definition BlockRandomTickEvent.h:17
Definition BlockRandomTickLegacyEvent.h:18
Definition BlockRedstoneUpdateEvent.h:16
Definition BlockStateChangeEvent.h:17
Definition BlockStepOffEvent.h:18
Definition BlockStepOnEvent.h:18
Definition BlockType.h:84
Definition Block.h:69
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:24
Definition ScriptCustomComponentParameterCache.h:21
Definition ScriptCustomComponentRegistry.h:16
Definition ModuleBindingBuilder.h:31
Definition StrongTypedObjectHandle.h:8
Definition WeakLifetimeScope.h:14
Definition ScriptBlockCustomComponentAlreadyRegisteredError.h:16
Definition ScriptBlockCustomComponentReloadNewComponentError.h:16
Definition ScriptBlockCustomComponentReloadNewEventError.h:16
Definition ScriptBlockCustomComponentReloadVersionError.h:16
Definition ScriptCustomComponentInvalidRegistryError.h:17
Definition ScriptCustomComponentParameters.h:15
Definition ModuleDescriptor.h:7
Definition ServerScriptManagerEvents.h:13
Definition ReflectionCtx.h:11
Definition ctx.h:5