Skip to content

Commit

Permalink
fix: fix onAte event #222 (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
killcerr authored Feb 3, 2025
1 parent 2eeeef6 commit b7779f4
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/lse/events/EventHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
#include "mc/world/events/PlayerOpenContainerEvent.h"
#include "mc/world/level/material/Material.h"
#include "mc/world/level/dimension/Dimension.h"
#include "mc/world/actor/player/PlayerItemInUse.h"
#include "ll/api/thread/ThreadName.h"

namespace lse::events {
Expand Down Expand Up @@ -578,7 +579,7 @@ LL_TYPE_INSTANCE_HOOK(
return shouldPush;
}

LL_TYPE_INSTANCE_HOOK(PlayerEatHook, HookPriority::Normal, Player, &Player::eat, void, ItemStack const& instance) {
LL_TYPE_INSTANCE_HOOK(PlayerEatHook1, HookPriority::Normal, Player, &Player::eat, void, ItemStack const& instance) {
IF_LISTENED(EVENT_TYPES::onAte) {
if (!CallEvent(
EVENT_TYPES::onAte,
Expand All @@ -592,6 +593,26 @@ LL_TYPE_INSTANCE_HOOK(PlayerEatHook, HookPriority::Normal, Player, &Player::eat,
origin(instance);
}

LL_TYPE_INSTANCE_HOOK(
PlayerEatHook2,
HookPriority::Normal,
ItemStack,
&ItemStack::useTimeDepleted,
::ItemUseMethod,
Level* level,
Player* player
) {
IF_LISTENED(EVENT_TYPES::onAte) {
if (isPotionItem() || getTypeName() == "minecraft:milk_bucket") {
if (!CallEvent(EVENT_TYPES::onAte, PlayerClass::newPlayer(player), ItemClass::newItem(this))) {
return ItemUseMethod::Unknown;
}
}
}
IF_LISTENED_END(EVENT_TYPES::onAte);
return origin(level, player);
}

LL_TYPE_INSTANCE_HOOK(ExplodeHook, HookPriority::Normal, Level, &Level::$explode, bool, ::Explosion& explosion) {
IF_LISTENED(EVENT_TYPES::onEntityExplode) {
if (explosion.mSourceID->rawID != ActorUniqueID::INVALID_ID().rawID) {
Expand Down Expand Up @@ -1332,7 +1353,10 @@ void ActorRideEvent() { ActorRideHook::hook(); }
void WitherDestroyEvent() { WitherDestroyHook::hook(); }
void FarmDecayEvent() { FarmDecayHook::hook(); }
void PistonPushEvent() { PistonPushHook::hook(); }
void PlayerEatEvent() { PlayerEatHook::hook(); }
void PlayerEatEvent() {
PlayerEatHook1::hook();
PlayerEatHook2::hook();
}
void ExplodeEvent() { ExplodeHook::hook(); }
void RespawnAnchorExplodeEvent() { RespawnAnchorExplodeHook::hook(); }
void BlockExplodedEvent() { BlockExplodedHook ::hook(); }
Expand Down

0 comments on commit b7779f4

Please sign in to comment.