diff --git a/.clang-format b/.clang-format index 26f965d..748a9ff 100644 --- a/.clang-format +++ b/.clang-format @@ -1,6 +1,14 @@ # Author: twoone-3 # Reference: https://releases.llvm.org/13.0.0/tools/clang/docs/ClangFormatStyleOptions.html +# General Options +BasedOnStyle: LLVM +Language: Cpp +Standard: Auto +TabWidth: 4 +UseTab: ForIndentation + +# Other Options AccessModifierOffset: -4 AlignAfterOpenBracket: DontAlign AlignArrayOfStructures: Left @@ -10,31 +18,34 @@ AlignConsecutiveDeclarations: None AlignConsecutiveMacros: None AlignEscapedNewlines: Left AlignOperands: DontAlign -AlignTrailingComments: false +AlignTrailingComments: true AllowAllArgumentsOnNextLine: true AllowAllConstructorInitializersOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true AllowShortBlocksOnASingleLine: Empty AllowShortCaseLabelsOnASingleLine: true -AllowShortEnumsOnASingleLine: false +AllowShortEnumsOnASingleLine: true AllowShortFunctionsOnASingleLine: All AllowShortIfStatementsOnASingleLine: Never AllowShortLambdasOnASingleLine: All AllowShortLoopsOnASingleLine: false AlwaysBreakAfterReturnType: None AlwaysBreakTemplateDeclarations: Yes -BasedOnStyle: LLVM BinPackArguments: false BinPackParameters: false -BreakBeforeBraces: Attach +BreakBeforeBraces: Custom +BraceWrapping: + BeforeCatch: true + BeforeElse: true + BeforeWhile: true ColumnLimit: 0 Cpp11BracedListStyle: true +EmptyLineAfterAccessModifier: Leave FixNamespaceComments: true IndentCaseLabels: true IndentPPDirectives: None IndentWidth: 4 KeepEmptyLinesAtTheStartOfBlocks: false -Language: Cpp MaxEmptyLinesToKeep: 1 NamespaceIndentation: None PointerAlignment: Left @@ -45,10 +56,8 @@ SpaceAfterTemplateKeyword: true SpaceBeforeAssignmentOperators: true SpaceBeforeCtorInitializerColon: true SpaceBeforeParens: ControlStatements +SpacesBeforeTrailingComments: 0 SpaceInEmptyParentheses: false SpacesInCStyleCastParentheses: false SpacesInParentheses: false SpacesInSquareBrackets: false -Standard: Latest -TabWidth: 4 -UseTab: Always diff --git a/API/BlockAPI.cpp b/API/BlockAPI.cpp index 982d27d..e8d7491 100644 --- a/API/BlockAPI.cpp +++ b/API/BlockAPI.cpp @@ -1,4 +1,4 @@ -#include "BlockAPI.h" +#include "BlockAPI.h" #include "McAPI.h" #include "ContainerAPI.h" #include "BlockEntityAPI.h" diff --git a/API/BlockAPI.h b/API/BlockAPI.h index e3fc7a8..1be6602 100644 --- a/API/BlockAPI.h +++ b/API/BlockAPI.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include diff --git a/API/BlockEntityAPI.cpp b/API/BlockEntityAPI.cpp index f97fb2c..0b48d03 100644 --- a/API/BlockEntityAPI.cpp +++ b/API/BlockEntityAPI.cpp @@ -1,4 +1,4 @@ -#include "BlockAPI.h" +#include "BlockAPI.h" #include "BlockEntityAPI.h" #include "NBTAPI.h" #include diff --git a/API/BlockEntityAPI.h b/API/BlockEntityAPI.h index 26b1867..e9d1e34 100644 --- a/API/BlockEntityAPI.h +++ b/API/BlockEntityAPI.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include class BlockActor; @@ -8,7 +8,7 @@ struct BlockEntityClass { BlockActor* thiz; int dim; - BlockEntityClass(BlockActor* be,int dim); + BlockEntityClass(BlockActor* be, int dim); BlockPos getPos(); int getType(); diff --git a/API/CommandAPI.cpp b/API/CommandAPI.cpp index b846bbd..4c14b3a 100644 --- a/API/CommandAPI.cpp +++ b/API/CommandAPI.cpp @@ -1,4 +1,4 @@ -#include "CommandAPI.h" +#include "CommandAPI.h" #include "McAPI.h" #include "ItemAPI.h" #include "EntityAPI.h" @@ -14,68 +14,68 @@ py::object convertResult(const DynamicCommand::Result& result) { if (!result.isSet) - return py::object(); // null + return py::object();// null switch (result.type) { - case DynamicCommand::ParameterType::Bool: - return py::bool_(result.getRaw()); - case DynamicCommand::ParameterType::Int: - return py::int_(result.getRaw()); - case DynamicCommand::ParameterType::Float: - return py::float_(result.getRaw()); - case DynamicCommand::ParameterType::String: - return py::str(result.getRaw()); - case DynamicCommand::ParameterType::Actor: { - py::list arr; - for (auto i : result.get>()) { - arr.append(EntityClass(i)); + case DynamicCommand::ParameterType::Bool: + return py::bool_(result.getRaw()); + case DynamicCommand::ParameterType::Int: + return py::int_(result.getRaw()); + case DynamicCommand::ParameterType::Float: + return py::float_(result.getRaw()); + case DynamicCommand::ParameterType::String: + return py::str(result.getRaw()); + case DynamicCommand::ParameterType::Actor: { + py::list arr; + for (auto i : result.get>()) { + arr.append(EntityClass(i)); + } + return arr; } - return arr; - } - case DynamicCommand::ParameterType::Player: { - py::list arr; - for (auto i : result.get>()) { - arr.append(PlayerClass(i)); + case DynamicCommand::ParameterType::Player: { + py::list arr; + for (auto i : result.get>()) { + arr.append(PlayerClass(i)); + } + return arr; } - return arr; - } - case DynamicCommand::ParameterType::BlockPos: { - py::list arr; - arr.append(result.get()); - auto dim = result.origin->getDimension(); - arr.append(dim ? int(dim->getDimensionId()) : -1); - return arr; - } - case DynamicCommand::ParameterType::Vec3: { - py::list arr; - arr.append(result.get()); - auto dim = result.origin->getDimension(); - arr.append(dim ? int(dim->getDimensionId()) : -1); - return arr; - } - case DynamicCommand::ParameterType::Message: - return py::str(result.getRaw().getMessage(*result.origin)); - case DynamicCommand::ParameterType::RawText: - return py::str(result.getRaw()); - case DynamicCommand::ParameterType::JsonValue: - return py::str(JsonHelpers::serialize(result.getRaw())); - case DynamicCommand::ParameterType::Item: - return py::cast(ItemClass(new ItemStack(result.getRaw().createInstance(1, 1, nullptr, true).value_or(ItemInstance::EMPTY_ITEM)))); - case DynamicCommand::ParameterType::Block: - return py::cast(BlockClass(BlockInstance::createBlockInstance( - const_cast(result.getRaw()), BlockPos::MIN, -1))); - case DynamicCommand::ParameterType::Effect: - return py::str(result.getRaw()->getResourceName()); - case DynamicCommand::ParameterType::Enum: - return py::str(result.getRaw()); - case DynamicCommand::ParameterType::SoftEnum: - return py::str(result.getRaw()); - case DynamicCommand::ParameterType::Command: - return py::str(result.getRaw>()->getCommandName()); - case DynamicCommand::ParameterType::ActorType: - return py::str(result.getRaw()->getCanonicalName()); - default: - return py::object(); // null - break; + case DynamicCommand::ParameterType::BlockPos: { + py::list arr; + arr.append(result.get()); + auto dim = result.origin->getDimension(); + arr.append(dim ? int(dim->getDimensionId()) : -1); + return arr; + } + case DynamicCommand::ParameterType::Vec3: { + py::list arr; + arr.append(result.get()); + auto dim = result.origin->getDimension(); + arr.append(dim ? int(dim->getDimensionId()) : -1); + return arr; + } + case DynamicCommand::ParameterType::Message: + return py::str(result.getRaw().getMessage(*result.origin)); + case DynamicCommand::ParameterType::RawText: + return py::str(result.getRaw()); + case DynamicCommand::ParameterType::JsonValue: + return py::str(JsonHelpers::serialize(result.getRaw())); + case DynamicCommand::ParameterType::Item: + return py::cast(ItemClass(new ItemStack(result.getRaw().createInstance(1, 1, nullptr, true).value_or(ItemInstance::EMPTY_ITEM)))); + case DynamicCommand::ParameterType::Block: + return py::cast(BlockClass(BlockInstance::createBlockInstance( + const_cast(result.getRaw()), BlockPos::MIN, -1))); + case DynamicCommand::ParameterType::Effect: + return py::str(result.getRaw()->getResourceName()); + case DynamicCommand::ParameterType::Enum: + return py::str(result.getRaw()); + case DynamicCommand::ParameterType::SoftEnum: + return py::str(result.getRaw()); + case DynamicCommand::ParameterType::Command: + return py::str(result.getRaw>()->getCommandName()); + case DynamicCommand::ParameterType::ActorType: + return py::str(result.getRaw()->getCanonicalName()); + default: + return py::object();// null + break; } } @@ -157,13 +157,12 @@ bool CommandClass::setCallback(const py::function& cb) { if (thiz == nullptr) return false; thiz->setCallback( - [cb](const DynamicCommand& command, const CommandOrigin& origin, - CommandOutput& output, std::unordered_map& results) { - PY_TRY; - py::gil_scoped_acquire gil_; - cb(CommandOriginClass(const_cast(&origin)), results); - PY_CATCH; - }); + [cb](const DynamicCommand& command, const CommandOrigin& origin, CommandOutput& output, std::unordered_map& results) { + PY_TRY; + py::gil_scoped_acquire gil_; + cb(CommandOriginClass(const_cast(&origin)), results); + PY_CATCH; + }); return true; } diff --git a/API/CommandAPI.h b/API/CommandAPI.h index f794c0b..0c95402 100644 --- a/API/CommandAPI.h +++ b/API/CommandAPI.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include @@ -11,17 +11,13 @@ struct CommandClass { string getName(); bool setAlias(const string& alias); // name, type, description, identifier, option - int64_t mandatory(const string& name, DynamicCommand::ParameterType type, - string description = "", string identifier = "", CommandParameterOption option = None); + int64_t mandatory(const string& name, DynamicCommand::ParameterType type, string description = "", string identifier = "", CommandParameterOption option = None); // name, type, description, option - int64_t mandatory(const string& name, DynamicCommand::ParameterType type, - string description = "", CommandParameterOption option = None); + int64_t mandatory(const string& name, DynamicCommand::ParameterType type, string description = "", CommandParameterOption option = None); // name, type, description, identifier, option - int64_t optional(const string& name, DynamicCommand::ParameterType type, - string description = "", string identifier = "", CommandParameterOption option = None); + int64_t optional(const string& name, DynamicCommand::ParameterType type, string description = "", string identifier = "", CommandParameterOption option = None); // name, type, description, option - int64_t optional(const string& name, DynamicCommand::ParameterType type, - string description = "", CommandParameterOption option = None); + int64_t optional(const string& name, DynamicCommand::ParameterType type, string description = "", CommandParameterOption option = None); bool addOverload(); // vector bool addOverload(const vector& args); @@ -33,10 +29,10 @@ struct CommandClass { bool setup(); string toString(); - // SoftEnum Ǵȫַ - // ȫʵʱ - // ͬѡܽӲͬ - // Enum + // SoftEnum 是带补全的字符串 + // 补全项可以实时更改 + // 不同选项不能接不同参数 + // Enum 则可以做到 // cmd name // cmd // cmd name name2 @@ -48,4 +44,3 @@ struct CommandClass { vector getSoftEnumValues(const string& name); vector getSoftEnumNames(); }; - diff --git a/API/CommandOriginAPI.cpp b/API/CommandOriginAPI.cpp index 6f2b381..79553e9 100644 --- a/API/CommandOriginAPI.cpp +++ b/API/CommandOriginAPI.cpp @@ -1,4 +1,4 @@ -#include "CommandOriginAPI.h" +#include "CommandOriginAPI.h" #include "NBTAPI.h" #include "EntityAPI.h" #include "BlockAPI.h" diff --git a/API/CommandOriginAPI.h b/API/CommandOriginAPI.h index 85b3b87..6f4a2fa 100644 --- a/API/CommandOriginAPI.h +++ b/API/CommandOriginAPI.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include struct EntityClass; diff --git a/API/CommandOutputAPI.cpp b/API/CommandOutputAPI.cpp index 10278b2..66eda1a 100644 --- a/API/CommandOutputAPI.cpp +++ b/API/CommandOutputAPI.cpp @@ -1,7 +1,6 @@ -#include "CommandOutputAPI.h" +#include "CommandOutputAPI.h" #include - CommandOutputClass::CommandOutputClass(CommandOutput* p) : thiz(p) {} bool CommandOutputClass::empty() { diff --git a/API/CommandOutputAPI.h b/API/CommandOutputAPI.h index 277feed..37de369 100644 --- a/API/CommandOutputAPI.h +++ b/API/CommandOutputAPI.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include class CommandOutput; diff --git a/API/ContainerAPI.h b/API/ContainerAPI.h index 44a3111..1f041f9 100644 --- a/API/ContainerAPI.h +++ b/API/ContainerAPI.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include class Container; diff --git a/API/EntityAPI.cpp b/API/EntityAPI.cpp index ba7a2cf..ea4eb03 100644 --- a/API/EntityAPI.cpp +++ b/API/EntityAPI.cpp @@ -1,4 +1,4 @@ -#include "BlockAPI.h" +#include "BlockAPI.h" #include "EntityAPI.h" #include "PlayerAPI.h" #include "ItemAPI.h" @@ -82,7 +82,7 @@ float EntityClass::getSpeed() { Vec2 EntityClass::getDirection() { if (thiz == nullptr) - return Vec2(0.f,0.f); + return Vec2(0.f, 0.f); return *thiz->getDirection(); } @@ -219,7 +219,7 @@ EntityClass EntityClass::getEntityFromViewVector(float maxDistance) { return thiz->getActorFromViewVector(maxDistance); } -BlockClass EntityClass::getBlockFromViewVector(bool includeLiquid, bool solidOnly, float maxDistance, bool ignoreBorderBlocks, bool fullOnly) { +BlockClass EntityClass::getBlockFromViewVector(bool includeLiquid, bool solidOnly, float maxDistance, bool ignoreBorderBlocks, bool fullOnly) { if (thiz == nullptr) return BlockInstance::Null; return thiz->getBlockFromViewVector(includeLiquid, solidOnly, maxDistance, ignoreBorderBlocks, fullOnly); diff --git a/API/EntityAPI.h b/API/EntityAPI.h index c14945c..702b482 100644 --- a/API/EntityAPI.h +++ b/API/EntityAPI.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include class Actor; @@ -49,9 +49,9 @@ struct EntityClass { vector getAllTags(); EntityClass getEntityFromViewVector(float maxDistance = 5.25f); BlockClass getBlockFromViewVector( - bool includeLiquid = false, - bool solidOnly = false, - float maxDistance = 5.25f, - bool ignoreBorderBlocks = true, - bool fullOnly = false); + bool includeLiquid = false, + bool solidOnly = false, + float maxDistance = 5.25f, + bool ignoreBorderBlocks = true, + bool fullOnly = false); }; \ No newline at end of file diff --git a/API/EventAPI.cpp b/API/EventAPI.cpp index 3e71e3d..157d26f 100644 --- a/API/EventAPI.cpp +++ b/API/EventAPI.cpp @@ -21,7 +21,7 @@ class Callbacker { bool callback() { bool pass = true; - arg_.inc_ref(); // TODO: 为什么需要增加引用计数? + arg_.inc_ref();// TODO: 为什么需要增加引用计数? for (auto& cb : listeners[type_]) { PY_TRY; py::gil_scoped_acquire gil_; @@ -66,578 +66,578 @@ void EnableEventListener(EventCode event_code) { using namespace Event; switch (event_code) { - case EventCode::onJoin: - Event::PlayerJoinEvent::subscribe([](const PlayerJoinEvent& ev) { - EVENT_BEGIN(EventCode::onJoin); - EVENT_INSERT(Player); - EVENT_END; - }); - break; - - case EventCode::onPreJoin: - Event::PlayerPreJoinEvent::subscribe([](const PlayerPreJoinEvent& ev) { - EVENT_BEGIN(EventCode::onPreJoin); - EVENT_INSERT(IP); - EVENT_INSERT(Player); - EVENT_INSERT(XUID); - EVENT_END; - }); - break; - - case EventCode::onLeft: - Event::PlayerLeftEvent::subscribe([](const PlayerLeftEvent& ev) { - EVENT_BEGIN(EventCode::onLeft); - EVENT_INSERT(Player); - EVENT_END; - }); - break; - - case EventCode::onChat: - Event::PlayerChatEvent::subscribe([](const PlayerChatEvent& ev) { - EVENT_BEGIN(EventCode::onChat); - EVENT_INSERT(Player); - EVENT_INSERT(Message); - EVENT_END; - }); - break; - - case EventCode::onChangeDim: - Event::PlayerChangeDimEvent::subscribe([](const PlayerChangeDimEvent& ev) { - EVENT_BEGIN(EventCode::onChangeDim); - EVENT_INSERT(Player); - EVENT_INSERT(ToDimensionId); - EVENT_END; - }); - break; - - case EventCode::onAttackEntity: - Event::PlayerAttackEvent::subscribe([](const PlayerAttackEvent& ev) { - EVENT_BEGIN(EventCode::onAttackEntity); - EVENT_INSERT(Player); - EVENT_INSERT(Target); - EVENT_END; - }); - break; - - case EventCode::onAttackBlock: - Event::PlayerAttackBlockEvent::subscribe([](const PlayerAttackBlockEvent& ev) { - EVENT_BEGIN(EventCode::onAttackBlock); - EVENT_INSERT(BlockInstance); - EVENT_INSERT(ItemStack); - EVENT_INSERT(Player); - EVENT_END; - }); - break; - - case EventCode::onPlayerDie: - Event::PlayerDieEvent::subscribe([](const PlayerDieEvent& ev) { - EVENT_BEGIN(EventCode::onPlayerDie); - EVENT_INSERT_EX(Cause, magic_enum::enum_name(ev.mDamageSource->getCause())); - EVENT_INSERT_EX(Entity, EntityClass(ev.mDamageSource->getEntity())); - EVENT_INSERT(Player); - EVENT_END; - }); - break; - - case EventCode::onRespawn: - Event::PlayerRespawnEvent::subscribe([](const PlayerRespawnEvent& ev) { - EVENT_BEGIN(EventCode::onRespawn); - EVENT_INSERT(Player); - EVENT_END; - }); - break; - - case EventCode::onStartDestroyBlock: - Event::PlayerStartDestroyBlockEvent::subscribe([](const PlayerStartDestroyBlockEvent& ev) { - EVENT_BEGIN(EventCode::onStartDestroyBlock); - EVENT_INSERT(Player); - EVENT_INSERT(BlockInstance); - EVENT_END; - }); - break; - - case EventCode::onDestroyBlock: - Event::PlayerDestroyBlockEvent::subscribe([](const PlayerDestroyBlockEvent& ev) { - EVENT_BEGIN(EventCode::onDestroyBlock); - EVENT_INSERT(Player); - EVENT_INSERT(BlockInstance); - EVENT_END; - }); - break; - - case EventCode::onPlaceBlock: - Event::PlayerPlaceBlockEvent::subscribe([](const PlayerPlaceBlockEvent& ev) { - EVENT_BEGIN(EventCode::onPlaceBlock); - EVENT_INSERT(Player); - EVENT_INSERT(BlockInstance); - EVENT_END; - }); - break; - - case EventCode::onMove: - Event::PlayerMoveEvent::subscribe([](const PlayerMoveEvent& ev) { - EVENT_BEGIN(EventCode::onMove); - EVENT_INSERT(Player); - EVENT_INSERT(Pos); - EVENT_END; - }); - break; - - case EventCode::onJump: - Event::PlayerJumpEvent::subscribe([](const PlayerJumpEvent& ev) { - EVENT_BEGIN(EventCode::onJump); - EVENT_INSERT(Player); - EVENT_END; - }); - break; - - case EventCode::onDropItem: - Event::PlayerDropItemEvent::subscribe([](const PlayerDropItemEvent& ev) { - EVENT_BEGIN(EventCode::onDropItem); - EVENT_INSERT(Player); - EVENT_INSERT(ItemStack); - EVENT_END; - }); - break; - - case EventCode::onTakeItem: - Event::PlayerPickupItemEvent::subscribe([](const PlayerPickupItemEvent& ev) { - EVENT_BEGIN(EventCode::onTakeItem); - EVENT_INSERT(Player); - EVENT_INSERT(ItemEntity); - EVENT_INSERT(ItemStack); - EVENT_END; - }); - break; - - case EventCode::onOpenContainer: - Event::PlayerOpenContainerEvent::subscribe([](const PlayerOpenContainerEvent& ev) { - EVENT_BEGIN(EventCode::onOpenContainer); - EVENT_INSERT(BlockInstance); - EVENT_INSERT(Player); - EVENT_INSERT(Container); - EVENT_END; - }); - break; - - case EventCode::onCloseContainer: - Event::PlayerCloseContainerEvent::subscribe([](const PlayerCloseContainerEvent& ev) { - EVENT_BEGIN(EventCode::onCloseContainer); - EVENT_INSERT(BlockInstance); - EVENT_INSERT(Player); - EVENT_INSERT(Container); - EVENT_END; - }); - break; - - case EventCode::onInventoryChange: - Event::PlayerInventoryChangeEvent::subscribe([](const PlayerInventoryChangeEvent& ev) { - EVENT_BEGIN(EventCode::onInventoryChange); - EVENT_INSERT(NewItemStack); - EVENT_INSERT(Player); - EVENT_INSERT(PreviousItemStack); - EVENT_INSERT(Slot); - EVENT_END; - }); - break; - - case EventCode::onUseItem: - Event::PlayerUseItemEvent::subscribe([](const PlayerUseItemEvent& ev) { - EVENT_BEGIN(EventCode::onUseItem); - EVENT_INSERT(Player); - EVENT_INSERT(ItemStack); - EVENT_END; - }); - break; - - case EventCode::onUseItemOn: - Event::PlayerUseItemOnEvent::subscribe([](const PlayerUseItemOnEvent& ev) { - EVENT_BEGIN(EventCode::onUseItemOn); - EVENT_INSERT(Player); - EVENT_INSERT(ItemStack); - EVENT_INSERT(BlockInstance); - EVENT_INSERT(Face); - EVENT_END; - }); - break; - - case EventCode::onContainerChange: - Event::ContainerChangeEvent::subscribe([](const ContainerChangeEvent& ev) { - EVENT_BEGIN(EventCode::onContainerChange); - EVENT_INSERT(Player); - EVENT_INSERT(Actor); - EVENT_INSERT(Container); - EVENT_INSERT(Slot); - EVENT_INSERT(NewItemStack); - EVENT_INSERT(PreviousItemStack); - EVENT_END; - }); - break; - - case EventCode::onChangeArmorStand: - Event::ArmorStandChangeEvent::subscribe([](const ArmorStandChangeEvent& ev) { - EVENT_BEGIN(EventCode::onChangeArmorStand); - EVENT_INSERT(Player); - EVENT_INSERT_EX(ArmorStand, EntityClass((Actor*)ev.mArmorStand)); - EVENT_INSERT(Slot); - EVENT_END; - }); - break; - - case EventCode::onChangeSprinting: - Event::PlayerSprintEvent::subscribe([](const PlayerSprintEvent& ev) { - EVENT_BEGIN(EventCode::onChangeSprinting); - EVENT_INSERT(Player); - EVENT_INSERT(IsSprinting); - EVENT_END; - }); - break; - - case EventCode::onSneak: - Event::PlayerSneakEvent::subscribe([](const PlayerSneakEvent& ev) { - EVENT_BEGIN(EventCode::onSneak); - EVENT_INSERT(Player); - EVENT_INSERT(IsSneaking); - EVENT_END; - }); - break; - - case EventCode::onOpenContainerScreen: - Event::PlayerOpenContainerScreenEvent::subscribe([](const PlayerOpenContainerScreenEvent& ev) { - EVENT_BEGIN(EventCode::onOpenContainerScreen); - EVENT_INSERT(Player); - EVENT_END; - }); - break; - - case EventCode::onSetArmor: - Event::PlayerSetArmorEvent::subscribe([](const PlayerSetArmorEvent& ev) { - EVENT_BEGIN(EventCode::onSetArmor); - EVENT_INSERT(Player); - EVENT_INSERT(Slot); - EVENT_INSERT(ArmorItem); - EVENT_END; - }); - break; - - case EventCode::onEat: - Event::PlayerEatEvent::subscribe([](const PlayerEatEvent& ev) { - EVENT_BEGIN(EventCode::onEat); - EVENT_INSERT(Player); - EVENT_INSERT(FoodItem); - EVENT_END; - }); - break; - - case EventCode::onConsumeTotem: - Event::PlayerConsumeTotemEvent::subscribe([](const PlayerConsumeTotemEvent& ev) { - EVENT_BEGIN(EventCode::onConsumeTotem); - EVENT_INSERT(Player); - EVENT_END; - }); - break; - - case EventCode::onEffectChanged: - Event::PlayerEffectChangedEvent::subscribe([](const PlayerEffectChangedEvent& ev) { - EVENT_BEGIN(EventCode::onEffectChanged); - EVENT_INSERT(Player); - EVENT_INSERT(Effect); - EVENT_INSERT(EventType); - EVENT_END; - }); - break; - - case EventCode::onUseRespawnAnchor: - Event::PlayerUseRespawnAnchorEvent::subscribe([](const PlayerUseRespawnAnchorEvent& ev) { - EVENT_BEGIN(EventCode::onUseRespawnAnchor); - EVENT_INSERT(Player); - EVENT_INSERT(BlockInstance); - EVENT_END; - }); - break; - - case EventCode::onRide: - Event::EntityRideEvent::subscribe([](const EntityRideEvent& ev) { - EVENT_BEGIN(EventCode::onRide); - EVENT_INSERT(Rider); - EVENT_INSERT(Vehicle); - EVENT_END; - }); - break; - - case EventCode::onEntityExplode: - Event::EntityExplodeEvent::subscribe([](const EntityExplodeEvent& ev) { - EVENT_BEGIN(EventCode::onEntityExplode); - EVENT_INSERT(Actor); - EVENT_INSERT(Pos); - EVENT_INSERT_EX(Dim, ev.mDimension->getDimensionId()); - EVENT_INSERT(Radius); - EVENT_INSERT(MaxResistance); - EVENT_INSERT(Breaking); - EVENT_INSERT(Fire); - EVENT_END; - }); - break; - - case EventCode::onBlockExplode: - Event::BlockExplodeEvent::subscribe([](const BlockExplodeEvent& ev) { - EVENT_BEGIN(EventCode::onBlockExplode); - EVENT_INSERT(BlockInstance); - EVENT_INSERT(Radius); - EVENT_INSERT(MaxResistance); - EVENT_INSERT(Breaking); - EVENT_INSERT(Fire); - EVENT_END; - }); - break; - - case EventCode::onBlockExploded: - Event::BlockExplodedEvent::subscribe([](const BlockExplodedEvent& ev) { - EVENT_BEGIN(EventCode::onBlockExploded); - EVENT_INSERT(BlockInstance); - EVENT_INSERT(ExplodeSource); - EVENT_END; - }); - break; - - case EventCode::onCmdBlockExecute: - Event::CmdBlockExecuteEvent::subscribe([](const CmdBlockExecuteEvent& ev) { - EVENT_BEGIN(EventCode::onCmdBlockExecute); - EVENT_INSERT(BlockInstance); - EVENT_INSERT(Command); - EVENT_INSERT(IsMinecart); - EVENT_INSERT(Minecart); - EVENT_END; - }); - break; - - case EventCode::onRedStoneUpdate: - Event::RedStoneUpdateEvent::subscribe([](const RedStoneUpdateEvent& ev) { - EVENT_BEGIN(EventCode::onRedStoneUpdate); - EVENT_INSERT(BlockInstance); - EVENT_INSERT(RedStonePower); - EVENT_INSERT(IsActivated); - EVENT_END; - }); - break; - - case EventCode::onWitherBossDestroy: - Event::WitherBossDestroyEvent::subscribe([](const WitherBossDestroyEvent& ev) { - EVENT_BEGIN(EventCode::onWitherBossDestroy); - EVENT_INSERT_EX(WitherBoss, EntityClass((Actor*)ev.mWitherBoss)); - EVENT_INSERT_EX(Min, ev.mDestroyRange.min); - EVENT_INSERT_EX(Max, ev.mDestroyRange.max); - EVENT_END; - }); - break; - - case EventCode::onMobHurt: - Event::MobHurtEvent::subscribe([](const MobHurtEvent& ev) { - EVENT_BEGIN(EventCode::onMobHurt); - EVENT_INSERT_EX(Mob, EntityClass(ev.mMob)); - EVENT_INSERT(Damage); - EVENT_INSERT_EX(Cause, magic_enum::enum_name(ev.mDamageSource->getCause())); - EVENT_INSERT_EX(Entity, EntityClass(ev.mDamageSource->getEntity())); - EVENT_END; - }); - break; - - case EventCode::onStepOnPressurePlate: - Event::EntityStepOnPressurePlateEvent::subscribe([](const EntityStepOnPressurePlateEvent& ev) { - EVENT_BEGIN(EventCode::onStepOnPressurePlate); - EVENT_INSERT(Actor); - EVENT_INSERT(BlockInstance); - EVENT_END; - }); - break; - - case EventCode::onMobDie: - Event::MobDieEvent::subscribe([](const MobDieEvent& ev) { - EVENT_BEGIN(EventCode::onMobDie); - EVENT_INSERT_EX(Mob, EntityClass(ev.mMob)); - EVENT_INSERT_EX(Cause, magic_enum::enum_name(ev.mDamageSource->getCause())); - EVENT_INSERT_EX(Entity, EntityClass(ev.mDamageSource->getEntity())); - EVENT_END; - }); - break; - - case EventCode::onNpcCmd: - Event::NpcCmdEvent::subscribe([](const NpcCmdEvent& ev) { - EVENT_BEGIN(EventCode::onNpcCmd); - EVENT_INSERT(Npc); - EVENT_INSERT(Player); - EVENT_INSERT(Command); - EVENT_END; - }); - break; - - case EventCode::onSpawnProjectile: - Event::ProjectileSpawnEvent::subscribe([](const ProjectileSpawnEvent& ev) { - EVENT_BEGIN(EventCode::onSpawnProjectile); - EVENT_INSERT(Shooter); - // idf... - EVENT_INSERT(Type); - EVENT_END; - }); - break; - - case EventCode::onProjectileCreated: - Event::ProjectileCreatedEvent::subscribe([](const ProjectileCreatedEvent& ev) { - EVENT_BEGIN(EventCode::onProjectileCreated); - EVENT_INSERT(Shooter); - EVENT_INSERT(Projectile); - EVENT_END; - }); - break; - - case EventCode::onProjectileHitEntity: - Event::ProjectileHitEntityEvent::subscribe([](const ProjectileHitEntityEvent& ev) { - EVENT_BEGIN(EventCode::onProjectileHitEntity); - EVENT_INSERT(Target); - EVENT_INSERT(Source); - EVENT_END; - }); - break; - - case EventCode::onEntityTransformation: - Event::EntityTransformEvent::subscribe([](const EntityTransformEvent& ev) { - EVENT_BEGIN(EventCode::onEntityTransformation); - EVENT_INSERT_EX(EntityId, to_string(ev.mBeforeEntityUniqueId->id)); - EVENT_INSERT(AfterEntity); - EVENT_END; - }); - break; - - case EventCode::onProjectileHitBlock: - Event::ProjectileHitBlockEvent::subscribe([](const ProjectileHitBlockEvent& ev) { - EVENT_BEGIN(EventCode::onProjectileHitBlock); - EVENT_INSERT(BlockInstance); - EVENT_INSERT(Source); - EVENT_END; - }); - break; - - case EventCode::onLiquidFlow: - Event::LiquidSpreadEvent::subscribe([](const LiquidSpreadEvent& ev) { - EVENT_BEGIN(EventCode::onLiquidFlow); - EVENT_INSERT(BlockInstance); - EVENT_INSERT(Target); - EVENT_INSERT(DimensionId); - EVENT_END; - }); - break; - - case EventCode::onUseFrameBlock: - Event::PlayerUseFrameBlockEvent::subscribe([](const PlayerUseFrameBlockEvent& ev) { - EVENT_BEGIN(EventCode::onUseFrameBlock); - EVENT_INSERT(Player); - EVENT_INSERT(BlockInstance); - EVENT_END; - }); - break; - - case EventCode::onBlockInteracted: - Event::BlockInteractedEvent::subscribe([](const BlockInteractedEvent& ev) { - EVENT_BEGIN(EventCode::onBlockInteracted); - EVENT_INSERT(Player); - EVENT_INSERT(BlockInstance); - EVENT_END; - }); - break; - - case EventCode::onFarmLandDecay: - Event::FarmLandDecayEvent::subscribe([](const FarmLandDecayEvent& ev) { - EVENT_BEGIN(EventCode::onFarmLandDecay); - EVENT_INSERT(BlockInstance); - EVENT_INSERT(Actor); - EVENT_END; - }); - break; - - case EventCode::onPistonTryPush: - Event::PistonTryPushEvent::subscribe([](const PistonTryPushEvent& ev) { - EVENT_BEGIN(EventCode::onPistonTryPush); - EVENT_INSERT(PistonBlockInstance); - EVENT_INSERT(TargetBlockInstance); - EVENT_END; - }); - break; - - case EventCode::onPistonPush: - Event::PistonPushEvent::subscribe([](const PistonPushEvent& ev) { - EVENT_BEGIN(EventCode::onPistonPush); - EVENT_INSERT(PistonBlockInstance); - EVENT_INSERT(TargetBlockInstance); - EVENT_END; - }); - break; - - case EventCode::onHopperSearchItem: - Event::HopperSearchItemEvent::subscribe([](const HopperSearchItemEvent& ev) { - EVENT_BEGIN(EventCode::onHopperSearchItem); - EVENT_INSERT_EX(isMinecart, ev.isMinecart); - EVENT_INSERT(HopperBlock); - EVENT_INSERT(MinecartPos); - EVENT_INSERT(DimensionId); - EVENT_END; - }); - break; - - case EventCode::onHopperPushOut: - Event::HopperPushOutEvent::subscribe([](const HopperPushOutEvent& ev) { - EVENT_BEGIN(EventCode::onHopperPushOut); - EVENT_INSERT(Pos); - EVENT_INSERT(DimensionId); - EVENT_END; - }); - break; - - case EventCode::onFireSpread: - Event::FireSpreadEvent::subscribe([](const FireSpreadEvent& ev) { - EVENT_BEGIN(EventCode::onFireSpread); - EVENT_INSERT(Target); - EVENT_INSERT(DimensionId); - EVENT_END; - }); - break; - - case EventCode::onBlockChanged: - Event::BlockChangedEvent::subscribe([](const BlockChangedEvent& ev) { - EVENT_BEGIN(EventCode::onBlockChanged); - EVENT_INSERT(PreviousBlockInstance); - EVENT_INSERT(NewBlockInstance); - EVENT_END; - }); - break; - - case EventCode::onScoreChanged: - Event::PlayerScoreChangedEvent::subscribe([](const PlayerScoreChangedEvent& ev) { - EVENT_BEGIN(EventCode::onScoreChanged); - EVENT_INSERT(Player); - EVENT_INSERT(Score); - EVENT_INSERT_EX(Objective, ObjectiveClass(ev.mObjective)); - // ScoreboardId - EVENT_END; - }); - break; - - case EventCode::onConsoleOutput: - Event::ConsoleOutputEvent::subscribe([](const ConsoleOutputEvent& ev) { - EVENT_BEGIN(EventCode::onConsoleOutput); - EVENT_INSERT(Output); - EVENT_END; - }); - break; - case EventCode::onMobSpawn: - Event::MobSpawnEvent::subscribe([](const MobSpawnEvent& ev) { - EVENT_BEGIN(EventCode::onMobSpawn); - EVENT_INSERT(TypeName); - EVENT_INSERT(Pos); - EVENT_INSERT(DimensionId); - EVENT_END; - }); - break; - default: - break; + case EventCode::onJoin: + Event::PlayerJoinEvent::subscribe([](const PlayerJoinEvent& ev) { + EVENT_BEGIN(EventCode::onJoin); + EVENT_INSERT(Player); + EVENT_END; + }); + break; + + case EventCode::onPreJoin: + Event::PlayerPreJoinEvent::subscribe([](const PlayerPreJoinEvent& ev) { + EVENT_BEGIN(EventCode::onPreJoin); + EVENT_INSERT(IP); + EVENT_INSERT(Player); + EVENT_INSERT(XUID); + EVENT_END; + }); + break; + + case EventCode::onLeft: + Event::PlayerLeftEvent::subscribe([](const PlayerLeftEvent& ev) { + EVENT_BEGIN(EventCode::onLeft); + EVENT_INSERT(Player); + EVENT_END; + }); + break; + + case EventCode::onChat: + Event::PlayerChatEvent::subscribe([](const PlayerChatEvent& ev) { + EVENT_BEGIN(EventCode::onChat); + EVENT_INSERT(Player); + EVENT_INSERT(Message); + EVENT_END; + }); + break; + + case EventCode::onChangeDim: + Event::PlayerChangeDimEvent::subscribe([](const PlayerChangeDimEvent& ev) { + EVENT_BEGIN(EventCode::onChangeDim); + EVENT_INSERT(Player); + EVENT_INSERT(ToDimensionId); + EVENT_END; + }); + break; + + case EventCode::onAttackEntity: + Event::PlayerAttackEvent::subscribe([](const PlayerAttackEvent& ev) { + EVENT_BEGIN(EventCode::onAttackEntity); + EVENT_INSERT(Player); + EVENT_INSERT(Target); + EVENT_END; + }); + break; + + case EventCode::onAttackBlock: + Event::PlayerAttackBlockEvent::subscribe([](const PlayerAttackBlockEvent& ev) { + EVENT_BEGIN(EventCode::onAttackBlock); + EVENT_INSERT(BlockInstance); + EVENT_INSERT(ItemStack); + EVENT_INSERT(Player); + EVENT_END; + }); + break; + + case EventCode::onPlayerDie: + Event::PlayerDieEvent::subscribe([](const PlayerDieEvent& ev) { + EVENT_BEGIN(EventCode::onPlayerDie); + EVENT_INSERT_EX(Cause, magic_enum::enum_name(ev.mDamageSource->getCause())); + EVENT_INSERT_EX(Entity, EntityClass(ev.mDamageSource->getEntity())); + EVENT_INSERT(Player); + EVENT_END; + }); + break; + + case EventCode::onRespawn: + Event::PlayerRespawnEvent::subscribe([](const PlayerRespawnEvent& ev) { + EVENT_BEGIN(EventCode::onRespawn); + EVENT_INSERT(Player); + EVENT_END; + }); + break; + + case EventCode::onStartDestroyBlock: + Event::PlayerStartDestroyBlockEvent::subscribe([](const PlayerStartDestroyBlockEvent& ev) { + EVENT_BEGIN(EventCode::onStartDestroyBlock); + EVENT_INSERT(Player); + EVENT_INSERT(BlockInstance); + EVENT_END; + }); + break; + + case EventCode::onDestroyBlock: + Event::PlayerDestroyBlockEvent::subscribe([](const PlayerDestroyBlockEvent& ev) { + EVENT_BEGIN(EventCode::onDestroyBlock); + EVENT_INSERT(Player); + EVENT_INSERT(BlockInstance); + EVENT_END; + }); + break; + + case EventCode::onPlaceBlock: + Event::PlayerPlaceBlockEvent::subscribe([](const PlayerPlaceBlockEvent& ev) { + EVENT_BEGIN(EventCode::onPlaceBlock); + EVENT_INSERT(Player); + EVENT_INSERT(BlockInstance); + EVENT_END; + }); + break; + + case EventCode::onMove: + Event::PlayerMoveEvent::subscribe([](const PlayerMoveEvent& ev) { + EVENT_BEGIN(EventCode::onMove); + EVENT_INSERT(Player); + EVENT_INSERT(Pos); + EVENT_END; + }); + break; + + case EventCode::onJump: + Event::PlayerJumpEvent::subscribe([](const PlayerJumpEvent& ev) { + EVENT_BEGIN(EventCode::onJump); + EVENT_INSERT(Player); + EVENT_END; + }); + break; + + case EventCode::onDropItem: + Event::PlayerDropItemEvent::subscribe([](const PlayerDropItemEvent& ev) { + EVENT_BEGIN(EventCode::onDropItem); + EVENT_INSERT(Player); + EVENT_INSERT(ItemStack); + EVENT_END; + }); + break; + + case EventCode::onTakeItem: + Event::PlayerPickupItemEvent::subscribe([](const PlayerPickupItemEvent& ev) { + EVENT_BEGIN(EventCode::onTakeItem); + EVENT_INSERT(Player); + EVENT_INSERT(ItemEntity); + EVENT_INSERT(ItemStack); + EVENT_END; + }); + break; + + case EventCode::onOpenContainer: + Event::PlayerOpenContainerEvent::subscribe([](const PlayerOpenContainerEvent& ev) { + EVENT_BEGIN(EventCode::onOpenContainer); + EVENT_INSERT(BlockInstance); + EVENT_INSERT(Player); + EVENT_INSERT(Container); + EVENT_END; + }); + break; + + case EventCode::onCloseContainer: + Event::PlayerCloseContainerEvent::subscribe([](const PlayerCloseContainerEvent& ev) { + EVENT_BEGIN(EventCode::onCloseContainer); + EVENT_INSERT(BlockInstance); + EVENT_INSERT(Player); + EVENT_INSERT(Container); + EVENT_END; + }); + break; + + case EventCode::onInventoryChange: + Event::PlayerInventoryChangeEvent::subscribe([](const PlayerInventoryChangeEvent& ev) { + EVENT_BEGIN(EventCode::onInventoryChange); + EVENT_INSERT(NewItemStack); + EVENT_INSERT(Player); + EVENT_INSERT(PreviousItemStack); + EVENT_INSERT(Slot); + EVENT_END; + }); + break; + + case EventCode::onUseItem: + Event::PlayerUseItemEvent::subscribe([](const PlayerUseItemEvent& ev) { + EVENT_BEGIN(EventCode::onUseItem); + EVENT_INSERT(Player); + EVENT_INSERT(ItemStack); + EVENT_END; + }); + break; + + case EventCode::onUseItemOn: + Event::PlayerUseItemOnEvent::subscribe([](const PlayerUseItemOnEvent& ev) { + EVENT_BEGIN(EventCode::onUseItemOn); + EVENT_INSERT(Player); + EVENT_INSERT(ItemStack); + EVENT_INSERT(BlockInstance); + EVENT_INSERT(Face); + EVENT_END; + }); + break; + + case EventCode::onContainerChange: + Event::ContainerChangeEvent::subscribe([](const ContainerChangeEvent& ev) { + EVENT_BEGIN(EventCode::onContainerChange); + EVENT_INSERT(Player); + EVENT_INSERT(Actor); + EVENT_INSERT(Container); + EVENT_INSERT(Slot); + EVENT_INSERT(NewItemStack); + EVENT_INSERT(PreviousItemStack); + EVENT_END; + }); + break; + + case EventCode::onChangeArmorStand: + Event::ArmorStandChangeEvent::subscribe([](const ArmorStandChangeEvent& ev) { + EVENT_BEGIN(EventCode::onChangeArmorStand); + EVENT_INSERT(Player); + EVENT_INSERT_EX(ArmorStand, EntityClass((Actor*)ev.mArmorStand)); + EVENT_INSERT(Slot); + EVENT_END; + }); + break; + + case EventCode::onChangeSprinting: + Event::PlayerSprintEvent::subscribe([](const PlayerSprintEvent& ev) { + EVENT_BEGIN(EventCode::onChangeSprinting); + EVENT_INSERT(Player); + EVENT_INSERT(IsSprinting); + EVENT_END; + }); + break; + + case EventCode::onSneak: + Event::PlayerSneakEvent::subscribe([](const PlayerSneakEvent& ev) { + EVENT_BEGIN(EventCode::onSneak); + EVENT_INSERT(Player); + EVENT_INSERT(IsSneaking); + EVENT_END; + }); + break; + + case EventCode::onOpenContainerScreen: + Event::PlayerOpenContainerScreenEvent::subscribe([](const PlayerOpenContainerScreenEvent& ev) { + EVENT_BEGIN(EventCode::onOpenContainerScreen); + EVENT_INSERT(Player); + EVENT_END; + }); + break; + + case EventCode::onSetArmor: + Event::PlayerSetArmorEvent::subscribe([](const PlayerSetArmorEvent& ev) { + EVENT_BEGIN(EventCode::onSetArmor); + EVENT_INSERT(Player); + EVENT_INSERT(Slot); + EVENT_INSERT(ArmorItem); + EVENT_END; + }); + break; + + case EventCode::onEat: + Event::PlayerEatEvent::subscribe([](const PlayerEatEvent& ev) { + EVENT_BEGIN(EventCode::onEat); + EVENT_INSERT(Player); + EVENT_INSERT(FoodItem); + EVENT_END; + }); + break; + + case EventCode::onConsumeTotem: + Event::PlayerConsumeTotemEvent::subscribe([](const PlayerConsumeTotemEvent& ev) { + EVENT_BEGIN(EventCode::onConsumeTotem); + EVENT_INSERT(Player); + EVENT_END; + }); + break; + + case EventCode::onEffectChanged: + Event::PlayerEffectChangedEvent::subscribe([](const PlayerEffectChangedEvent& ev) { + EVENT_BEGIN(EventCode::onEffectChanged); + EVENT_INSERT(Player); + EVENT_INSERT(Effect); + EVENT_INSERT(EventType); + EVENT_END; + }); + break; + + case EventCode::onUseRespawnAnchor: + Event::PlayerUseRespawnAnchorEvent::subscribe([](const PlayerUseRespawnAnchorEvent& ev) { + EVENT_BEGIN(EventCode::onUseRespawnAnchor); + EVENT_INSERT(Player); + EVENT_INSERT(BlockInstance); + EVENT_END; + }); + break; + + case EventCode::onRide: + Event::EntityRideEvent::subscribe([](const EntityRideEvent& ev) { + EVENT_BEGIN(EventCode::onRide); + EVENT_INSERT(Rider); + EVENT_INSERT(Vehicle); + EVENT_END; + }); + break; + + case EventCode::onEntityExplode: + Event::EntityExplodeEvent::subscribe([](const EntityExplodeEvent& ev) { + EVENT_BEGIN(EventCode::onEntityExplode); + EVENT_INSERT(Actor); + EVENT_INSERT(Pos); + EVENT_INSERT_EX(Dim, ev.mDimension->getDimensionId()); + EVENT_INSERT(Radius); + EVENT_INSERT(MaxResistance); + EVENT_INSERT(Breaking); + EVENT_INSERT(Fire); + EVENT_END; + }); + break; + + case EventCode::onBlockExplode: + Event::BlockExplodeEvent::subscribe([](const BlockExplodeEvent& ev) { + EVENT_BEGIN(EventCode::onBlockExplode); + EVENT_INSERT(BlockInstance); + EVENT_INSERT(Radius); + EVENT_INSERT(MaxResistance); + EVENT_INSERT(Breaking); + EVENT_INSERT(Fire); + EVENT_END; + }); + break; + + case EventCode::onBlockExploded: + Event::BlockExplodedEvent::subscribe([](const BlockExplodedEvent& ev) { + EVENT_BEGIN(EventCode::onBlockExploded); + EVENT_INSERT(BlockInstance); + EVENT_INSERT(ExplodeSource); + EVENT_END; + }); + break; + + case EventCode::onCmdBlockExecute: + Event::CmdBlockExecuteEvent::subscribe([](const CmdBlockExecuteEvent& ev) { + EVENT_BEGIN(EventCode::onCmdBlockExecute); + EVENT_INSERT(BlockInstance); + EVENT_INSERT(Command); + EVENT_INSERT(IsMinecart); + EVENT_INSERT(Minecart); + EVENT_END; + }); + break; + + case EventCode::onRedStoneUpdate: + Event::RedStoneUpdateEvent::subscribe([](const RedStoneUpdateEvent& ev) { + EVENT_BEGIN(EventCode::onRedStoneUpdate); + EVENT_INSERT(BlockInstance); + EVENT_INSERT(RedStonePower); + EVENT_INSERT(IsActivated); + EVENT_END; + }); + break; + + case EventCode::onWitherBossDestroy: + Event::WitherBossDestroyEvent::subscribe([](const WitherBossDestroyEvent& ev) { + EVENT_BEGIN(EventCode::onWitherBossDestroy); + EVENT_INSERT_EX(WitherBoss, EntityClass((Actor*)ev.mWitherBoss)); + EVENT_INSERT_EX(Min, ev.mDestroyRange.min); + EVENT_INSERT_EX(Max, ev.mDestroyRange.max); + EVENT_END; + }); + break; + + case EventCode::onMobHurt: + Event::MobHurtEvent::subscribe([](const MobHurtEvent& ev) { + EVENT_BEGIN(EventCode::onMobHurt); + EVENT_INSERT_EX(Mob, EntityClass(ev.mMob)); + EVENT_INSERT(Damage); + EVENT_INSERT_EX(Cause, magic_enum::enum_name(ev.mDamageSource->getCause())); + EVENT_INSERT_EX(Entity, EntityClass(ev.mDamageSource->getEntity())); + EVENT_END; + }); + break; + + case EventCode::onStepOnPressurePlate: + Event::EntityStepOnPressurePlateEvent::subscribe([](const EntityStepOnPressurePlateEvent& ev) { + EVENT_BEGIN(EventCode::onStepOnPressurePlate); + EVENT_INSERT(Actor); + EVENT_INSERT(BlockInstance); + EVENT_END; + }); + break; + + case EventCode::onMobDie: + Event::MobDieEvent::subscribe([](const MobDieEvent& ev) { + EVENT_BEGIN(EventCode::onMobDie); + EVENT_INSERT_EX(Mob, EntityClass(ev.mMob)); + EVENT_INSERT_EX(Cause, magic_enum::enum_name(ev.mDamageSource->getCause())); + EVENT_INSERT_EX(Entity, EntityClass(ev.mDamageSource->getEntity())); + EVENT_END; + }); + break; + + case EventCode::onNpcCmd: + Event::NpcCmdEvent::subscribe([](const NpcCmdEvent& ev) { + EVENT_BEGIN(EventCode::onNpcCmd); + EVENT_INSERT(Npc); + EVENT_INSERT(Player); + EVENT_INSERT(Command); + EVENT_END; + }); + break; + + case EventCode::onSpawnProjectile: + Event::ProjectileSpawnEvent::subscribe([](const ProjectileSpawnEvent& ev) { + EVENT_BEGIN(EventCode::onSpawnProjectile); + EVENT_INSERT(Shooter); + // idf... + EVENT_INSERT(Type); + EVENT_END; + }); + break; + + case EventCode::onProjectileCreated: + Event::ProjectileCreatedEvent::subscribe([](const ProjectileCreatedEvent& ev) { + EVENT_BEGIN(EventCode::onProjectileCreated); + EVENT_INSERT(Shooter); + EVENT_INSERT(Projectile); + EVENT_END; + }); + break; + + case EventCode::onProjectileHitEntity: + Event::ProjectileHitEntityEvent::subscribe([](const ProjectileHitEntityEvent& ev) { + EVENT_BEGIN(EventCode::onProjectileHitEntity); + EVENT_INSERT(Target); + EVENT_INSERT(Source); + EVENT_END; + }); + break; + + case EventCode::onEntityTransformation: + Event::EntityTransformEvent::subscribe([](const EntityTransformEvent& ev) { + EVENT_BEGIN(EventCode::onEntityTransformation); + EVENT_INSERT_EX(EntityId, to_string(ev.mBeforeEntityUniqueId->id)); + EVENT_INSERT(AfterEntity); + EVENT_END; + }); + break; + + case EventCode::onProjectileHitBlock: + Event::ProjectileHitBlockEvent::subscribe([](const ProjectileHitBlockEvent& ev) { + EVENT_BEGIN(EventCode::onProjectileHitBlock); + EVENT_INSERT(BlockInstance); + EVENT_INSERT(Source); + EVENT_END; + }); + break; + + case EventCode::onLiquidFlow: + Event::LiquidSpreadEvent::subscribe([](const LiquidSpreadEvent& ev) { + EVENT_BEGIN(EventCode::onLiquidFlow); + EVENT_INSERT(BlockInstance); + EVENT_INSERT(Target); + EVENT_INSERT(DimensionId); + EVENT_END; + }); + break; + + case EventCode::onUseFrameBlock: + Event::PlayerUseFrameBlockEvent::subscribe([](const PlayerUseFrameBlockEvent& ev) { + EVENT_BEGIN(EventCode::onUseFrameBlock); + EVENT_INSERT(Player); + EVENT_INSERT(BlockInstance); + EVENT_END; + }); + break; + + case EventCode::onBlockInteracted: + Event::BlockInteractedEvent::subscribe([](const BlockInteractedEvent& ev) { + EVENT_BEGIN(EventCode::onBlockInteracted); + EVENT_INSERT(Player); + EVENT_INSERT(BlockInstance); + EVENT_END; + }); + break; + + case EventCode::onFarmLandDecay: + Event::FarmLandDecayEvent::subscribe([](const FarmLandDecayEvent& ev) { + EVENT_BEGIN(EventCode::onFarmLandDecay); + EVENT_INSERT(BlockInstance); + EVENT_INSERT(Actor); + EVENT_END; + }); + break; + + case EventCode::onPistonTryPush: + Event::PistonTryPushEvent::subscribe([](const PistonTryPushEvent& ev) { + EVENT_BEGIN(EventCode::onPistonTryPush); + EVENT_INSERT(PistonBlockInstance); + EVENT_INSERT(TargetBlockInstance); + EVENT_END; + }); + break; + + case EventCode::onPistonPush: + Event::PistonPushEvent::subscribe([](const PistonPushEvent& ev) { + EVENT_BEGIN(EventCode::onPistonPush); + EVENT_INSERT(PistonBlockInstance); + EVENT_INSERT(TargetBlockInstance); + EVENT_END; + }); + break; + + case EventCode::onHopperSearchItem: + Event::HopperSearchItemEvent::subscribe([](const HopperSearchItemEvent& ev) { + EVENT_BEGIN(EventCode::onHopperSearchItem); + EVENT_INSERT_EX(isMinecart, ev.isMinecart); + EVENT_INSERT(HopperBlock); + EVENT_INSERT(MinecartPos); + EVENT_INSERT(DimensionId); + EVENT_END; + }); + break; + + case EventCode::onHopperPushOut: + Event::HopperPushOutEvent::subscribe([](const HopperPushOutEvent& ev) { + EVENT_BEGIN(EventCode::onHopperPushOut); + EVENT_INSERT(Pos); + EVENT_INSERT(DimensionId); + EVENT_END; + }); + break; + + case EventCode::onFireSpread: + Event::FireSpreadEvent::subscribe([](const FireSpreadEvent& ev) { + EVENT_BEGIN(EventCode::onFireSpread); + EVENT_INSERT(Target); + EVENT_INSERT(DimensionId); + EVENT_END; + }); + break; + + case EventCode::onBlockChanged: + Event::BlockChangedEvent::subscribe([](const BlockChangedEvent& ev) { + EVENT_BEGIN(EventCode::onBlockChanged); + EVENT_INSERT(PreviousBlockInstance); + EVENT_INSERT(NewBlockInstance); + EVENT_END; + }); + break; + + case EventCode::onScoreChanged: + Event::PlayerScoreChangedEvent::subscribe([](const PlayerScoreChangedEvent& ev) { + EVENT_BEGIN(EventCode::onScoreChanged); + EVENT_INSERT(Player); + EVENT_INSERT(Score); + EVENT_INSERT_EX(Objective, ObjectiveClass(ev.mObjective)); + // ScoreboardId + EVENT_END; + }); + break; + + case EventCode::onConsoleOutput: + Event::ConsoleOutputEvent::subscribe([](const ConsoleOutputEvent& ev) { + EVENT_BEGIN(EventCode::onConsoleOutput); + EVENT_INSERT(Output); + EVENT_END; + }); + break; + case EventCode::onMobSpawn: + Event::MobSpawnEvent::subscribe([](const MobSpawnEvent& ev) { + EVENT_BEGIN(EventCode::onMobSpawn); + EVENT_INSERT(TypeName); + EVENT_INSERT(Pos); + EVENT_INSERT(DimensionId); + EVENT_END; + }); + break; + default: + break; } } diff --git a/API/EventAPI.h b/API/EventAPI.h index bd56249..2d973df 100644 --- a/API/EventAPI.h +++ b/API/EventAPI.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once enum class EventCode { /* Player Events */ onPreJoin, diff --git a/API/ItemAPI.cpp b/API/ItemAPI.cpp index 5aafba7..e0ab16a 100644 --- a/API/ItemAPI.cpp +++ b/API/ItemAPI.cpp @@ -1,4 +1,4 @@ -#include +#include #include "ItemAPI.h" #include "McAPI.h" #include "EntityAPI.h" diff --git a/API/ItemAPI.h b/API/ItemAPI.h index 5a74729..38b45ec 100644 --- a/API/ItemAPI.h +++ b/API/ItemAPI.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include class ItemStack; diff --git a/API/LoggerAPI.cpp b/API/LoggerAPI.cpp index 954f484..79e68ba 100644 --- a/API/LoggerAPI.cpp +++ b/API/LoggerAPI.cpp @@ -1,4 +1,4 @@ -#include +#include #include "LoggerAPI.h" #include "PlayerAPI.h" diff --git a/API/LoggerAPI.h b/API/LoggerAPI.h index e715f27..b7aec4d 100644 --- a/API/LoggerAPI.h +++ b/API/LoggerAPI.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include struct PlayerClass; diff --git a/API/McAPI.cpp b/API/McAPI.cpp index 71ce24d..531fa2f 100644 --- a/API/McAPI.cpp +++ b/API/McAPI.cpp @@ -1,4 +1,4 @@ -#include "McAPI.h" +#include "McAPI.h" #include #include @@ -20,10 +20,10 @@ void setListener(const string& event_name, const py::function& cb) { auto event_code = magic_enum::enum_cast(event_name); if (!event_code) throw py::value_error("Invalid event name " + event_name); - //δã + //如果监听器未启用,则启用 if (listeners.find(event_code.value()) == listeners.end()) EnableEventListener(event_code.value()); - //ӻص + //添加回调函数 listeners[event_code.value()].push_back(cb); } @@ -32,13 +32,12 @@ void registerCommand(const string& name, const string& desc, const py::function& auto command = DynamicCommand::createCommand(name, desc, perm); command->addOverload(); command->setCallback( - [cb](DynamicCommand const& command, CommandOrigin const& origin, - CommandOutput& output, std::unordered_map& results) { - PY_TRY; - py::gil_scoped_acquire gil_; - cb(EntityClass((Player*)origin.getPlayer()), results); - PY_CATCH; - }); + [cb](DynamicCommand const& command, CommandOrigin const& origin, CommandOutput& output, std::unordered_map& results) { + PY_TRY; + py::gil_scoped_acquire gil_; + cb(PlayerClass((Player*)origin.getPlayer()), results); + PY_CATCH; + }); DynamicCommand::setup(std::move(command)); } @@ -85,12 +84,12 @@ NBTClass getStructure(const BlockPos& pos1, const BlockPos& pos2, int dim, bool bool setStructure(const NBTClass& nbt, const BlockPos& pos, int dim, Mirror mir, Rotation rot) { auto st = StructureTemplate::fromTag("name", *nbt.thiz->asCompoundTag()); /*for (int x = 0; x != size.x; ++x) { - for (int y = 0; y != size.y; ++y) { - for (int z = 0; z != size.z; ++z) { - BlockPos pos{ x, y, z }; - bs->neighborChanged(pos, pos); - } - } + for (int y = 0; y != size.y; ++y) { + for (int z = 0; z != size.z; ++z) { + BlockPos pos{ x, y, z }; + bs->neighborChanged(pos, pos); + } + } }*/ return st.toWorld(dim, pos, mir, rot); } @@ -156,7 +155,10 @@ bool sendCmdOutput(const string& output) { finalOutput += "\r\n"; SymCall("??$_Insert_string@DU?$char_traits@D@std@@_K@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@QEBD_K@Z", - ostream&, ostream&, const char*, size_t)(cout, finalOutput.c_str(), finalOutput.size()); + ostream&, + ostream&, + const char*, + size_t)(cout, finalOutput.c_str(), finalOutput.size()); return true; } @@ -198,4 +200,4 @@ vector getAllScoreObjectives() { return res; } -} // namespace mc +}// namespace mc diff --git a/API/McAPI.h b/API/McAPI.h index a945d7c..22217e0 100644 --- a/API/McAPI.h +++ b/API/McAPI.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include #include @@ -19,19 +19,17 @@ py::list getAllEntities(); BlockClass getBlock(const BlockPos& pos, int dim); bool setBlock(const BlockPos& pos, int dim, const string& name, int tile_data); bool setBlock(const BlockPos& pos, int dim, const BlockClass& b); -//ָصȡNBTṹ -NBTClass getStructure(const BlockPos& pos1, const BlockPos& pos2, int dim, - bool ignore_entities = true, bool ignore_blocks = false); -//NBTṹݵṹָص -bool setStructure(const NBTClass& nbt, const BlockPos& pos, int dim, - Mirror mir = None_15, Rotation rot = None_14); -//ը +//从指定地点获取NBT结构数据 +NBTClass getStructure(const BlockPos& pos1, const BlockPos& pos2, int dim, bool ignore_entities = true, bool ignore_blocks = false); +//从NBT结构数据导出结构到指定地点 +bool setStructure(const NBTClass& nbt, const BlockPos& pos, int dim, Mirror mir = None_15, Rotation rot = None_14); +//产生爆炸 void explode(const Vec3& pos, int dim, float power, bool destroy, float range, bool fire); -//Ʒ +//生成物品 void spawnItem(ItemClass& item, Vec3 pos, int dim); -// +//设置牌子文字 void setSignBlockMessage(BlockPos pos, int dim, const string& text); -//ǷΪʷķ +//是否为史莱姆区块 int IsSlimeChunk(unsigned x, unsigned z); EntityClass spawnMob(const Vec3& pos, int dim, const string& type); @@ -51,4 +49,4 @@ ObjectiveClass getScoreObjective(const string& name); ObjectiveClass newScoreObjective(const string& name, const string& display); bool removeScoreObjective(const string& name); vector getAllScoreObjectives(); -} +}// namespace mc diff --git a/API/MoneyAPI.cpp b/API/MoneyAPI.cpp index 879497d..3536793 100644 --- a/API/MoneyAPI.cpp +++ b/API/MoneyAPI.cpp @@ -1,4 +1,4 @@ -#include "MoneyAPI.h" +#include "MoneyAPI.h" #include "API/EventAPI.h" #include #include @@ -21,8 +21,7 @@ LLMoneyReduce_T reduce = nullptr; LLMoneyTrans_T transfer = nullptr; LLMoneyGetHist_T getHistory = nullptr; LLMoneyClearHist_T clearHIstory = nullptr; -}; - +};// namespace money bool EconomySystem::init() { auto llmoney = LL::getPlugin("LLMoney"); diff --git a/API/MoneyAPI.h b/API/MoneyAPI.h index 29d6698..7f6e522 100644 --- a/API/MoneyAPI.h +++ b/API/MoneyAPI.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include using std::string; diff --git a/API/NbtAPI.cpp b/API/NbtAPI.cpp index 144c4c0..0101d8e 100644 --- a/API/NbtAPI.cpp +++ b/API/NbtAPI.cpp @@ -22,7 +22,7 @@ NBTClass::NBTClass(Tag* other) : thiz(other), is_reference(true) {} NBTClass::NBTClass(const NBTClass& other) : thiz(other.thiz->copy()), is_reference(false) {} NBTClass::NBTClass(NBTClass&& other) noexcept - : thiz(move(other.thiz)), is_reference(other.is_reference) {} + : thiz(move(other.thiz)), is_reference(other.is_reference) {} NBTClass::~NBTClass() { if (is_reference) diff --git a/API/NbtAPI.h b/API/NbtAPI.h index 084517c..4d281b6 100644 --- a/API/NbtAPI.h +++ b/API/NbtAPI.h @@ -10,7 +10,7 @@ struct NBTClass { NBTClass(); NBTClass(Tag* other); - template + template NBTClass(unique_ptr&& other) { thiz = std::move(other); is_reference = false; @@ -18,7 +18,7 @@ struct NBTClass { NBTClass(const NBTClass& other); NBTClass(NBTClass&& other) noexcept; ~NBTClass(); - + static NBTClass newEnd(); static NBTClass newByte(unsigned char value); static NBTClass newShort(short value); diff --git a/API/PlayerAPI.cpp b/API/PlayerAPI.cpp index 44d12f6..02cee96 100644 --- a/API/PlayerAPI.cpp +++ b/API/PlayerAPI.cpp @@ -1,4 +1,4 @@ -#include +#include #include "BlockAPI.h" #include "EntityAPI.h" #include "PlayerAPI.h" @@ -356,14 +356,14 @@ bool PlayerClass::setBossBar(int64_t uid, const string& name, float percent, Bos else if (percent > 100) percent = 100; float value = percent / 100; - thiz->updateBossEvent(uid, name, value, colour); // TODO: test whether it work + thiz->updateBossEvent(uid, name, value, colour);// TODO: test whether it work return thiz->sendBossEventPacket(BossEvent::Show, name, value, colour); } bool PlayerClass::removeBossBar() { if (thiz == nullptr) return {}; - return thiz->sendBossEventPacket(BossEvent::Hide, "", 0, BossEventColour::Red); // Remove + return thiz->sendBossEventPacket(BossEvent::Hide, "", 0, BossEventColour::Red);// Remove } bool PlayerClass::removeBossBar(int64_t uid) { @@ -410,17 +410,17 @@ bool PlayerClass::sendCustomForm(const string& str, const py::function& cb) { return {}; Player* p = thiz; return thiz->sendCustomFormPacket(str, - [p, cb](const string& arg) { - if (LL::isServerStopping()) - return; - if (arg == "null") - return; - PY_TRY; - py::gil_scoped_acquire gil_; - auto json = py::module_::import("json"); - cb(PlayerClass(p), json.attr("loads")(arg)); - PY_CATCH; - }); + [p, cb](const string& arg) { + if (LL::isServerStopping()) + return; + if (arg == "null") + return; + PY_TRY; + py::gil_scoped_acquire gil_; + auto json = py::module_::import("json"); + cb(PlayerClass(p), json.attr("loads")(arg)); + PY_CATCH; + }); } bool PlayerClass::sendSimpleForm(const string& title, const string& content, const vector& buttons, const vector& images, const py::function& cb) { @@ -429,32 +429,30 @@ bool PlayerClass::sendSimpleForm(const string& title, const string& content, con if (buttons.size() != images.size()) throw py::value_error("The number of buttons is not equal to the number of images"); Player* p = thiz; - return thiz->sendSimpleFormPacket(title, content, buttons, images, - [p, cb](int arg) { - if (LL::isServerStopping()) - return; - if (arg == -1) - return; - PY_TRY; - py::gil_scoped_acquire gil_; - cb(PlayerClass(p), arg); - PY_CATCH; - }); + return thiz->sendSimpleFormPacket(title, content, buttons, images, [p, cb](int arg) { + if (LL::isServerStopping()) + return; + if (arg == -1) + return; + PY_TRY; + py::gil_scoped_acquire gil_; + cb(PlayerClass(p), arg); + PY_CATCH; + }); } bool PlayerClass::sendModalForm(const string& title, const string& content, const string& button1, const string& button2, const py::function& cb) { if (thiz == nullptr) return {}; Player* p = thiz; - return thiz->sendModalFormPacket(title, content, button1, button2, - [p, cb](bool arg) { - if (LL::isServerStopping()) - return; - PY_TRY; - py::gil_scoped_acquire gil_; - cb(PlayerClass(p), arg); - PY_CATCH; - }); + return thiz->sendModalFormPacket(title, content, button1, button2, [p, cb](bool arg) { + if (LL::isServerStopping()) + return; + PY_TRY; + py::gil_scoped_acquire gil_; + cb(PlayerClass(p), arg); + PY_CATCH; + }); } bool PlayerClass::refreshChunks() { diff --git a/API/PlayerAPI.h b/API/PlayerAPI.h index 87dac3e..bbbd75e 100644 --- a/API/PlayerAPI.h +++ b/API/PlayerAPI.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include @@ -85,10 +85,8 @@ struct PlayerClass { bool addExperience(int value); bool sendCustomForm(const string& str, const py::function& cb); - bool sendSimpleForm(const string& title, const string& content, - const vector& buttons, const vector& images, const py::function& cb); - bool sendModalForm(const string& title, const string& content, - const string& button1, const string& button2, const py::function& cb); + bool sendSimpleForm(const string& title, const string& content, const vector& buttons, const vector& images, const py::function& cb); + bool sendModalForm(const string& title, const string& content, const string& button1, const string& button2, const py::function& cb); bool setExtraData(string key, const py::object& value); py::object getExtraData(string key); @@ -102,11 +100,11 @@ struct PlayerClass { vector getAllTags(); EntityClass getEntityFromViewVector(float maxDistance = 5.25f); BlockClass getBlockFromViewVector( - bool includeLiquid = false, - bool solidOnly = false, - float maxDistance = 5.25f, - bool ignoreBorderBlocks = true, - bool fullOnly = false); + bool includeLiquid = false, + bool solidOnly = false, + float maxDistance = 5.25f, + bool ignoreBorderBlocks = true, + bool fullOnly = false); bool isSimulatedPlayer(); diff --git a/API/ScoreboardAPI.cpp b/API/ScoreboardAPI.cpp index c8972a7..7bb72d8 100644 --- a/API/ScoreboardAPI.cpp +++ b/API/ScoreboardAPI.cpp @@ -1,4 +1,4 @@ -#include "ScoreboardAPI.h" +#include "ScoreboardAPI.h" #include "McAPI.h" #include "PlayerAPI.h" #include diff --git a/API/ScoreboardAPI.h b/API/ScoreboardAPI.h index 558d8b9..799a4f6 100644 --- a/API/ScoreboardAPI.h +++ b/API/ScoreboardAPI.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include class Objective; diff --git a/Example/mc.pyi b/Example/mc.pyi index ceeaafe..9153210 100644 --- a/Example/mc.pyi +++ b/Example/mc.pyi @@ -1,7 +1,7 @@ # pyr的代码补全文件 # Copyright (c) 2022 twoone3 # All rights reserved. -# last change: 2022.7.10 +# last change: 2022.7.24 from enum import Enum @@ -524,7 +524,7 @@ class Player: real_name: str xuid: str uuid: str - perm_level: int + perm_level: CommandPermissionLevel game_mode: GameType max_health: int health: int @@ -954,7 +954,7 @@ def runCommandEx(cmd) -> tuple[str, bool]: def setListener(event, callback) -> bool: pass - +# callback: (player: Player, result: dict[str, CommandResult]) -> None def registerCommand( name, desc, callback, perm=CommandPermissionLevel.GameMasters ) -> bool: diff --git a/Global.cpp b/Global.cpp index 247d1ff..b725632 100644 --- a/Global.cpp +++ b/Global.cpp @@ -1,9 +1,10 @@ -#include "Global.hpp" +#include "Global.hpp" fifo_json StrToJson(std::string_view str) { try { return fifo_json::parse(str); - } catch (const std::exception& e) { + } + catch (const std::exception& e) { logger.error("\nParsing JSON failed! {}", e.what()); return nullptr; } diff --git a/Init.cpp b/Init.cpp index 5b1155d..c55a425 100644 --- a/Init.cpp +++ b/Init.cpp @@ -8,8 +8,8 @@ using namespace std; constexpr unsigned PYR_VERSION_MAJOR = 2; constexpr unsigned PYR_VERSION_MINOR = 0; -constexpr unsigned PYR_VERSION_MICRO = 5; -constexpr const char* PYR_VERSION = "v2.0.5"; +constexpr unsigned PYR_VERSION_MICRO = 6; +constexpr const char* PYR_VERSION = "v2.0.6"; void entry() { PY_TRY; @@ -45,7 +45,8 @@ void entry() { if (name.front() == '_') { logger.debug("Ignoring {}", name); continue; - } else { + } + else { PY_TRY; logger.info("Loading {}", name); py::module_::import(name.c_str()); @@ -66,12 +67,12 @@ THook(int, "main", int argc, char* argv[], char* envp[]) { extern "C" _declspec(dllexport) void onPostInit() { std::ios::sync_with_stdio(false); LL::registerPlugin( - "BDSpyrunner", - "Loading python in BDS", - LL::Version(PYR_VERSION_MAJOR, - PYR_VERSION_MINOR, - PYR_VERSION_MICRO, - LL::Version::Release), - "https://github.com/twoone-3/BDSpyrunner.git", - "GPL v3.0"); + "BDSpyrunner", + "Loading python in BDS", + LL::Version(PYR_VERSION_MAJOR, + PYR_VERSION_MINOR, + PYR_VERSION_MICRO, + LL::Version::Release), + "https://github.com/twoone-3/BDSpyrunner.git", + "GPL v3.0"); } diff --git a/ModuleDef.cpp b/ModuleDef.cpp index 8fd0ffc..e06bc9c 100644 --- a/ModuleDef.cpp +++ b/ModuleDef.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -46,404 +46,404 @@ PYBIND11_EMBEDDED_MODULE(mc, mc_module) { #pragma endregion #pragma region Classes py::class_(mc_module, "Vec2") - .def(py::init()) + .def(py::init()) - .def_property( - "x", [](const Vec2& pos) { return pos.x; }, [](Vec2& pos, float val) { pos.x = val; }) - .def_property( - "y", [](const Vec2& pos) { return pos.y; }, [](Vec2& pos, float val) { pos.y = val; }) - .def("__repr__", &Vec2::toString); + .def_property( + "x", [](const Vec2& pos) { return pos.x; }, [](Vec2& pos, float val) { pos.x = val; }) + .def_property( + "y", [](const Vec2& pos) { return pos.y; }, [](Vec2& pos, float val) { pos.y = val; }) + .def("__repr__", &Vec2::toString); py::class_(mc_module, "Vec3") - .def(py::init()) + .def(py::init()) - .def_property( - "x", [](const Vec3& pos) { return pos.x; }, [](Vec3& pos, float val) { pos.x = val; }) - .def_property( - "y", [](const Vec3& pos) { return pos.y; }, [](Vec3& pos, float val) { pos.y = val; }) - .def_property( - "z", [](const Vec3& pos) { return pos.z; }, [](Vec3& pos, float val) { pos.z = val; }) - .def("__repr__", &Vec3::toString); + .def_property( + "x", [](const Vec3& pos) { return pos.x; }, [](Vec3& pos, float val) { pos.x = val; }) + .def_property( + "y", [](const Vec3& pos) { return pos.y; }, [](Vec3& pos, float val) { pos.y = val; }) + .def_property( + "z", [](const Vec3& pos) { return pos.z; }, [](Vec3& pos, float val) { pos.z = val; }) + .def("__repr__", &Vec3::toString); py::class_(mc_module, "BlockPos") - .def(py::init()) + .def(py::init()) - .def_property( - "x", [](const BlockPos& pos) { return pos.x; }, [](BlockPos& pos, int val) { pos.x = val; }) - .def_property( - "y", [](const BlockPos& pos) { return pos.y; }, [](BlockPos& pos, int val) { pos.y = val; }) - .def_property( - "z", [](const BlockPos& pos) { return pos.z; }, [](BlockPos& pos, int val) { pos.z = val; }) - .def("__repr__", &BlockPos::toString); + .def_property( + "x", [](const BlockPos& pos) { return pos.x; }, [](BlockPos& pos, int val) { pos.x = val; }) + .def_property( + "y", [](const BlockPos& pos) { return pos.y; }, [](BlockPos& pos, int val) { pos.y = val; }) + .def_property( + "z", [](const BlockPos& pos) { return pos.z; }, [](BlockPos& pos, int val) { pos.z = val; }) + .def("__repr__", &BlockPos::toString); py::class_(mc_module, "Block") - .def_property("name", &BlockClass::getName, nullptr) - .def_property("type", &BlockClass::getType, nullptr) - .def_property("id", &BlockClass::getId, nullptr) - .def_property("pos", &BlockClass::getPos, nullptr) - .def_property("dim", &BlockClass::getDim, nullptr) - .def_property("tile_data", &BlockClass::getTileData, nullptr) - - .def("setNbt", &BlockClass::setNbt) - .def("getNbt", &BlockClass::getNbt) - .def("hasContainer", &BlockClass::hasContainer) - .def("getContainer", &BlockClass::getContainer) - .def("hasBlockEntity", &BlockClass::hasBlockEntity) - .def("getBlockEntity", &BlockClass::getBlockEntity) - .def("removeBlockEntity", &BlockClass::removeBlockEntity); + .def_property("name", &BlockClass::getName, nullptr) + .def_property("type", &BlockClass::getType, nullptr) + .def_property("id", &BlockClass::getId, nullptr) + .def_property("pos", &BlockClass::getPos, nullptr) + .def_property("dim", &BlockClass::getDim, nullptr) + .def_property("tile_data", &BlockClass::getTileData, nullptr) + + .def("setNbt", &BlockClass::setNbt) + .def("getNbt", &BlockClass::getNbt) + .def("hasContainer", &BlockClass::hasContainer) + .def("getContainer", &BlockClass::getContainer) + .def("hasBlockEntity", &BlockClass::hasBlockEntity) + .def("getBlockEntity", &BlockClass::getBlockEntity) + .def("removeBlockEntity", &BlockClass::removeBlockEntity); py::class_(mc_module, "Container") - .def_property("size", &ContainerClass::getSize, nullptr) - .def_property("type", &ContainerClass::getType, nullptr) - - .def("addItem", &ContainerClass::addItem) - .def("addItemToFirstEmptySlot", &ContainerClass::addItemToFirstEmptySlot) - .def("hasRoomFor", &ContainerClass::hasRoomFor) - .def("removeItem", &ContainerClass::removeItem) - .def("getItem", &ContainerClass::getItem) - .def("setItem", &ContainerClass::setItem) - .def("getAllItems", &ContainerClass::getAllItems) - .def("removeAllItems", &ContainerClass::removeAllItems) - .def("isEmpty", &ContainerClass::isEmpty); + .def_property("size", &ContainerClass::getSize, nullptr) + .def_property("type", &ContainerClass::getType, nullptr) + + .def("addItem", &ContainerClass::addItem) + .def("addItemToFirstEmptySlot", &ContainerClass::addItemToFirstEmptySlot) + .def("hasRoomFor", &ContainerClass::hasRoomFor) + .def("removeItem", &ContainerClass::removeItem) + .def("getItem", &ContainerClass::getItem) + .def("setItem", &ContainerClass::setItem) + .def("getAllItems", &ContainerClass::getAllItems) + .def("removeAllItems", &ContainerClass::removeAllItems) + .def("isEmpty", &ContainerClass::isEmpty); py::class_(mc_module, "Item") - .def(py::init()) - - .def_property("name", &ItemClass::getName, nullptr) - .def_property("type", &ItemClass::getType, nullptr) - .def_property("id", &ItemClass::getId, nullptr) - .def_property("count", &ItemClass::getCount, nullptr) - .def_property("aux", &ItemClass::getAux, nullptr) - - .def("set", &ItemClass::set) - .def("clone", &ItemClass::clone) - .def("isNull", &ItemClass::isNull) - .def("setNull", &ItemClass::setNull) - .def("setAux", &ItemClass::setAux) - .def("setLore", &ItemClass::setLore) - .def("setNbt", &ItemClass::setNbt) - .def("getNbt", &ItemClass::getNbt); + .def(py::init()) + + .def_property("name", &ItemClass::getName, nullptr) + .def_property("type", &ItemClass::getType, nullptr) + .def_property("id", &ItemClass::getId, nullptr) + .def_property("count", &ItemClass::getCount, nullptr) + .def_property("aux", &ItemClass::getAux, nullptr) + + .def("set", &ItemClass::set) + .def("clone", &ItemClass::clone) + .def("isNull", &ItemClass::isNull) + .def("setNull", &ItemClass::setNull) + .def("setAux", &ItemClass::setAux) + .def("setLore", &ItemClass::setLore) + .def("setNbt", &ItemClass::setNbt) + .def("getNbt", &ItemClass::getNbt); py::class_(mc_module, "Command") - .def(py::init()) - .def_property("name", &CommandClass::getName, nullptr) - - .def("setEnum", &CommandClass::setEnum) - .def("setAlias", &CommandClass::setAlias) - .def("mandatory2", py::overload_cast(&CommandClass::mandatory), "name"_a, "type"_a, "description"_a = "", "identifier"_a = "", "option"_a = None) - .def("mandatory", py::overload_cast(&CommandClass::mandatory), "name"_a, "type"_a, "description"_a = "", "option"_a = None) - .def("optional2", py::overload_cast(&CommandClass::optional), "name"_a, "type"_a, "description"_a = "", "identifier"_a = "", "option"_a = None) - .def("optional", py::overload_cast(&CommandClass::optional), "name"_a, "type"_a, "description"_a = "", "option"_a = None) - .def("setSoftEnum", &CommandClass::setSoftEnum) - .def("addSoftEnumValues", &CommandClass::addSoftEnumValues) - .def("removeSoftEnumValues", &CommandClass::removeSoftEnumValues) - .def("getSoftEnumValues", &CommandClass::getSoftEnumValues) - .def("getSoftEnumNames", &CommandClass::getSoftEnumNames) - .def("overload", py::overload_cast<>(&CommandClass::addOverload)) - .def("overload", py::overload_cast&>(&CommandClass::addOverload)) - .def("overload", py::overload_cast&&>(&CommandClass::addOverload)) - .def("setCallback", &CommandClass::setCallback) - .def("setup", &CommandClass::setup); + .def(py::init()) + .def_property("name", &CommandClass::getName, nullptr) + + .def("setEnum", &CommandClass::setEnum) + .def("setAlias", &CommandClass::setAlias) + .def("mandatory2", py::overload_cast(&CommandClass::mandatory), "name"_a, "type"_a, "description"_a = "", "identifier"_a = "", "option"_a = None) + .def("mandatory", py::overload_cast(&CommandClass::mandatory), "name"_a, "type"_a, "description"_a = "", "option"_a = None) + .def("optional2", py::overload_cast(&CommandClass::optional), "name"_a, "type"_a, "description"_a = "", "identifier"_a = "", "option"_a = None) + .def("optional", py::overload_cast(&CommandClass::optional), "name"_a, "type"_a, "description"_a = "", "option"_a = None) + .def("setSoftEnum", &CommandClass::setSoftEnum) + .def("addSoftEnumValues", &CommandClass::addSoftEnumValues) + .def("removeSoftEnumValues", &CommandClass::removeSoftEnumValues) + .def("getSoftEnumValues", &CommandClass::getSoftEnumValues) + .def("getSoftEnumNames", &CommandClass::getSoftEnumNames) + .def("overload", py::overload_cast<>(&CommandClass::addOverload)) + .def("overload", py::overload_cast&>(&CommandClass::addOverload)) + .def("overload", py::overload_cast&&>(&CommandClass::addOverload)) + .def("setCallback", &CommandClass::setCallback) + .def("setup", &CommandClass::setup); py::class_(mc_module, "CommandOrigin") - .def_property("type", &CommandOriginClass::getOriginType, nullptr) - .def_property("type_name", &CommandOriginClass::getOriginTypeName, nullptr) - .def_property("name", &CommandOriginClass::getOriginName, nullptr) - .def_property("pos", &CommandOriginClass::getPosition, nullptr) - .def_property("blockpos", &CommandOriginClass::getBlockPosition, nullptr) - .def_property("dim", &CommandOriginClass::getDim, nullptr) - .def_property("entity", &CommandOriginClass::getEntity, nullptr) - .def_property("player", &CommandOriginClass::getPlayer, nullptr) - - .def("getNbt", &CommandOriginClass::getNbt) - .def("toString", &CommandOriginClass::toString); + .def_property("type", &CommandOriginClass::getOriginType, nullptr) + .def_property("type_name", &CommandOriginClass::getOriginTypeName, nullptr) + .def_property("name", &CommandOriginClass::getOriginName, nullptr) + .def_property("pos", &CommandOriginClass::getPosition, nullptr) + .def_property("blockpos", &CommandOriginClass::getBlockPosition, nullptr) + .def_property("dim", &CommandOriginClass::getDim, nullptr) + .def_property("entity", &CommandOriginClass::getEntity, nullptr) + .def_property("player", &CommandOriginClass::getPlayer, nullptr) + + .def("getNbt", &CommandOriginClass::getNbt) + .def("toString", &CommandOriginClass::toString); py::class_(mc_module, "CommandOutput") - .def_property("empty", &CommandOutputClass::empty, nullptr) - .def_property("success_count", &CommandOutputClass::getSuccessCount, nullptr) + .def_property("empty", &CommandOutputClass::empty, nullptr) + .def_property("success_count", &CommandOutputClass::getSuccessCount, nullptr) - .def("success", py::overload_cast<>(&CommandOutputClass::success)) - .def("success", py::overload_cast(&CommandOutputClass::success)) - .def("error", &CommandOutputClass::error) - .def("addMessage", &CommandOutputClass::addMessage) - .def("toString", &CommandOutputClass::toString); + .def("success", py::overload_cast<>(&CommandOutputClass::success)) + .def("success", py::overload_cast(&CommandOutputClass::success)) + .def("error", &CommandOutputClass::error) + .def("addMessage", &CommandOutputClass::addMessage) + .def("toString", &CommandOutputClass::toString); py::class_(mc_module, "CommandResult") - .def("__repr__", [](const DynamicCommand::Result& thiz) { return py::str(convertResult(thiz)); }) - .def("toObject", [](const DynamicCommand::Result& thiz) { return convertResult(thiz); }); + .def("__repr__", [](const DynamicCommand::Result& thiz) { return py::str(convertResult(thiz)); }) + .def("toObject", [](const DynamicCommand::Result& thiz) { return convertResult(thiz); }); py::class_(mc_module, "NBT") - .def_property("type", &NBTClass::getType, nullptr) - .def_static("newByte", &NBTClass::newByte) - .def_static("newShort", &NBTClass::newShort) - .def_static("newInt", &NBTClass::newInt) - .def_static("newLong", &NBTClass::newInt64) - .def_static("newFloat", &NBTClass::newFloat) - .def_static("newDouble", &NBTClass::newDouble) - .def_static("newByteArray", &NBTClass::newByteArray) - .def_static("newString", &NBTClass::newString) - .def_static("newIntArray", &NBTClass::newIntArray) - .def_static("newList", &NBTClass::newList) - .def_static("newCompound", &NBTClass::newCompound) - .def_static("fromSNBT", &NBTClass::fromSNBT) - .def_static("fromBinary", &NBTClass::fromBinary) - - .def("__getitem__", py::overload_cast(&NBTClass::__getitem__)) - .def("__getitem__", py::overload_cast(&NBTClass::__getitem__)) - .def("__setitem__", &NBTClass::__setitem__) - .def("asByte", &NBTClass::asByte) - .def("asShort", &NBTClass::asShort) - .def("asInt", &NBTClass::asInt) - .def("asInt64", &NBTClass::asInt64) - .def("asFloat", &NBTClass::asFloat) - .def("asDouble", &NBTClass::asDouble) - .def("asString", &NBTClass::asString) - .def("toBinary", &NBTClass::toBinary) - .def("toJson", &NBTClass::toJson, "indent"_a = 4) - .def("toSNBT", &NBTClass::toSNBT, "indent"_a = 4, "format"_a = SnbtFormat::PartialNewLine) - .def("append", &NBTClass::append); + .def_property("type", &NBTClass::getType, nullptr) + .def_static("newByte", &NBTClass::newByte) + .def_static("newShort", &NBTClass::newShort) + .def_static("newInt", &NBTClass::newInt) + .def_static("newLong", &NBTClass::newInt64) + .def_static("newFloat", &NBTClass::newFloat) + .def_static("newDouble", &NBTClass::newDouble) + .def_static("newByteArray", &NBTClass::newByteArray) + .def_static("newString", &NBTClass::newString) + .def_static("newIntArray", &NBTClass::newIntArray) + .def_static("newList", &NBTClass::newList) + .def_static("newCompound", &NBTClass::newCompound) + .def_static("fromSNBT", &NBTClass::fromSNBT) + .def_static("fromBinary", &NBTClass::fromBinary) + + .def("__getitem__", py::overload_cast(&NBTClass::__getitem__)) + .def("__getitem__", py::overload_cast(&NBTClass::__getitem__)) + .def("__setitem__", &NBTClass::__setitem__) + .def("asByte", &NBTClass::asByte) + .def("asShort", &NBTClass::asShort) + .def("asInt", &NBTClass::asInt) + .def("asInt64", &NBTClass::asInt64) + .def("asFloat", &NBTClass::asFloat) + .def("asDouble", &NBTClass::asDouble) + .def("asString", &NBTClass::asString) + .def("toBinary", &NBTClass::toBinary) + .def("toJson", &NBTClass::toJson, "indent"_a = 4) + .def("toSNBT", &NBTClass::toSNBT, "indent"_a = 4, "format"_a = SnbtFormat::PartialNewLine) + .def("append", &NBTClass::append); py::class_(mc_module, "Logger") - .def(py::init(), "title"_a) - .def("debug", &LoggerClass::debug) - .def("info", &LoggerClass::info) - .def("warn", &LoggerClass::warn) - .def("error", &LoggerClass::error) - .def("fatal", &LoggerClass::fatal) + .def(py::init(), "title"_a) + .def("debug", &LoggerClass::debug) + .def("info", &LoggerClass::info) + .def("warn", &LoggerClass::warn) + .def("error", &LoggerClass::error) + .def("fatal", &LoggerClass::fatal) - .def("setTitle", &LoggerClass::setTitle) - .def("setFile", &LoggerClass::setFile) - .def("setPlayer", &LoggerClass::setPlayer); + .def("setTitle", &LoggerClass::setTitle) + .def("setFile", &LoggerClass::setFile) + .def("setPlayer", &LoggerClass::setPlayer); py::class_(mc_module, "Player") - .def_property("name", &PlayerClass::getName, nullptr) - .def_property("pos", &PlayerClass::getPos, nullptr) - .def_property("blockpos", &PlayerClass::getBlockPos, nullptr) - .def_property("dim", &PlayerClass::getDim, nullptr) - .def_property("real_name", &PlayerClass::getRealName, nullptr) - .def_property("xuid", &PlayerClass::getXuid, nullptr) - .def_property("uuid", &PlayerClass::getUuid, nullptr) - .def_property("perm_level", &PlayerClass::getPermLevel, nullptr) - .def_property("game_mode", &PlayerClass::getGameMode, nullptr) - .def_property("max_health", &PlayerClass::getMaxHealth, nullptr) - .def_property("health", &PlayerClass::getHealth, nullptr) - .def_property("in_air", &PlayerClass::getInAir, nullptr) - .def_property("in_water", &PlayerClass::getInWater, nullptr) - .def_property("sneaking", &PlayerClass::getSneaking, nullptr) - .def_property("speed", &PlayerClass::getSpeed, nullptr) - .def_property("direction", &PlayerClass::getDirection, nullptr) - .def_property("unique_id", &PlayerClass::getUniqueID, nullptr) - .def_property("lang_code", &PlayerClass::getLangCode, nullptr) - - .def("__repr__", [](const PlayerClass& p) { return fmt::format("Player* = {}", (void*)p.thiz); }) - .def_property("ip", &PlayerClass::getIP, nullptr) - .def_property("avg_ping", &PlayerClass::getAvgPing, nullptr) - .def_property("avg_packet_loss", &PlayerClass::getAvgPacketLoss, nullptr) - .def_property("os", &PlayerClass::getOs, nullptr) - .def_property("client_id", &PlayerClass::getClientId, nullptr) - - .def("isOP", &PlayerClass::isOP) - .def("setPermLevel", &PlayerClass::setPermLevel) - .def("setGameMode", &PlayerClass::setGameMode) - - .def("runcmd", &PlayerClass::runcmd) - .def("teleport", &PlayerClass::teleport) - .def("kill", &PlayerClass::kill) - .def("kick", &PlayerClass::kick, "msg"_a = "Disconnecting from the server") - .def("sendText", &PlayerClass::sendText, "msg"_a = "", "type"_a = TextType::RAW) - .def("talkAs", &PlayerClass::talkAs) - .def("rename", &PlayerClass::rename) - .def("setOnFire", &PlayerClass::setOnFire) - .def("transServer", &PlayerClass::transServer, "ip"_a, "port"_a = 19132) - .def("crash", &PlayerClass::crash) - .def("hurt", &PlayerClass::hurt) - .def("refreshChunks", &PlayerClass::refreshChunks) - .def("giveItem", &PlayerClass::giveItem) - .def("clearItem", &PlayerClass::clearItem) - .def("isSprinting", &PlayerClass::isSprinting) - .def("setSprinting", &PlayerClass::setSprinting) - - .def("getBlockStandingOn", &PlayerClass::getBlockStandingOn) - .def("getHand", &PlayerClass::getHand) - .def("getOffHand", &PlayerClass::getOffHand) - .def("getInventory", &PlayerClass::getInventory) - .def("getArmor", &PlayerClass::getArmor) - .def("getEnderChest", &PlayerClass::getEnderChest) - .def("getRespawnPosition", &PlayerClass::getRespawnPosition) - .def("setRespawnPosition", &PlayerClass::setRespawnPosition) - .def("refreshItems", &PlayerClass::refreshItems) - .def("getScore", &PlayerClass::getScore) - .def("setScore", &PlayerClass::setScore) - .def("addScore", &PlayerClass::addScore) - .def("reduceScore", &PlayerClass::reduceScore) - .def("deleteScore", &PlayerClass::deleteScore) - .def("setSidebar", &PlayerClass::setSidebar) - .def("removeSidebar", &PlayerClass::removeSidebar) - .def("setBossBar", &PlayerClass::setBossBar) - .def("removeBossBar", py::overload_cast<>(&PlayerClass::removeBossBar)) - .def("removeBossBar", py::overload_cast(&PlayerClass::removeBossBar)) - .def("addLevel", &PlayerClass::addLevel) - .def("getLevel", &PlayerClass::getLevel) - .def("resetLevel", &PlayerClass::resetLevel) - .def("getXpNeededForNextLevel", &PlayerClass::getXpNeededForNextLevel) - .def("addExperience", &PlayerClass::addExperience) - - .def("sendSimpleForm", &PlayerClass::sendSimpleForm) - .def("sendModalForm", &PlayerClass::sendModalForm) - .def("sendCustomForm", &PlayerClass::sendCustomForm) - - .def("setExtraData", &PlayerClass::setExtraData) - .def("getExtraData", &PlayerClass::getExtraData) - .def("delExtraData", &PlayerClass::delExtraData) - - .def("setNbt", &PlayerClass::setNbt) - .def("getNbt", &PlayerClass::getNbt) - .def("addTag", &PlayerClass::addTag) - .def("removeTag", &PlayerClass::removeTag) - .def("hasTag", &PlayerClass::hasTag) - .def("getAllTags", &PlayerClass::getAllTags) - .def("getEntityFromViewVector", &PlayerClass::getEntityFromViewVector, "max_distance"_a = 5.25f) - .def("getBlockFromViewVector", &PlayerClass::getBlockFromViewVector, "includeLiquid"_a = false, "solidOnly"_a = false, "maxDistance"_a = 5.25f, "ignoreBorderBlocks"_a = true, "fullOnly"_a = false) - - .def("removeItem", &PlayerClass::removeItem) - .def("setHeadShow", &PlayerClass::setHeadShow) - - // SimulatedPlayer API - .def("isSimulatedPlayer", &PlayerClass::isSimulatedPlayer) - .def("simulateSneak", &PlayerClass::simulateSneak) - .def("simulateAttack", py::overload_cast<>(&PlayerClass::simulateAttack)) - .def("simulateAttack", py::overload_cast(&PlayerClass::simulateAttack)) - .def("simulateDestory", py::overload_cast<>(&PlayerClass::simulateDestory)) - .def("simulateDestory", py::overload_cast(&PlayerClass::simulateDestory)) - .def("simulateDisconnect", &PlayerClass::simulateDisconnect) - .def("simulateInteract", py::overload_cast<>(&PlayerClass::simulateInteract)) - .def("simulateInteractEntity", py::overload_cast(&PlayerClass::simulateInteract)) - .def("simulateInteractBlock", py::overload_cast(&PlayerClass::simulateInteract)) - .def("simulateJump", &PlayerClass::simulateJump) - .def("simulateLocalMove", &PlayerClass::simulateLocalMove, "target"_a, "speed"_a = 1.0f) - .def("simulateWorldMove", &PlayerClass::simulateWorldMove, "target"_a, "speed"_a = 1.0f) - .def("simulateMoveTo", &PlayerClass::simulateMoveTo, "target"_a, "speed"_a = 1.0f) - .def("simulateLookAt", py::overload_cast(&PlayerClass::simulateLookAt)) - .def("simulateLookAt", py::overload_cast(&PlayerClass::simulateLookAt)) - .def("simulateLookAt", py::overload_cast(&PlayerClass::simulateLookAt)) - .def("simulateSetBodyRotation", &PlayerClass::simulateSetBodyRotation) - .def("simulateNavigateTo", py::overload_cast, float>(&PlayerClass::simulateNavigateTo), "path"_a, "speed"_a = 1.0f) - .def("simulateNavigateTo", py::overload_cast(&PlayerClass::simulateNavigateTo), "pos"_a, "speed"_a = 1.0f) - .def("simulateNavigateTo", py::overload_cast(&PlayerClass::simulateNavigateTo), "target"_a, "speed"_a = 1.0f) - .def("simulateUseItem", py::overload_cast<>(&PlayerClass::simulateUseItem)) - .def("simulateUseItem2", py::overload_cast(&PlayerClass::simulateUseItem)) - .def("simulateUseItem3", py::overload_cast(&PlayerClass::simulateUseItem)) - .def("simulateUseItem4", py::overload_cast(&PlayerClass::simulateUseItem), "item"_a, "pos"_a, "face"_a, "relativePos"_a = Vec3(0.5, 0.5, 0.5)) - .def("simulateUseItem5", py::overload_cast(&PlayerClass::simulateUseItem), "slot"_a, "pos"_a, "face"_a, "relativePos"_a = Vec3(0.5, 0.5, 0.5)) - .def("simulateStopDestroyingBlock", &PlayerClass::simulateStopDestroyingBlock) - .def("simulateStopInteracting", &PlayerClass::simulateStopInteracting) - .def("simulateStopMoving", &PlayerClass::simulateStopMoving) - .def("simulateStopUsingItem", &PlayerClass::simulateStopUsingItem) - .def("simulateStopSneaking", &PlayerClass::simulateStopSneaking); + .def_property("name", &PlayerClass::getName, nullptr) + .def_property("pos", &PlayerClass::getPos, nullptr) + .def_property("blockpos", &PlayerClass::getBlockPos, nullptr) + .def_property("dim", &PlayerClass::getDim, nullptr) + .def_property("real_name", &PlayerClass::getRealName, nullptr) + .def_property("xuid", &PlayerClass::getXuid, nullptr) + .def_property("uuid", &PlayerClass::getUuid, nullptr) + .def_property("perm_level", &PlayerClass::getPermLevel, nullptr) + .def_property("game_mode", &PlayerClass::getGameMode, nullptr) + .def_property("max_health", &PlayerClass::getMaxHealth, nullptr) + .def_property("health", &PlayerClass::getHealth, nullptr) + .def_property("in_air", &PlayerClass::getInAir, nullptr) + .def_property("in_water", &PlayerClass::getInWater, nullptr) + .def_property("sneaking", &PlayerClass::getSneaking, nullptr) + .def_property("speed", &PlayerClass::getSpeed, nullptr) + .def_property("direction", &PlayerClass::getDirection, nullptr) + .def_property("unique_id", &PlayerClass::getUniqueID, nullptr) + .def_property("lang_code", &PlayerClass::getLangCode, nullptr) + + .def("__repr__", [](const PlayerClass& p) { return fmt::format("Player* = {}", (void*)p.thiz); }) + .def_property("ip", &PlayerClass::getIP, nullptr) + .def_property("avg_ping", &PlayerClass::getAvgPing, nullptr) + .def_property("avg_packet_loss", &PlayerClass::getAvgPacketLoss, nullptr) + .def_property("os", &PlayerClass::getOs, nullptr) + .def_property("client_id", &PlayerClass::getClientId, nullptr) + + .def("isOP", &PlayerClass::isOP) + .def("setPermLevel", &PlayerClass::setPermLevel) + .def("setGameMode", &PlayerClass::setGameMode) + + .def("runcmd", &PlayerClass::runcmd) + .def("teleport", &PlayerClass::teleport) + .def("kill", &PlayerClass::kill) + .def("kick", &PlayerClass::kick, "msg"_a = "Disconnecting from the server") + .def("sendText", &PlayerClass::sendText, "msg"_a = "", "type"_a = TextType::RAW) + .def("talkAs", &PlayerClass::talkAs) + .def("rename", &PlayerClass::rename) + .def("setOnFire", &PlayerClass::setOnFire) + .def("transServer", &PlayerClass::transServer, "ip"_a, "port"_a = 19132) + .def("crash", &PlayerClass::crash) + .def("hurt", &PlayerClass::hurt) + .def("refreshChunks", &PlayerClass::refreshChunks) + .def("giveItem", &PlayerClass::giveItem) + .def("clearItem", &PlayerClass::clearItem) + .def("isSprinting", &PlayerClass::isSprinting) + .def("setSprinting", &PlayerClass::setSprinting) + + .def("getBlockStandingOn", &PlayerClass::getBlockStandingOn) + .def("getHand", &PlayerClass::getHand) + .def("getOffHand", &PlayerClass::getOffHand) + .def("getInventory", &PlayerClass::getInventory) + .def("getArmor", &PlayerClass::getArmor) + .def("getEnderChest", &PlayerClass::getEnderChest) + .def("getRespawnPosition", &PlayerClass::getRespawnPosition) + .def("setRespawnPosition", &PlayerClass::setRespawnPosition) + .def("refreshItems", &PlayerClass::refreshItems) + .def("getScore", &PlayerClass::getScore) + .def("setScore", &PlayerClass::setScore) + .def("addScore", &PlayerClass::addScore) + .def("reduceScore", &PlayerClass::reduceScore) + .def("deleteScore", &PlayerClass::deleteScore) + .def("setSidebar", &PlayerClass::setSidebar) + .def("removeSidebar", &PlayerClass::removeSidebar) + .def("setBossBar", &PlayerClass::setBossBar) + .def("removeBossBar", py::overload_cast<>(&PlayerClass::removeBossBar)) + .def("removeBossBar", py::overload_cast(&PlayerClass::removeBossBar)) + .def("addLevel", &PlayerClass::addLevel) + .def("getLevel", &PlayerClass::getLevel) + .def("resetLevel", &PlayerClass::resetLevel) + .def("getXpNeededForNextLevel", &PlayerClass::getXpNeededForNextLevel) + .def("addExperience", &PlayerClass::addExperience) + + .def("sendSimpleForm", &PlayerClass::sendSimpleForm) + .def("sendModalForm", &PlayerClass::sendModalForm) + .def("sendCustomForm", &PlayerClass::sendCustomForm) + + .def("setExtraData", &PlayerClass::setExtraData) + .def("getExtraData", &PlayerClass::getExtraData) + .def("delExtraData", &PlayerClass::delExtraData) + + .def("setNbt", &PlayerClass::setNbt) + .def("getNbt", &PlayerClass::getNbt) + .def("addTag", &PlayerClass::addTag) + .def("removeTag", &PlayerClass::removeTag) + .def("hasTag", &PlayerClass::hasTag) + .def("getAllTags", &PlayerClass::getAllTags) + .def("getEntityFromViewVector", &PlayerClass::getEntityFromViewVector, "max_distance"_a = 5.25f) + .def("getBlockFromViewVector", &PlayerClass::getBlockFromViewVector, "includeLiquid"_a = false, "solidOnly"_a = false, "maxDistance"_a = 5.25f, "ignoreBorderBlocks"_a = true, "fullOnly"_a = false) + + .def("removeItem", &PlayerClass::removeItem) + .def("setHeadShow", &PlayerClass::setHeadShow) + + // SimulatedPlayer API + .def("isSimulatedPlayer", &PlayerClass::isSimulatedPlayer) + .def("simulateSneak", &PlayerClass::simulateSneak) + .def("simulateAttack", py::overload_cast<>(&PlayerClass::simulateAttack)) + .def("simulateAttack", py::overload_cast(&PlayerClass::simulateAttack)) + .def("simulateDestory", py::overload_cast<>(&PlayerClass::simulateDestory)) + .def("simulateDestory", py::overload_cast(&PlayerClass::simulateDestory)) + .def("simulateDisconnect", &PlayerClass::simulateDisconnect) + .def("simulateInteract", py::overload_cast<>(&PlayerClass::simulateInteract)) + .def("simulateInteractEntity", py::overload_cast(&PlayerClass::simulateInteract)) + .def("simulateInteractBlock", py::overload_cast(&PlayerClass::simulateInteract)) + .def("simulateJump", &PlayerClass::simulateJump) + .def("simulateLocalMove", &PlayerClass::simulateLocalMove, "target"_a, "speed"_a = 1.0f) + .def("simulateWorldMove", &PlayerClass::simulateWorldMove, "target"_a, "speed"_a = 1.0f) + .def("simulateMoveTo", &PlayerClass::simulateMoveTo, "target"_a, "speed"_a = 1.0f) + .def("simulateLookAt", py::overload_cast(&PlayerClass::simulateLookAt)) + .def("simulateLookAt", py::overload_cast(&PlayerClass::simulateLookAt)) + .def("simulateLookAt", py::overload_cast(&PlayerClass::simulateLookAt)) + .def("simulateSetBodyRotation", &PlayerClass::simulateSetBodyRotation) + .def("simulateNavigateTo", py::overload_cast, float>(&PlayerClass::simulateNavigateTo), "path"_a, "speed"_a = 1.0f) + .def("simulateNavigateTo", py::overload_cast(&PlayerClass::simulateNavigateTo), "pos"_a, "speed"_a = 1.0f) + .def("simulateNavigateTo", py::overload_cast(&PlayerClass::simulateNavigateTo), "target"_a, "speed"_a = 1.0f) + .def("simulateUseItem", py::overload_cast<>(&PlayerClass::simulateUseItem)) + .def("simulateUseItem2", py::overload_cast(&PlayerClass::simulateUseItem)) + .def("simulateUseItem3", py::overload_cast(&PlayerClass::simulateUseItem)) + .def("simulateUseItem4", py::overload_cast(&PlayerClass::simulateUseItem), "item"_a, "pos"_a, "face"_a, "relativePos"_a = Vec3(0.5, 0.5, 0.5)) + .def("simulateUseItem5", py::overload_cast(&PlayerClass::simulateUseItem), "slot"_a, "pos"_a, "face"_a, "relativePos"_a = Vec3(0.5, 0.5, 0.5)) + .def("simulateStopDestroyingBlock", &PlayerClass::simulateStopDestroyingBlock) + .def("simulateStopInteracting", &PlayerClass::simulateStopInteracting) + .def("simulateStopMoving", &PlayerClass::simulateStopMoving) + .def("simulateStopUsingItem", &PlayerClass::simulateStopUsingItem) + .def("simulateStopSneaking", &PlayerClass::simulateStopSneaking); py::class_(mc_module, "Entity") - .def_property("name", &EntityClass::getName, nullptr) - .def_property("type", &EntityClass::getType, nullptr) - .def_property("id", &EntityClass::getId, nullptr) - .def_property("pos", &EntityClass::getPos, nullptr) - .def_property("blockpos", &EntityClass::getBlockPos, nullptr) - .def_property("dim", &EntityClass::getDim, nullptr) - .def_property("max_health", &EntityClass::getMaxHealth, nullptr) - .def_property("health", &EntityClass::getHealth, nullptr) - .def_property("in_air", &EntityClass::getInAir, nullptr) - .def_property("in_water", &EntityClass::getInWater, nullptr) - .def_property("speed", &EntityClass::getSpeed, nullptr) - .def_property("direction", &EntityClass::getDirection, nullptr) - .def_property("unique_id", &EntityClass::getUniqueID, nullptr) - - .def("teleport", &EntityClass::teleport) - .def("kill", &EntityClass::kill) - .def("hurt", &EntityClass::hurt) - .def("setOnFire", &EntityClass::setOnFire) - .def("isPlayer", &EntityClass::isPlayer) - .def("toPlayer", &EntityClass::toPlayer) - .def("isItemEntity", &EntityClass::isItemEntity) - .def("toItem", &EntityClass::toItem) - .def("getBlockStandingOn", &EntityClass::getBlockStandingOn) - .def("getArmor", &EntityClass::getArmor) - .def("hasContainer", &EntityClass::hasContainer) - .def("getContainer", &EntityClass::getContainer) - .def("refreshItems", &EntityClass::refreshItems) - .def("setNbt", &EntityClass::setNbt) - .def("getNbt", &EntityClass::getNbt) - .def("addTag", &EntityClass::addTag) - .def("removeTag", &EntityClass::removeTag) - .def("hasTag", &EntityClass::hasTag) - .def("getAllTags", &EntityClass::getAllTags) - .def("getEntityFromViewVector", &EntityClass::getEntityFromViewVector) - .def("getBlockFromViewVector", &EntityClass::getBlockFromViewVector); + .def_property("name", &EntityClass::getName, nullptr) + .def_property("type", &EntityClass::getType, nullptr) + .def_property("id", &EntityClass::getId, nullptr) + .def_property("pos", &EntityClass::getPos, nullptr) + .def_property("blockpos", &EntityClass::getBlockPos, nullptr) + .def_property("dim", &EntityClass::getDim, nullptr) + .def_property("max_health", &EntityClass::getMaxHealth, nullptr) + .def_property("health", &EntityClass::getHealth, nullptr) + .def_property("in_air", &EntityClass::getInAir, nullptr) + .def_property("in_water", &EntityClass::getInWater, nullptr) + .def_property("speed", &EntityClass::getSpeed, nullptr) + .def_property("direction", &EntityClass::getDirection, nullptr) + .def_property("unique_id", &EntityClass::getUniqueID, nullptr) + + .def("teleport", &EntityClass::teleport) + .def("kill", &EntityClass::kill) + .def("hurt", &EntityClass::hurt) + .def("setOnFire", &EntityClass::setOnFire) + .def("isPlayer", &EntityClass::isPlayer) + .def("toPlayer", &EntityClass::toPlayer) + .def("isItemEntity", &EntityClass::isItemEntity) + .def("toItem", &EntityClass::toItem) + .def("getBlockStandingOn", &EntityClass::getBlockStandingOn) + .def("getArmor", &EntityClass::getArmor) + .def("hasContainer", &EntityClass::hasContainer) + .def("getContainer", &EntityClass::getContainer) + .def("refreshItems", &EntityClass::refreshItems) + .def("setNbt", &EntityClass::setNbt) + .def("getNbt", &EntityClass::getNbt) + .def("addTag", &EntityClass::addTag) + .def("removeTag", &EntityClass::removeTag) + .def("hasTag", &EntityClass::hasTag) + .def("getAllTags", &EntityClass::getAllTags) + .def("getEntityFromViewVector", &EntityClass::getEntityFromViewVector) + .def("getBlockFromViewVector", &EntityClass::getBlockFromViewVector); py::class_(mc_module, "BlockEntity") - .def_property("pos", &BlockEntityClass::getPos, nullptr) - .def_property("type", &BlockEntityClass::getType, nullptr) + .def_property("pos", &BlockEntityClass::getPos, nullptr) + .def_property("type", &BlockEntityClass::getType, nullptr) - .def("setNbt", &BlockEntityClass::setNbt) - .def("getNbt", &BlockEntityClass::getNbt) - .def("getBlock", &BlockEntityClass::getBlock); + .def("setNbt", &BlockEntityClass::setNbt) + .def("getNbt", &BlockEntityClass::getNbt) + .def("getBlock", &BlockEntityClass::getBlock); py::class_(mc_module, "Objective") - .def_property("name", &ObjectiveClass::getName, nullptr) - .def_property("display_name", &ObjectiveClass::getDisplayName, nullptr) + .def_property("name", &ObjectiveClass::getName, nullptr) + .def_property("display_name", &ObjectiveClass::getDisplayName, nullptr) - .def("setDisplay", &ObjectiveClass::setDisplay, "slot"_a, "sort"_a = 0) - .def("setScore", &ObjectiveClass::setScore) - .def("addScore", &ObjectiveClass::addScore) - .def("reduceScore", &ObjectiveClass::reduceScore) - .def("deleteScore", &ObjectiveClass::deleteScore) - .def("getScore", &ObjectiveClass::getScore); + .def("setDisplay", &ObjectiveClass::setDisplay, "slot"_a, "sort"_a = 0) + .def("setScore", &ObjectiveClass::setScore) + .def("addScore", &ObjectiveClass::addScore) + .def("reduceScore", &ObjectiveClass::reduceScore) + .def("deleteScore", &ObjectiveClass::deleteScore) + .def("getScore", &ObjectiveClass::getScore); #pragma endregion #pragma region Functions mc_module - .def("getBbsVersion", &LL::getBdsVersion) - .def("getServerProtocolVersion", &LL::getServerProtocolVersion) - .def("runCommand", &Level::runcmd) - .def("runCommandEx", &Level::runcmdEx) - .def("setListener", &mc::setListener) - .def("registerCommand", &mc::registerCommand, "name"_a, "desc"_a, "callback"_a, "perm"_a = GameMasters) - .def("getPlayer", &mc::getPlayer) - .def("getOnlinePlayers", &mc::getOnlinePlayers) - .def("getAllEntities", &mc::getAllEntities) - .def("setServerMotd", &LL::setServerMotd) - .def("broadcastText", &Level::broadcastText, "text"_a, "type"_a = TextType::RAW) - .def("broadcastTitle", &Level::broadcastTitle, "text"_a, "type"_a = TitleType::SetTitle, "fade_in_duration"_a = 100, "remain_duration"_a = 500, "fade_out_duration"_a = 100) - .def("getBlock", &mc::getBlock) - .def("setBlock", py::overload_cast(&mc::setBlock)) - .def("setBlock", py::overload_cast(&mc::setBlock)) - .def("getStructure", &mc::getStructure, "pos1"_a, "pos2"_a, "dim"_a, "ignore_entities"_a = true, "ignore_blocks"_a = false) - .def("setStructure", &mc::setStructure, "nbt"_a, "pos"_a, "dim"_a, "mir"_a = None_15, "rot"_a = None_14) - .def("explode", &mc::explode) - .def("spawnItem", &mc::spawnItem) - .def("setSignBlockMessage", &mc::setSignBlockMessage) - .def("isSlimeChunk", &mc::IsSlimeChunk) - - .def("spawnMob", &mc::spawnMob) - .def("cloneMob", &mc::cloneMob) - .def("spawnSimulatedPlayer", &mc::spawnSimulatedPlayer) - .def("spawnParticle", &mc::spawnParticle) - .def("setMotd", &LL::setServerMotd) - .def("sendCmdOutput", &mc::sendCmdOutput) - .def("getDisplayObjective", &mc::getDisplayObjective) - .def("clearDisplayObjective", &mc::clearDisplayObjective) - .def("getScoreObjective", &mc::getScoreObjective) - .def("newScoreObjective", &mc::newScoreObjective) - .def("removeScoreObjective", &mc::removeScoreObjective) - .def("getAllScoreObjectives", &mc::getAllScoreObjectives) - - .def("setMaxPlayers", &mc::setMaxNumPlayers) - - .def("getMoney", &EconomySystem::getMoney) - .def("setMoney", &EconomySystem::setMoney) - .def("addMoney", &EconomySystem::addMoney) - .def("reduceMoney", &EconomySystem::reduceMoney) - .def("transMoney", &EconomySystem::transMoney) - .def("getMoneyHist", &EconomySystem::getMoneyHist) - .def("clearMoneyHist", &EconomySystem::clearMoneyHist); + .def("getBbsVersion", &LL::getBdsVersion) + .def("getServerProtocolVersion", &LL::getServerProtocolVersion) + .def("runCommand", &Level::runcmd) + .def("runCommandEx", &Level::runcmdEx) + .def("setListener", &mc::setListener) + .def("registerCommand", &mc::registerCommand, "name"_a, "desc"_a, "callback"_a, "perm"_a = GameMasters) + .def("getPlayer", &mc::getPlayer) + .def("getOnlinePlayers", &mc::getOnlinePlayers) + .def("getAllEntities", &mc::getAllEntities) + .def("setServerMotd", &LL::setServerMotd) + .def("broadcastText", &Level::broadcastText, "text"_a, "type"_a = TextType::RAW) + .def("broadcastTitle", &Level::broadcastTitle, "text"_a, "type"_a = TitleType::SetTitle, "fade_in_duration"_a = 100, "remain_duration"_a = 500, "fade_out_duration"_a = 100) + .def("getBlock", &mc::getBlock) + .def("setBlock", py::overload_cast(&mc::setBlock)) + .def("setBlock", py::overload_cast(&mc::setBlock)) + .def("getStructure", &mc::getStructure, "pos1"_a, "pos2"_a, "dim"_a, "ignore_entities"_a = true, "ignore_blocks"_a = false) + .def("setStructure", &mc::setStructure, "nbt"_a, "pos"_a, "dim"_a, "mir"_a = None_15, "rot"_a = None_14) + .def("explode", &mc::explode) + .def("spawnItem", &mc::spawnItem) + .def("setSignBlockMessage", &mc::setSignBlockMessage) + .def("isSlimeChunk", &mc::IsSlimeChunk) + + .def("spawnMob", &mc::spawnMob) + .def("cloneMob", &mc::cloneMob) + .def("spawnSimulatedPlayer", &mc::spawnSimulatedPlayer) + .def("spawnParticle", &mc::spawnParticle) + .def("setMotd", &LL::setServerMotd) + .def("sendCmdOutput", &mc::sendCmdOutput) + .def("getDisplayObjective", &mc::getDisplayObjective) + .def("clearDisplayObjective", &mc::clearDisplayObjective) + .def("getScoreObjective", &mc::getScoreObjective) + .def("newScoreObjective", &mc::newScoreObjective) + .def("removeScoreObjective", &mc::removeScoreObjective) + .def("getAllScoreObjectives", &mc::getAllScoreObjectives) + + .def("setMaxPlayers", &mc::setMaxNumPlayers) + + .def("getMoney", &EconomySystem::getMoney) + .def("setMoney", &EconomySystem::setMoney) + .def("addMoney", &EconomySystem::addMoney) + .def("reduceMoney", &EconomySystem::reduceMoney) + .def("transMoney", &EconomySystem::transMoney) + .def("getMoneyHist", &EconomySystem::getMoneyHist) + .def("clearMoneyHist", &EconomySystem::clearMoneyHist); #pragma endregion PY_CATCH; } \ No newline at end of file