Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return isNegative() and not false, if CondIsWithin is invalid #7038

Merged
merged 3 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/ch/njol/skript/conditions/CondIsWithin.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ public boolean check(Event event) {
Location one = loc1.getSingle(event);
Location two = loc2.getSingle(event);
if (one == null || two == null || one.getWorld() != two.getWorld())
return false;
return isNegated();
AABB box = new AABB(one, two);
return locsToCheck.check(event, box::contains, isNegated());
}

// else, within an entity/block/chunk/world
Object area = this.area.getSingle(event);
if (area == null)
return false;
return isNegated();

// Entities
if (area instanceof Entity) {
Expand Down
2 changes: 2 additions & 0 deletions src/test/skript/tests/syntaxes/conditions/CondIsWithin.sk
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ test "within condition" when running minecraft "1.17":
set {_loc2} to location(20, 20, 20, "world")
assert location(10, 10, 10, "world") is within {_loc1} and {_loc2} with "failed within two locs"
assert location(10, -10, 10, "world") is not within {_loc1} and {_loc2} with "failed within two locs"
assert location(0, 0, 0, "world") is not within {_none} and {_none} with "failed within two locs"

# chunks
set {_chunk1} to chunk at {_loc1}
Expand Down Expand Up @@ -37,6 +38,7 @@ test "within condition" when running below minecraft "1.17":
set {_loc2} to location(20, 20, 20, "world")
assert location(10, 10, 10, "world") is within {_loc1} and {_loc2} with "failed within two locs"
assert location(10, -10, 10, "world") is not within {_loc1} and {_loc2} with "failed within two locs"
assert location(0, 0, 0, "world") is not within {_none} and {_none} with "failed within two locs"

# chunks
set {_chunk1} to chunk at {_loc1}
Expand Down