@@ -371,20 +371,19 @@ LL_TYPE_INSTANCE_HOOK(
371371}
372372
373373LL_TYPE_INSTANCE_HOOK (
374- ActorDestroyBlockEventHook ,
374+ EndermanTakeBlockHook ,
375375 HookPriority::Normal,
376376 ActorEventCoordinator,
377377 &ActorEventCoordinator::sendEvent,
378378 CoordinatorResult,
379379 EventRef<ActorGameplayEvent<CoordinatorResult>> const & event
380- )
381- try {
382- return event.get ().visit ([&](auto && arg) {
380+ ) {
381+ bool canceled = event.get ().visit ([&](auto && arg) {
383382 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) ) {
388387 if (!CallEvent (
389388 EVENT_TYPES::onEndermanTakeBlock,
390389 EntityClass::newEntity (entity.as_ptr ()),
@@ -395,16 +394,15 @@ try {
395394 ),
396395 IntPos::newPos (BlockPos (griefingEvent.mPos ), entity->getDimensionId ())
397396 )) {
398- return CoordinatorResult::Cancel ;
397+ return true ;
399398 }
400399 }
401- IF_LISTENED_END (EVENT_TYPES::onEndermanTakeBlock);
402400 }
403- return CoordinatorResult::Continue ;
401+ IF_LISTENED_END (EVENT_TYPES::onEndermanTakeBlock) ;
404402 }
405- return origin (event) ;
403+ return false ;
406404 });
407- } catch (...) {
405+ if (canceled) return CoordinatorResult::Cancel;
408406 return origin (event);
409407}
410408
@@ -423,7 +421,7 @@ void MobHurtEvent() {
423421 MobHurtEffectHook::hook ();
424422}
425423void NpcCommandEvent () { NpcCommandHook::hook (); }
426- void EndermanTakeBlockEvent () { ActorDestroyBlockEventHook ::hook (); }
424+ void EndermanTakeBlockEvent () { EndermanTakeBlockHook ::hook (); }
427425void EffectUpdateEvent () { EffectUpdateHook::hook (); }
428426void TransformationEvent () { TransformationHook::hook (); }
429427} // namespace lse::events::entity
0 commit comments