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,
38 String,
39 Enum,
40 SoftEnum,
41 Actor,
42 Player,
44 Vec3,
45 RawText,
46 Message,
47 JsonValue,
48 Item,
49 BlockName,
51 Effect,
52 ActorType,
53 Command,
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,
69 std::string,
70 RuntimeEnum,
71 RuntimeSoftEnum,
81 std::vector<BlockStateCommandParam>,
82 MobEffect const*,
84 std::unique_ptr<::Command>,
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 Actor.h:104
Definition AutomaticID.h:6
Definition BlockPos.h:18
Definition BlockState.h:11
Definition CommandBlockName.h:12
Definition CommandFilePath.h:5
Definition CommandIntegerRange.h:5
Definition CommandItem.h:11
Definition CommandMessage.h:15
Definition CommandPositionFloat.h:8
Definition CommandPosition.h:13
Definition CommandRawText.h:5
Definition CommandSelector.h:11
Definition CommandWildcardInt.h:5
Definition Command.h:17
Definition Dimension.h:83
Definition Item.h:65
Definition Value.h:16
Definition MobEffect.h:27
Definition Optional.h:8
Definition Player.h:119
Definition RelativeFloat.h:5
Definition Vec3.h:10
Definition WildcardCommandSelector.h:7
Definition Optional.h:17
Definition ParamKind.h:93
Definition ActorDefinitionIdentifier.h:13