Commits

md_5 authored 3804ba654e0
SPIGOT-1373: Implement EntityTargetEvent for TEMPT.

This can be a high frequency event call. Use with care.
No tags

nms-patches/PathfinderGoalTempt.patch

Added
1 +--- a/net/minecraft/server/PathfinderGoalTempt.java
2 ++++ b/net/minecraft/server/PathfinderGoalTempt.java
3 +@@ -3,6 +3,12 @@
4 + import com.google.common.collect.Sets;
5 + import java.util.Set;
6 + import javax.annotation.Nullable;
7 ++// CraftBukkit start
8 ++import org.bukkit.craftbukkit.entity.CraftLivingEntity;
9 ++import org.bukkit.craftbukkit.event.CraftEventFactory;
10 ++import org.bukkit.event.entity.EntityTargetEvent;
11 ++import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
12 ++// CraftBukkit end
13 +
14 + public class PathfinderGoalTempt extends PathfinderGoal {
15 +
16 +@@ -13,7 +19,7 @@
17 + private double e;
18 + private double f;
19 + private double g;
20 +- private EntityHuman h;
21 ++ private EntityLiving h; // CraftBukkit
22 + private int i;
23 + private boolean j;
24 + private final Set<Item> k;
25 +@@ -40,7 +46,18 @@
26 + return false;
27 + } else {
28 + this.h = this.a.world.findNearbyPlayer(this.a, 10.0D);
29 +- return this.h == null ? false : this.a(this.h.getItemInMainHand()) || this.a(this.h.getItemInOffHand());
30 ++ // CraftBukkit start
31 ++ // PAIL: rename
32 ++ boolean tempt = this.h == null ? false : this.a(this.h.getItemInMainHand()) || this.a(this.h.getItemInOffHand());
33 ++ if (tempt) {
34 ++ EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(this.a, this.h, EntityTargetEvent.TargetReason.TEMPT);
35 ++ if (event.isCancelled()) {
36 ++ return false;
37 ++ }
38 ++ this.h = ((CraftLivingEntity) event.getTarget()).getHandle();
39 ++ }
40 ++ return tempt;
41 ++ // CraftBukkit end
42 + }
43 + }
44 +

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut