@@ -371,20 +371,19 @@ LL_TYPE_INSTANCE_HOOK(
371
371
}
372
372
373
373
LL_TYPE_INSTANCE_HOOK (
374
- ActorDestroyBlockEventHook ,
374
+ EndermanTakeBlockHook ,
375
375
HookPriority::Normal,
376
376
ActorEventCoordinator,
377
377
&ActorEventCoordinator::sendEvent,
378
378
CoordinatorResult,
379
379
EventRef<ActorGameplayEvent<CoordinatorResult>> const & event
380
- )
381
- try {
382
- return event.get ().visit ([&](auto && arg) {
380
+ ) {
381
+ bool canceled = event.get ().visit ([&](auto && arg) {
383
382
if constexpr (std::is_same_v<std::decay_t <decltype (arg)>, Details::ValueOrRef<ActorGriefingBlockEvent const >>) {
384
- auto & griefingEvent = arg. value ();
385
-
386
- if ( auto entity = griefingEvent.mActorContext ->tryUnwrap (); entity && entity-> isType (ActorType::EnderMan)) {
387
- IF_LISTENED (EVENT_TYPES::onEndermanTakeBlock ) {
383
+ IF_LISTENED (EVENT_TYPES::onEndermanTakeBlock) {
384
+ auto & griefingEvent = arg. value ();
385
+ auto entity = griefingEvent.mActorContext ->tryUnwrap ();
386
+ if (entity && entity-> isType (ActorType::EnderMan) ) {
388
387
if (!CallEvent (
389
388
EVENT_TYPES::onEndermanTakeBlock,
390
389
EntityClass::newEntity (entity.as_ptr ()),
@@ -395,16 +394,15 @@ try {
395
394
),
396
395
IntPos::newPos (BlockPos (griefingEvent.mPos ), entity->getDimensionId ())
397
396
)) {
398
- return CoordinatorResult::Cancel ;
397
+ return true ;
399
398
}
400
399
}
401
- IF_LISTENED_END (EVENT_TYPES::onEndermanTakeBlock);
402
400
}
403
- return CoordinatorResult::Continue ;
401
+ IF_LISTENED_END (EVENT_TYPES::onEndermanTakeBlock) ;
404
402
}
405
- return origin (event) ;
403
+ return false ;
406
404
});
407
- } catch (...) {
405
+ if (canceled) return CoordinatorResult::Cancel;
408
406
return origin (event);
409
407
}
410
408
@@ -423,7 +421,7 @@ void MobHurtEvent() {
423
421
MobHurtEffectHook::hook ();
424
422
}
425
423
void NpcCommandEvent () { NpcCommandHook::hook (); }
426
- void EndermanTakeBlockEvent () { ActorDestroyBlockEventHook ::hook (); }
424
+ void EndermanTakeBlockEvent () { EndermanTakeBlockHook ::hook (); }
427
425
void EffectUpdateEvent () { EffectUpdateHook::hook (); }
428
426
void TransformationEvent () { TransformationHook::hook (); }
429
427
} // namespace lse::events::entity
0 commit comments