From 1a3ae37b731e0b1b66feb878b16b22e650268a30 Mon Sep 17 00:00:00 2001 From: FrozenBrain Date: Fri, 1 Jan 2016 21:56:34 +0100 Subject: [PATCH] Fix rotation of item frames --- .../function/entity/ExtentEntityCopy.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 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 a23ae4be7..200f82e60 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 @@ -131,6 +131,7 @@ public class ExtentEntityCopy implements EntityFunction { boolean hasTilePosition = tag.containsKey("TileX") && tag.containsKey("TileY") && tag.containsKey("TileZ"); boolean hasDirection = tag.containsKey("Direction"); boolean hasLegacyDirection = tag.containsKey("Dir"); + boolean hasFacing = tag.containsKey("Facing"); if (hasTilePosition) { Vector tilePosition = new Vector(tag.asInt("TileX"), tag.asInt("TileY"), tag.asInt("TileZ")); @@ -141,15 +142,25 @@ public class ExtentEntityCopy implements EntityFunction { .putInt("TileY", newTilePosition.getBlockY()) .putInt("TileZ", newTilePosition.getBlockZ()); - if (hasDirection || hasLegacyDirection) { - int d = hasDirection ? tag.asInt("Direction") : MCDirections.fromLegacyHanging((byte) tag.asInt("Dir")); + if (hasDirection || hasLegacyDirection || hasFacing) { + int d; + if (hasDirection) { + d = tag.asInt("Direction"); + } else if (hasLegacyDirection) { + d = MCDirections.fromLegacyHanging((byte) tag.asInt("Dir")); + } else { + d = tag.asInt("Facing"); + } + Direction direction = MCDirections.fromHanging(d); if (direction != null) { Vector vector = transform.apply(direction.toVector()).subtract(transform.apply(Vector.ZERO)).normalize(); Direction newDirection = Direction.findClosest(vector, Flag.CARDINAL); - builder.putByte("Direction", (byte) MCDirections.toHanging(newDirection)); + byte hangingByte = (byte) MCDirections.toHanging(newDirection); + builder.putByte("Direction", hangingByte); + builder.putByte("Facing", hangingByte); builder.putByte("Dir", MCDirections.toLegacyHanging(MCDirections.toHanging(newDirection))); } }