diff --git a/LiteLoader/api/Basic_Event.cpp b/LiteLoader/api/Basic_Event.cpp index 6dae7301cf..d9b4b18664 100644 --- a/LiteLoader/api/Basic_Event.cpp +++ b/LiteLoader/api/Basic_Event.cpp @@ -120,10 +120,14 @@ THook(bool, } Player *MakeSP(CommandOrigin &ori) { + Player *pl = (Player *)ori.getEntity(); + if (pl) { + return pl; + } // if (ori.getOriginType() == OriginType::Player) { - return (Player *)ori.getEntity(); + // } - // return 0; + return 0; } vector> PlayerUseCmdCallBacks; diff --git a/headers/api/commands.h b/headers/api/commands.h index a1960599b9..02926d849d 100644 --- a/headers/api/commands.h +++ b/headers/api/commands.h @@ -249,15 +249,22 @@ static_assert(sizeof(MakeOverload) == 1); { MakeOverload __ov2((struct name2 *)0, cb2, #name2, cb, __VA_ARGS__); } #include inline static optional MakeWP(CommandOrigin const &ori) { - if (ori.getOriginType() == OriginType::Player) { + if ((ServerPlayer *)ori.getEntity()) { return {{*(ServerPlayer *)ori.getEntity()}}; } + // if (ori.getOriginType() == OriginType::Player) { + //return {{*(ServerPlayer *)ori.getEntity()}}; + //} return {}; } inline static ServerPlayer *MakeSP(CommandOrigin const &ori) { - if (ori.getOriginType() == OriginType::Player) { - return {(ServerPlayer *)ori.getEntity()}; + ServerPlayer *sp = (ServerPlayer *)ori.getEntity(); + if (sp) { + return {sp}; } + // if (ori.getOriginType() == OriginType::Player) { + //return {(ServerPlayer *)ori.getEntity()}; + //} return nullptr; } inline static ServerPlayer *MakeSP(void *x) {