3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-21 05:50:05 +01:00
Paper/nms-patches/PathfinderGoalTempt.patch

44 Zeilen
1.7 KiB
Diff

--- a/net/minecraft/server/PathfinderGoalTempt.java
+++ b/net/minecraft/server/PathfinderGoalTempt.java
2018-07-15 02:00:00 +02:00
@@ -1,5 +1,12 @@
package net.minecraft.server;
2016-11-17 02:41:03 +01:00
+// 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
2018-07-15 02:00:00 +02:00
+
public class PathfinderGoalTempt extends PathfinderGoal {
2018-07-15 02:00:00 +02:00
private final EntityCreature a;
@@ -9,7 +16,7 @@
private double e;
private double f;
private double g;
2017-05-14 04:00:00 +02:00
- private EntityHuman target;
+ private EntityLiving target; // CraftBukkit
private int i;
private boolean j;
2018-07-15 02:00:00 +02:00
private final RecipeItemStack k;
@@ -36,7 +43,17 @@
return false;
} else {
2017-05-14 04:00:00 +02:00
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
2017-05-14 04:00:00 +02:00
+ boolean tempt = this.target == null ? false : this.a(this.target.getItemInMainHand()) || this.a(this.target.getItemInOffHand());
+ if (tempt) {
2017-05-14 04:00:00 +02:00
+ 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
}
}