--- a/net/minecraft/world/entity/ai/sensing/TemptingSensor.java
+++ b/net/minecraft/world/entity/ai/sensing/TemptingSensor.java
@@ -3,10 +3,13 @@
 import com.google.common.collect.ImmutableSet;
 import java.util.Comparator;
 import java.util.List;
+import java.util.Objects;
 import java.util.Set;
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 import net.minecraft.server.level.ServerLevel;
+import net.minecraft.world.entity.Entity;
 import net.minecraft.world.entity.EntitySelector;
 import net.minecraft.world.entity.PathfinderMob;
 import net.minecraft.world.entity.ai.Brain;
@@ -15,33 +18,55 @@
 import net.minecraft.world.entity.player.Player;
 import net.minecraft.world.item.ItemStack;
 
+// CraftBukkit start
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.entity.HumanEntity;
+import org.bukkit.event.entity.EntityTargetEvent;
+import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
+// CraftBukkit end
+
 public class TemptingSensor extends Sensor<PathfinderMob> {
+
     public static final int TEMPTATION_RANGE = 10;
-    private static final TargetingConditions TEMPT_TARGETING = TargetingConditions.forNonCombat().range(10.0).ignoreLineOfSight();
+    private static final TargetingConditions TEMPT_TARGETING = TargetingConditions.forNonCombat().range(10.0D).ignoreLineOfSight();
     private final Predicate<ItemStack> temptations;
 
     public TemptingSensor(Predicate<ItemStack> predicate) {
         this.temptations = predicate;
     }
 
-    @Override
     protected void doTick(ServerLevel world, PathfinderMob entity) {
-        Brain<?> brain = entity.getBrain();
-        List<Player> list = world.players()
-            .stream()
-            .filter(EntitySelector.NO_SPECTATORS)
-            .filter(playerx -> TEMPT_TARGETING.test(entity, playerx))
-            .filter(playerx -> entity.closerThan(playerx, 10.0))
-            .filter(this::playerHoldingTemptation)
-            .filter(serverPlayer -> !entity.hasPassenger(serverPlayer))
-            .sorted(Comparator.comparingDouble(entity::distanceToSqr))
-            .collect(Collectors.toList());
+        Brain<?> behaviorcontroller = entity.getBrain();
+        Stream<net.minecraft.server.level.ServerPlayer> stream = world.players().stream().filter(EntitySelector.NO_SPECTATORS).filter((entityplayer) -> { // CraftBukkit - decompile error
+            return TemptingSensor.TEMPT_TARGETING.test(entity, entityplayer);
+        }).filter((entityplayer) -> {
+            return entity.closerThan(entityplayer, 10.0D);
+        }).filter(this::playerHoldingTemptation).filter((entityplayer) -> {
+            return !entity.hasPassenger((Entity) entityplayer);
+        });
+
+        Objects.requireNonNull(entity);
+        List<Player> list = (List) stream.sorted(Comparator.comparingDouble(entity::distanceToSqr)).collect(Collectors.toList());
+
         if (!list.isEmpty()) {
-            Player player = list.get(0);
-            brain.setMemory(MemoryModuleType.TEMPTING_PLAYER, player);
+            Player entityhuman = (Player) list.get(0);
+
+            // CraftBukkit start
+            EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(entity, entityhuman, EntityTargetEvent.TargetReason.TEMPT);
+            if (event.isCancelled()) {
+                return;
+            }
+            if (event.getTarget() instanceof HumanEntity) {
+                behaviorcontroller.setMemory(MemoryModuleType.TEMPTING_PLAYER, ((CraftHumanEntity) event.getTarget()).getHandle());
+            } else {
+                behaviorcontroller.eraseMemory(MemoryModuleType.TEMPTING_PLAYER);
+            }
+            // CraftBukkit end
         } else {
-            brain.eraseMemory(MemoryModuleType.TEMPTING_PLAYER);
+            behaviorcontroller.eraseMemory(MemoryModuleType.TEMPTING_PLAYER);
         }
+
     }
 
     private boolean playerHoldingTemptation(Player player) {
