From f08701df507e6fe8e9bb9ab27f0a0eabd6ce609d Mon Sep 17 00:00:00 2001 From: Collin Barber Date: Mon, 16 Sep 2024 18:36:24 -0400 Subject: [PATCH] Fix #457, explosion global sounds --- .../core/mechanics/conditions/RangeCondition.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/MechanicsCore/src/main/java/me/deecaad/core/mechanics/conditions/RangeCondition.java b/MechanicsCore/src/main/java/me/deecaad/core/mechanics/conditions/RangeCondition.java index c9eaa78a9..1802a540c 100644 --- a/MechanicsCore/src/main/java/me/deecaad/core/mechanics/conditions/RangeCondition.java +++ b/MechanicsCore/src/main/java/me/deecaad/core/mechanics/conditions/RangeCondition.java @@ -3,6 +3,7 @@ import me.deecaad.core.file.SerializeData; import me.deecaad.core.file.SerializerException; import me.deecaad.core.mechanics.CastData; +import org.bukkit.Location; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -26,8 +27,14 @@ public RangeCondition(OptionalDouble minSquared, OptionalDouble maxSquared) { @Override public boolean isAllowed0(CastData cast) { - double distanceSquared = cast.getTargetLocation().distanceSquared(cast.getSourceLocation()); + // Bias towards using the target + Location targetLocation; + if (cast.getTarget() != null) + targetLocation = cast.getTarget().getEyeLocation(); + else + targetLocation = cast.getTargetLocation(); + double distanceSquared = targetLocation.distanceSquared(cast.getSourceLocation()); if (minSquared.isPresent() && distanceSquared < minSquared.getAsDouble()) return false; if (maxSquared.isPresent() && distanceSquared >= maxSquared.getAsDouble())