Skip to content

Commit

Permalink
Fix AIOOB with ExprVectorXYZ when used with non-vectors (#6387)
Browse files Browse the repository at this point in the history
fix aioob error and add regression test
  • Loading branch information
sovdeeth committed Feb 4, 2024
1 parent 884641c commit 3fbf72e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/ch/njol/skript/expressions/ExprVectorXYZ.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
public class ExprVectorXYZ extends SimplePropertyExpression<Vector, Number> {

static {
register(ExprVectorXYZ.class, Number.class, "[vector] (0¦x|1¦y|2¦z) [component[s]]", "vectors");
// TODO: Combine with ExprCoordinates for 2.9
register(ExprVectorXYZ.class, Number.class, "[vector] (0:x|1:y|2:z) [component[s]]", "vectors");
}

private final static Character[] axes = new Character[] {'x', 'y', 'z'};
Expand Down Expand Up @@ -84,6 +85,8 @@ public Class<?>[] acceptChange(ChangeMode mode) {
public void change(Event event, @Nullable Object[] delta, ChangeMode mode) {
assert delta != null;
Vector[] vectors = getExpr().getArray(event);
if (vectors.length == 0)
return;
double deltaValue = ((Number) delta[0]).doubleValue();
switch (mode) {
case REMOVE:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test "x component of block":
set {_a} to block at location(0, 0, 0)
add 1 to x of {_a} # should not throw exception

0 comments on commit 3fbf72e

Please sign in to comment.