PaperMC/nms-patches/PathfinderGoalFollowOwner.patch

35 lines
2 KiB
Diff
Raw Normal View History

--- a/net/minecraft/server/PathfinderGoalFollowOwner.java
+++ b/net/minecraft/server/PathfinderGoalFollowOwner.java
2019-04-23 04:00:00 +02:00
@@ -1,6 +1,11 @@
package net.minecraft.server;
2019-04-23 04:00:00 +02:00
import java.util.EnumSet;
+// CraftBukkit start
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.entity.CraftEntity;
+import org.bukkit.event.entity.EntityTeleportEvent;
+// CraftBukkit end
2019-04-23 04:00:00 +02:00
public class PathfinderGoalFollowOwner extends PathfinderGoal {
2019-04-23 04:00:00 +02:00
@@ -80,7 +85,18 @@
for (int l = 0; l <= 4; ++l) {
for (int i1 = 0; i1 <= 4; ++i1) {
2019-04-23 04:00:00 +02:00
if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && this.a(new BlockPosition(i + l, k - 1, j + i1))) {
- this.a.setPositionRotation((double) ((float) (i + l) + 0.5F), (double) k, (double) ((float) (j + i1) + 0.5F), this.a.yaw, this.a.pitch);
+ // CraftBukkit start
2019-04-23 04:00:00 +02:00
+ CraftEntity entity = this.a.getBukkitEntity();
+ Location to = new Location(entity.getWorld(), (double) ((float) (i + l) + 0.5F), (double) k, (double) ((float) (j + i1) + 0.5F), this.a.yaw, this.a.pitch);
+ EntityTeleportEvent event = new EntityTeleportEvent(entity, entity.getLocation(), to);
2019-04-23 04:00:00 +02:00
+ this.a.world.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;
+ }
+ to = event.getTo();
+
2019-04-23 04:00:00 +02:00
+ this.a.setPositionRotation(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch());
+ // CraftBukkit end
2019-04-23 04:00:00 +02:00
this.e.o();
return;
}