LeviLamina
Loading...
Searching...
No Matches
SpawnMobEvent.h
1#pragma once
2
3#include "ll/api/event/Cancellable.h"
4#include "ll/api/event/world/WorldEvent.h"
5
6#include "mc/deps/core/math/Vec3.h"
7#include "mc/world/actor/ActorDefinitionIdentifier.h"
8#include "mc/world/actor/Mob.h"
9#include "mc/world/item/ItemStack.h"
10
11namespace ll::event::inline world {
12
13class SpawnMobEvent : public WorldEvent {
14protected:
15 ActorDefinitionIdentifier const& mIdentifier;
16 optional_ref<Actor> mSpawner;
17 Vec3 const& mPos;
18 bool& mNaturalSpawn;
19 bool& mSurface;
20 bool& mFromSpawner;
21
22 constexpr explicit SpawnMobEvent(
23 BlockSource& blockSource,
24 ActorDefinitionIdentifier const& identifier,
25 optional_ref<Actor> spawner,
26 Vec3 const& pos,
27 bool& naturalSpawn,
28 bool& surface,
29 bool& fromSpawner
30 )
31 : WorldEvent(blockSource),
32 mIdentifier(identifier),
33 mSpawner(spawner),
34 mPos(pos),
35 mNaturalSpawn(naturalSpawn),
36 mSurface(surface),
37 mFromSpawner(fromSpawner) {}
38
39public:
40 LLAPI void serialize(CompoundTag&) const override;
41
42 LLNDAPI ActorDefinitionIdentifier const& identifier() const;
43 LLNDAPI optional_ref<Actor> spawner() const;
44 LLNDAPI Vec3 const& pos() const;
45 LLNDAPI bool const& naturalSpawn() const;
46 LLNDAPI bool const& surface() const;
47 LLNDAPI bool const& fromSpawner() const;
48};
49class SpawningMobEvent final : public Cancellable<SpawnMobEvent> {
50public:
51 constexpr explicit SpawningMobEvent(
52 BlockSource& blockSource,
53 ActorDefinitionIdentifier const& identifier,
54 optional_ref<Actor> spawner,
55 Vec3 const& pos,
56 bool& naturalSpawn,
57 bool& surface,
58 bool& fromSpawner
59 )
60 : Cancellable(blockSource, identifier, spawner, pos, naturalSpawn, surface, fromSpawner) {}
61
62public:
63 LLAPI void deserialize(CompoundTag const&) override;
64
65 LLNDAPI bool& naturalSpawn() const;
66 LLNDAPI bool& surface() const;
67 LLNDAPI bool& fromSpawner() const;
68};
69class SpawnedMobEvent final : public SpawnMobEvent {
71
72public:
73 constexpr explicit SpawnedMobEvent(
75 BlockSource& blockSource,
76 ActorDefinitionIdentifier const& identifier,
77 optional_ref<Actor> spawner,
78 Vec3 const& pos,
79 bool& naturalSpawn,
80 bool& surface,
81 bool& fromSpawner
82 )
83 : SpawnMobEvent(blockSource, identifier, spawner, pos, naturalSpawn, surface, fromSpawner),
84 mMob(mob) {}
85
86public:
87 LLAPI void serialize(CompoundTag&) const override;
88
89 LLNDAPI optional_ref<Mob> mob() const;
90};
91} // namespace ll::event::inline world
Definition BlockSource.h:67
Definition CompoundTag.h:13
Definition Vec3.h:10
Definition optional_ref.h:10
Definition SpawnMobEvent.h:13
Definition SpawnMobEvent.h:69
Definition SpawnMobEvent.h:49
Definition WorldEvent.h:9
Definition ActorDefinitionIdentifier.h:13
Definition serialize.h:11