Fix lead_break sound playing after cancelling EntityUnleashEvent (#12944)
This commit is contained in:
@@ -49,15 +49,16 @@
|
|||||||
entity.dropLeash();
|
entity.dropLeash();
|
||||||
} else {
|
} else {
|
||||||
entity.removeLeash();
|
entity.removeLeash();
|
||||||
@@ -154,7 +_,7 @@
|
@@ -154,8 +_,7 @@
|
||||||
if (leashHolder != null && leashHolder.level() == entity.level()) {
|
if (leashHolder != null && leashHolder.level() == entity.level()) {
|
||||||
double d = entity.leashDistanceTo(leashHolder);
|
double d = entity.leashDistanceTo(leashHolder);
|
||||||
entity.whenLeashedTo(leashHolder);
|
entity.whenLeashedTo(leashHolder);
|
||||||
- if (d > entity.leashSnapDistance()) {
|
- if (d > entity.leashSnapDistance()) {
|
||||||
|
- level.playSound(null, leashHolder.getX(), leashHolder.getY(), leashHolder.getZ(), SoundEvents.LEAD_BREAK, SoundSource.NEUTRAL, 1.0F, 1.0F);
|
||||||
+ if (d > entity.leashSnapDistanceOrConfig()) { // Paper - Configurable max leash distance
|
+ if (d > entity.leashSnapDistanceOrConfig()) { // Paper - Configurable max leash distance
|
||||||
level.playSound(null, leashHolder.getX(), leashHolder.getY(), leashHolder.getZ(), SoundEvents.LEAD_BREAK, SoundSource.NEUTRAL, 1.0F, 1.0F);
|
|
||||||
entity.leashTooFarBehaviour();
|
entity.leashTooFarBehaviour();
|
||||||
} else if (d > entity.leashElasticDistance() - leashHolder.getBbWidth() - entity.getBbWidth()
|
} else if (d > entity.leashElasticDistance() - leashHolder.getBbWidth() - entity.getBbWidth()
|
||||||
|
&& entity.checkElasticInteractions(leashHolder, leashData)) {
|
||||||
@@ -175,6 +_,12 @@
|
@@ -175,6 +_,12 @@
|
||||||
entity.checkFallDistanceAccumulation();
|
entity.checkFallDistanceAccumulation();
|
||||||
}
|
}
|
||||||
@@ -71,7 +72,7 @@
|
|||||||
default double leashSnapDistance() {
|
default double leashSnapDistance() {
|
||||||
return 12.0;
|
return 12.0;
|
||||||
}
|
}
|
||||||
@@ -196,7 +_,21 @@
|
@@ -196,7 +_,25 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
default void leashTooFarBehaviour() {
|
default void leashTooFarBehaviour() {
|
||||||
@@ -82,7 +83,11 @@
|
|||||||
+ // Paper start - Expand EntityUnleashEvent
|
+ // Paper start - Expand EntityUnleashEvent
|
||||||
+ final org.bukkit.event.entity.EntityUnleashEvent event = new org.bukkit.event.entity.EntityUnleashEvent(entity.getBukkitEntity(), org.bukkit.event.entity.EntityUnleashEvent.UnleashReason.DISTANCE, true);
|
+ final org.bukkit.event.entity.EntityUnleashEvent event = new org.bukkit.event.entity.EntityUnleashEvent(entity.getBukkitEntity(), org.bukkit.event.entity.EntityUnleashEvent.UnleashReason.DISTANCE, true);
|
||||||
+ if (!event.callEvent()) return;
|
+ if (!event.callEvent()) return;
|
||||||
|
+
|
||||||
|
+ Entity leashHolder = this.getLeashHolder();
|
||||||
|
+ Level level = leashHolder.level();
|
||||||
+ dropLeash = event.isDropLeash();
|
+ dropLeash = event.isDropLeash();
|
||||||
|
+ level.playSound(null, leashHolder.getX(), leashHolder.getY(), leashHolder.getZ(), SoundEvents.LEAD_BREAK, SoundSource.NEUTRAL, 1.0F, 1.0F); // Moved from Leashable#tickLeash
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
+ if (dropLeash) {
|
+ if (dropLeash) {
|
||||||
|
|||||||
Reference in New Issue
Block a user