Skip to content

Commit

Permalink
Fix #457, explosion global sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
CJCrafter committed Sep 16, 2024
1 parent 77958ac commit f08701d
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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())
Expand Down

0 comments on commit f08701d

Please sign in to comment.