mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-08 19:34:09 +01:00
49 lines
2.2 KiB
Diff
49 lines
2.2 KiB
Diff
--- a/net/minecraft/world/entity/TamableAnimal.java
|
|
+++ b/net/minecraft/world/entity/TamableAnimal.java
|
|
@@ -27,6 +27,11 @@
|
|
import net.minecraft.world.level.pathfinder.PathType;
|
|
import net.minecraft.world.level.pathfinder.WalkNodeEvaluator;
|
|
import net.minecraft.world.scores.PlayerTeam;
|
|
+// CraftBukkit start
|
|
+import org.bukkit.Location;
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
+import org.bukkit.event.entity.EntityTeleportEvent;
|
|
+// CraftBukkit end
|
|
|
|
public abstract class TamableAnimal extends Animal implements OwnableEntity {
|
|
|
|
@@ -96,8 +101,16 @@
|
|
@Override
|
|
public boolean handleLeashAtDistance(Entity leashHolder, float distance) {
|
|
if (this.isInSittingPose()) {
|
|
- if (distance > 10.0F) {
|
|
- this.dropLeash();
|
|
+ if (distance > (float) this.level().paperConfig().misc.maxLeashDistance.or(Leashable.LEASH_TOO_FAR_DIST)) { // Paper - Configurable max leash distance
|
|
+ // Paper start - Expand EntityUnleashEvent
|
|
+ org.bukkit.event.entity.EntityUnleashEvent event = new org.bukkit.event.entity.EntityUnleashEvent(this.getBukkitEntity(), org.bukkit.event.entity.EntityUnleashEvent.UnleashReason.DISTANCE, true);
|
|
+ if (!event.callEvent()) return false;
|
|
+ if (event.isDropLeash()) {
|
|
+ this.dropLeash();
|
|
+ } else {
|
|
+ this.removeLeash();
|
|
+ }
|
|
+ // Paper end - Expand EntityUnleashEvent
|
|
}
|
|
|
|
return false;
|
|
@@ -295,7 +308,14 @@
|
|
if (!this.canTeleportTo(new BlockPos(x, y, z))) {
|
|
return false;
|
|
} else {
|
|
- this.moveTo((double) x + 0.5D, (double) y, (double) z + 0.5D, this.getYRot(), this.getXRot());
|
|
+ // CraftBukkit start
|
|
+ EntityTeleportEvent event = CraftEventFactory.callEntityTeleportEvent(this, (double) x + 0.5D, (double) y, (double) z + 0.5D);
|
|
+ if (event.isCancelled()) {
|
|
+ return false;
|
|
+ }
|
|
+ Location to = event.getTo();
|
|
+ this.moveTo(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch());
|
|
+ // CraftBukkit end
|
|
this.navigation.stop();
|
|
return true;
|
|
}
|