Skip to content

Commit

Permalink
test: add molang registry test
Browse files Browse the repository at this point in the history
  • Loading branch information
Dofes committed Feb 4, 2024
1 parent 00cfe86 commit 1f3dba3
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
51 changes: 51 additions & 0 deletions src/ll/test/TestMolang.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include "mc/util/molang/MolangScriptArg.h"
#include "mc/world/level/levelgen/feature/helpers/RenderParams.h"

#include "mc/util/ExpressionNode.h"


#include "ll/api/memory/Hook.h"
#include "mc/server/commands/CommandOutput.h"
#include "mc/world/events/ServerInstanceEventCoordinator.h"

#include "ll/api/Logger.h"
#include "mc/server/commands/CommandBlockName.h"
#include "mc/world/AutomaticID.h"


namespace {
LL_AUTO_TYPE_INSTANCE_HOOK(
testtttt,
ll::memory::HookPriority::Low,
ServerInstanceEventCoordinator,
&ServerInstanceEventCoordinator::sendServerThreadStarted,
void,
::ServerInstance& ins
) {
static ll::Logger logger("MolangTest");
ExpressionNode::registerQueryFunction(
"query.is_levilamina",
[&](RenderParams&, const std::vector<ExpressionNode>&) -> MolangScriptArg { return MolangScriptArg(true); },
"query is_levilamina",
MolangQueryFunctionReturnType::Bool,
"default",
0,
UINT64_MAX,
{}
);
ExpressionNode::registerQueryFunction(
"query.homo_number",
[&](RenderParams&, const std::vector<ExpressionNode>&) -> MolangScriptArg { return MolangScriptArg(114514); },
"query homo_number",
MolangQueryFunctionReturnType::Number,
"default",
0,
UINT64_MAX,
{}
);
auto parm = RenderParams();
logger.info("query.is_levilamina: {}", ExpressionNode("query.is_levilamina").evalAsFloat(parm));
logger.info("query.homo_number: {}", ExpressionNode("query.homo_number").evalAsFloat(parm));
origin(ins);
}
} // namespace
3 changes: 1 addition & 2 deletions src/mc/util/molang/MolangMemberArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#include "mc/_HeaderOutputPredefine.h"

class MolangMemberVariable;

// auto generated inclusion list
#include "mc/util/molang/MolangStruct_BaseAndPattern.h"
#include "mc/util/molang/MolangStruct_MinAndMax.h"
Expand All @@ -19,6 +17,7 @@ class MolangMemberVariable;
#include "mc/util/molang/MolangStruct_XYZ.h"

struct MolangScriptArg;
class MolangMemberVariable;

// auto generated forward declare list
// clang-format off
Expand Down

0 comments on commit 1f3dba3

Please sign in to comment.