diff --git a/src/main/java/io/github/edwinmindcraft/apoli/api/power/configuration/power/InteractionPowerConfiguration.java b/src/main/java/io/github/edwinmindcraft/apoli/api/power/configuration/power/InteractionPowerConfiguration.java index a800cf12c..4b8c95d84 100644 --- a/src/main/java/io/github/edwinmindcraft/apoli/api/power/configuration/power/InteractionPowerConfiguration.java +++ b/src/main/java/io/github/edwinmindcraft/apoli/api/power/configuration/power/InteractionPowerConfiguration.java @@ -66,11 +66,10 @@ public void performActorItemStuff(LivingEntity actor, InteractionHand hand) { Mutable resultingStack = this.itemResult() == null ? heldStack : new MutableObject<>(this.itemResult().copy()); boolean modified = this.itemResult() != null; if (this.resultItemAction().isBound()) { - this.resultItemAction().value().execute(actor.level(), resultingStack); - modified = true; + ConfiguredItemAction.execute(this.resultItemAction(), actor.level(), resultingStack); } if (modified) { - if (heldStack.getValue().isEmpty()) + if (resultingStack.getValue().isEmpty()) actor.setItemInHand(hand, resultingStack.getValue()); else if (actor instanceof Player player) player.getInventory().placeItemBackInInventory(resultingStack.getValue()); diff --git a/src/main/java/io/github/edwinmindcraft/apoli/common/ApoliPowerEventHandler.java b/src/main/java/io/github/edwinmindcraft/apoli/common/ApoliPowerEventHandler.java index b3e7cf331..d122bbfb7 100644 --- a/src/main/java/io/github/edwinmindcraft/apoli/common/ApoliPowerEventHandler.java +++ b/src/main/java/io/github/edwinmindcraft/apoli/common/ApoliPowerEventHandler.java @@ -404,11 +404,16 @@ public static void preventEntityInteraction(PlayerInteractEvent.EntityInteract e Player player = event.getEntity(); if (player.isSpectator()) return; Entity target = event.getTarget(); - ActionOnEntityUsePower.tryPrevent(player, target, event.getHand()) - .or(() -> ActionOnBeingUsedPower.tryPrevent(target, player, event.getHand())).ifPresent(res -> { - event.setCancellationResult(res); - event.setCanceled(true); - }); + Optional result = ActionOnEntityUsePower.tryPrevent(player, target, event.getHand()); + if (result.isEmpty() || result.get() == InteractionResult.PASS) { + result = ActionOnBeingUsedPower.tryPrevent(target, player, event.getHand()); + } + result.ifPresent(res -> { + if (res != InteractionResult.PASS) { + event.setCancellationResult(res); + event.setCanceled(true); + } + }); } @SubscribeEvent(priority = EventPriority.HIGHEST)