From aae92490144760dd8551bb62f374408bef7b6d35 Mon Sep 17 00:00:00 2001 From: opl- Date: Sat, 7 Oct 2023 20:16:21 +0200 Subject: [PATCH] Fix NullPointerException due to nullable source extent in ExtentEntityCopy (#2447) Fix NullPointerException due to nullable source extent Co-authored-by: opl <4833621+opl@users.noreply.github.com> --- .../sk89q/worldedit/function/entity/ExtentEntityCopy.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java index 7a034d7bd..fa3ef1dc4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java @@ -257,7 +257,8 @@ public class ExtentEntityCopy implements EntityFunction { //FAWE start if (hasRotation) { ListTag orgrot = state.getNbtData().getListTag("Rotation"); - Vector3 orgDirection = new Location(source, 0, 0, 0, orgrot.getFloat(0), orgrot.getFloat(1)).getDirection(); + // source extent may be null: use non-nullable destination instead since this is just a conversion into a vector. + Vector3 orgDirection = new Location(destination, 0, 0, 0, orgrot.getFloat(0), orgrot.getFloat(1)).getDirection(); Vector3 newDirection = transform.apply(orgDirection).subtract(transform.apply(Vector3.ZERO)).normalize(); builder.put( "Rotation", @@ -276,7 +277,8 @@ public class ExtentEntityCopy implements EntityFunction { CompoundTagBuilder builder = tag.createBuilder(); ListTag orgrot = state.getNbtData().getListTag("Rotation"); - Vector3 orgDirection = new Location(source, 0, 0, 0, orgrot.getFloat(0), orgrot.getFloat(1)).getDirection(); + // source extent may be null: use non-nullable destination instead since this is just a conversion into a vector. + Vector3 orgDirection = new Location(destination, 0, 0, 0, orgrot.getFloat(0), orgrot.getFloat(1)).getDirection(); Vector3 newDirection = transform.apply(orgDirection).subtract(transform.apply(Vector3.ZERO)).normalize(); builder.put( "Rotation",