Skip to content

Commit a0cb26b

Browse files
committed
feat: add onPlayerPullFishingHook
chore: remove more-events from xmake.lua
1 parent c749c6b commit a0cb26b

File tree

4 files changed

+29
-12
lines changed

4 files changed

+29
-12
lines changed

src/legacy/api/EventAPI.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,9 @@ void EnableEventListener(int eventId) {
850850
case EVENT_TYPES::onOpenInventory:
851851
lse::events::PlayerOpenInventoryEvent();
852852
break;
853-
853+
case EVENT_TYPES::onPlayerPullFishingHook:
854+
lse::events::PlayerPullFishingHookEvent();
855+
break;
854856
default:
855857
break;
856858
}

src/legacy/events/EventHooks.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
#include <mc/server/module/VanillaServerGameplayEventListener.h>
1818
#include <mc/world/actor/ActorDefinitionIdentifier.h>
1919
#include <mc/world/actor/ArmorStand.h>
20+
#include <mc/world/actor/FishingHook.h>
2021
#include <mc/world/actor/boss/WitherBoss.h>
22+
#include <mc/world/actor/item/ItemActor.h>
2123
#include <mc/world/actor/player/Player.h>
2224
#include <mc/world/containers/models/LevelContainerModel.h>
2325
#include <mc/world/events/EventResult.h>
@@ -773,6 +775,28 @@ LL_TYPE_INSTANCE_HOOK(
773775
origin();
774776
}
775777

778+
LL_TYPE_INSTANCE_HOOK(
779+
PlayerPullFishingHook,
780+
HookPriority::Normal,
781+
FishingHook,
782+
&FishingHook::_pullCloser,
783+
void,
784+
Actor& inEntity,
785+
float inSpeed
786+
) {
787+
IF_LISTENED(EVENT_TYPES::onPlayerPullFishingHook) {
788+
CallEventVoid(
789+
EVENT_TYPES::onPlayerPullFishingHook,
790+
PlayerClass::newPlayer(this->getPlayerOwner()),
791+
EntityClass::newEntity(&inEntity),
792+
inEntity.isType(ActorType::ItemEntity) ? ItemClass::newItem(&static_cast<ItemActor&>(inEntity).item(), true)
793+
: Local<Value>()
794+
);
795+
}
796+
IF_LISTENED_END(EVENT_TYPES::onPlayerPullFishingHook);
797+
origin(inEntity, inSpeed);
798+
}
799+
776800
void PlayerStartDestroyBlock() { PlayerStartDestroyHook::hook(); }
777801
void PlayerDropItem() { PlayerDropItemHook::hook(); }
778802
void PlayerOpenContainerEvent() { PlayerOpenContainerHook::hook(); }
@@ -815,6 +839,7 @@ void CommandBlockExecuteEvent() { CommandBlockExecuteHook::hook(); }
815839
void PlayerUseRespawnAnchorEvent() { PlayerUseRespawnAnchorHook::hook(); }
816840
void PlayerSleepEvent() { PlayerSleepHook::hook(); }
817841
void PlayerOpenInventoryEvent() { PlayerOpenInventoryHook::hook(); }
842+
void PlayerPullFishingHookEvent() { PlayerPullFishingHook::hook(); }
818843

819844
// NOLINTEND(cppcoreguidelines-pro-type-reinterpret-cast)
820845
// NOLINTEND(cppcoreguidelines-avoid-non-const-global-variables)

src/legacy/events/EventHooks.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ void CommandBlockExecuteEvent();
3030
void PlayerUseRespawnAnchorEvent();
3131
void PlayerSleepEvent();
3232
void PlayerOpenInventoryEvent();
33+
void PlayerPullFishingHookEvent();
3334

3435
} // namespace lse::events

xmake.lua

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ add_requires(
1212
"levilamina 0.9.2",
1313
"lightwebsocketclient",
1414
"magic_enum",
15-
"more-events develop",
1615
"nlohmann_json",
1716
"openssl 1.1.1-w",
1817
"simpleini",
@@ -44,15 +43,6 @@ option("backend")
4443
set_default("lua")
4544
set_values("lua", "quickjs", "python", "nodejs")
4645

47-
package("more-events")
48-
add_urls("https://github.com/LiteLDev/MoreEvents.git")
49-
50-
add_deps("levilamina 0.9.2")
51-
52-
on_install(function (package)
53-
import("package.tools.xmake").install(package)
54-
end)
55-
5646
target("legacy-script-engine")
5747
add_cxflags(
5848
"/EHa",
@@ -83,7 +73,6 @@ target("legacy-script-engine")
8373
"levilamina",
8474
"lightwebsocketclient",
8575
"magic_enum",
86-
"more-events",
8776
"nlohmann_json",
8877
"scriptx",
8978
"simpleini",

0 commit comments

Comments
 (0)