From 9c14e47cb2fdcd4bd4aaac15514d35371fa63f97 Mon Sep 17 00:00:00 2001 From: CJH3139 Date: Sun, 5 Oct 2025 16:45:42 -0700 Subject: [PATCH 1/2] Add aliases for closest to nearest entity expression --- .../java/ch/njol/skript/expressions/ExprNearestEntity.java | 4 ++-- .../skript/tests/syntaxes/expressions/ExprNearestEntity.sk | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/ch/njol/skript/expressions/ExprNearestEntity.java b/src/main/java/ch/njol/skript/expressions/ExprNearestEntity.java index 3f5db26c97a..e2cc6631ad3 100644 --- a/src/main/java/ch/njol/skript/expressions/ExprNearestEntity.java +++ b/src/main/java/ch/njol/skript/expressions/ExprNearestEntity.java @@ -37,8 +37,8 @@ public class ExprNearestEntity extends SimpleExpression { static { Skript.registerExpression(ExprNearestEntity.class, Entity.class, ExpressionType.COMBINED, - "[the] nearest %*entitydatas% [[relative] to %entity/location%]", - "[the] %*entitydatas% nearest [to %entity/location%]"); + "[the] (nearest|closest) %*entitydatas% [[relative] to %entity/location%]", + "[the] %*entitydatas% (nearest|closest) [to %entity/location%]"); } @SuppressWarnings("NotNullFieldNotInitialized") diff --git a/src/test/skript/tests/syntaxes/expressions/ExprNearestEntity.sk b/src/test/skript/tests/syntaxes/expressions/ExprNearestEntity.sk index 843dcf7a8ae..ed930f83315 100644 --- a/src/test/skript/tests/syntaxes/expressions/ExprNearestEntity.sk +++ b/src/test/skript/tests/syntaxes/expressions/ExprNearestEntity.sk @@ -16,3 +16,10 @@ test "nearest entity does not allow duplicate entities": # assert nearest entity relative to {_cow} is {_pig} with "incorrect nearest entity found" # assert nearest entity relative to (location of {_cow}) is {_cow} with "incorrect nearest entity found when using location" # delete all entities + +### +test "closest entity": + spawn a pig at test-location: + set {_pig} to entity + assert closest entity of test-location is set with "syntax doesn't work :(" +### From ae8b8db257e9e9e08967738cec9e14630df14df0 Mon Sep 17 00:00:00 2001 From: CJH3139 Date: Sun, 5 Oct 2025 16:59:47 -0700 Subject: [PATCH 2/2] updated test script for ExprNearestEntity --- .../tests/syntaxes/expressions/ExprNearestEntity.sk | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/test/skript/tests/syntaxes/expressions/ExprNearestEntity.sk b/src/test/skript/tests/syntaxes/expressions/ExprNearestEntity.sk index ed930f83315..857621ff993 100644 --- a/src/test/skript/tests/syntaxes/expressions/ExprNearestEntity.sk +++ b/src/test/skript/tests/syntaxes/expressions/ExprNearestEntity.sk @@ -1,5 +1,6 @@ test "nearest entity does not allow duplicate entities": assert nearest cow and cow relative to {_null} to fail with "duplicate entities were allowed in nearest entity expr" + assert closest cow and cow relative to {_null} to fail with "duplicate entities were allowed in nearest entity expr" # server doesn't spawn the entities until the next tick, and we can't wait in the test system so... commented for now #test "nearest entity": @@ -16,10 +17,3 @@ test "nearest entity does not allow duplicate entities": # assert nearest entity relative to {_cow} is {_pig} with "incorrect nearest entity found" # assert nearest entity relative to (location of {_cow}) is {_cow} with "incorrect nearest entity found when using location" # delete all entities - -### -test "closest entity": - spawn a pig at test-location: - set {_pig} to entity - assert closest entity of test-location is set with "syntax doesn't work :(" -###