mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 19:49:35 +01:00
b2efd58164
By: md_5 <git@md-5.net>
44 lines
1.8 KiB
Diff
44 lines
1.8 KiB
Diff
--- a/net/minecraft/server/PathfinderGoalTempt.java
|
|
+++ b/net/minecraft/server/PathfinderGoalTempt.java
|
|
@@ -2,6 +2,13 @@
|
|
|
|
import java.util.EnumSet;
|
|
|
|
+// 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 static final PathfinderTargetCondition c = (new PathfinderTargetCondition()).a(10.0D).a().b().d().c();
|
|
@@ -12,7 +19,7 @@
|
|
private double g;
|
|
private double h;
|
|
private double i;
|
|
- protected EntityHuman target;
|
|
+ protected EntityLiving target; // CraftBukkit
|
|
private int j;
|
|
private boolean k;
|
|
private final RecipeItemStack l;
|
|
@@ -40,7 +47,17 @@
|
|
return false;
|
|
} else {
|
|
this.target = this.a.world.a(PathfinderGoalTempt.c, (EntityLiving) this.a);
|
|
- 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
|
|
}
|
|
}
|
|
|