From 642f2a1f581ad49544bc7c140bedc8a0f24eacef Mon Sep 17 00:00:00 2001 From: wizjany Date: Fri, 29 May 2015 15:44:17 -0400 Subject: [PATCH] Fix entities copying to original location. Fixes WORLDEDIT-3275. --- .../function/entity/ExtentEntityCopy.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 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 134e10bd9..a23ae4be7 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 @@ -89,19 +89,19 @@ public class ExtentEntityCopy implements EntityFunction { BaseEntity state = entity.getState(); if (state != null) { Location newLocation; + Location location = entity.getLocation(); - if (!transform.isIdentity()) { - Location location = entity.getLocation(); - Vector pivot = from.round().add(0.5, 0.5, 0.5); - Vector newPosition = transform.apply(location.toVector().subtract(pivot)); - Vector newDirection = transform.apply(location.getDirection()).subtract(transform.apply(Vector.ZERO)).normalize(); - newLocation = new Location(destination, newPosition.add(to.round().add(0.5, 0.5, 0.5)), newDirection); + Vector pivot = from.round().add(0.5, 0.5, 0.5); + Vector newPosition = transform.apply(location.toVector().subtract(pivot)); + Vector newDirection; - // Some entities store their position data in NBT - state = transformNbtData(state); - } else { - newLocation = entity.getLocation(); - } + newDirection = transform.isIdentity() ? + entity.getLocation().getDirection() + : transform.apply(location.getDirection()).subtract(transform.apply(Vector.ZERO)).normalize(); + newLocation = new Location(destination, newPosition.add(to.round().add(0.5, 0.5, 0.5)), newDirection); + + // Some entities store their position data in NBT + state = transformNbtData(state); boolean success = destination.createEntity(newLocation, state) != null;