Skip to content

Commit

Permalink
fix: fix PlayerJumpEvent crash
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamguxiang committed Dec 29, 2024
1 parent 0c5a2e6 commit 82975b1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ll/api/event/player/PlayerJumpEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "mc/network/ServerNetworkHandler.h"
#include "mc/network/packet/PlayerAuthInputPacket.h"
#include "mc/server/ServerPlayer.h"

namespace ll::event::inline player {
LL_AUTO_TYPE_INSTANCE_HOOK(
PlayerJumpEventHook,
Expand All @@ -14,8 +16,10 @@ LL_AUTO_TYPE_INSTANCE_HOOK(
::NetworkIdentifier const& source,
::PlayerAuthInputPacket const& packet
) {
if (ServerPlayer* player = _getServerPlayer(source, packet.mClientSubId)) {
auto& handle = ll::memory::dAccess<ServerNetworkHandler>(this, -16);
if (ServerPlayer* player = handle._getServerPlayer(source, packet.mClientSubId)) {
if (packet.getInput(::PlayerAuthInputPacket::InputData::StartJumping)) {
std::cout << player->getRealName() << std::endl;
EventBus::getInstance().publish(PlayerJumpEvent(*(Player*)player));
}
}
Expand Down

0 comments on commit 82975b1

Please sign in to comment.