LeviLamina
Loading...
Searching...
No Matches
ParamKind.h
1#pragma once
2
3#include "ll/api/base/Meta.h"
4#include "ll/api/command/Optional.h"
5#include "ll/api/command/ParamTraits.h"
6#include "ll/api/command/Runtime/RuntimeEnum.h"
7
8#include "mc/deps/core/utility/AutomaticID.h"
9#include "mc/deps/core/utility/typeid_t.h"
10#include "mc/deps/json/Value.h"
11#include "mc/server/commands/BlockStateCommandParam.h"
12#include "mc/server/commands/Command.h"
13#include "mc/server/commands/CommandBlockName.h"
14#include "mc/server/commands/CommandFilePath.h"
15#include "mc/server/commands/CommandIntegerRange.h"
16#include "mc/server/commands/CommandItem.h"
17#include "mc/server/commands/CommandMessage.h"
18#include "mc/server/commands/CommandPositionFloat.h"
19#include "mc/server/commands/CommandRawText.h"
20#include "mc/server/commands/CommandWildcardInt.h"
21#include "mc/server/commands/RelativeFloat.h"
22#include "mc/server/commands/WildcardCommandSelector.h"
23#include "mc/world/actor/ActorDefinitionIdentifier.h"
24#include "mc/world/actor/player/Player.h"
25#include "mc/world/effect/MobEffect.h"
26
27namespace ll::command {
28
29using ParamKindType = size_t;
30
31namespace ParamKind {
32
33enum Kind : ParamKindType {
34 Int,
35 Bool,
36 Float,
37 Dimension,
38 String,
39 Enum,
40 SoftEnum,
41 Actor,
42 Player,
43 BlockPos,
44 Vec3,
45 RawText,
46 Message,
47 JsonValue,
48 Item,
49 BlockName,
50 BlockState,
51 Effect,
52 ActorType,
53 Command,
54 RelativeFloat,
55 IntegerRange,
56 FilePath,
57 WildcardInt,
58 WildcardActor,
59 // New types can only be added here, to keep the ABI stable.
60 Count,
61};
62} // namespace ParamKind
63
64using ParamKindList = meta::TypeList<
65 int,
66 bool,
67 float,
68 ::DimensionType,
69 std::string,
70 RuntimeEnum,
71 RuntimeSoftEnum,
72 CommandSelector<Actor>,
73 CommandSelector<Player>,
74 CommandPosition,
75 CommandPositionFloat,
76 CommandRawText,
77 CommandMessage,
78 Json::Value,
79 CommandItem,
80 CommandBlockName,
81 std::vector<BlockStateCommandParam>,
82 MobEffect const*,
83 ActorDefinitionIdentifier const*,
84 std::unique_ptr<::Command>,
85 RelativeFloat,
86 CommandIntegerRange,
87 CommandFilePath,
88 CommandWildcardInt,
89 WildcardCommandSelector<Actor>
90 // New types can only be added here, to keep the ABI stable.
91 >;
92
93class ParamStorageType : public Optional<ParamKindList::to<std::variant>> {
94public:
95 using Optional<ParamKindList::to<std::variant>>::Optional;
96
97 ParamKindType index() const { return mValue.index(); }
98 bool hold(ParamKindType kind) const { return has_value() && kind == index(); }
99 template <size_t N>
100 decltype(auto) get() const {
101 return std::get<N>(value());
102 }
103};
104
105} // namespace ll::command
Definition Optional.h:17
Definition ParamKind.h:93