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