From fabd7045e72f99f003482f2804a1d67c9a4309e8 Mon Sep 17 00:00:00 2001 From: FrozenBrain Date: Sat, 21 May 2016 02:00:30 +0200 Subject: [PATCH] Fix NPE when rotating hanging entities (#356) --- .../worldedit/function/entity/ExtentEntityCopy.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 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 200f82e60..58663ab3c 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 @@ -158,10 +158,12 @@ public class ExtentEntityCopy implements EntityFunction { Vector vector = transform.apply(direction.toVector()).subtract(transform.apply(Vector.ZERO)).normalize(); Direction newDirection = Direction.findClosest(vector, Flag.CARDINAL); - byte hangingByte = (byte) MCDirections.toHanging(newDirection); - builder.putByte("Direction", hangingByte); - builder.putByte("Facing", hangingByte); - builder.putByte("Dir", MCDirections.toLegacyHanging(MCDirections.toHanging(newDirection))); + if (newDirection != null) { + byte hangingByte = (byte) MCDirections.toHanging(newDirection); + builder.putByte("Direction", hangingByte); + builder.putByte("Facing", hangingByte); + builder.putByte("Dir", MCDirections.toLegacyHanging(MCDirections.toHanging(newDirection))); + } } }