From a695bb81fe521ef33cbbeb13416f23adfbd46fbc Mon Sep 17 00:00:00 2001 From: aurora Date: Thu, 9 May 2024 20:56:48 +0200 Subject: [PATCH] Fix paintings not getting rotated correctly Co-authored-by: Octavia Togami --- .../function/entity/ExtentEntityCopy.java | 17 +++++++++++++++-- 1 file changed, 15 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 a0a69c263c..de48230c28 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 @@ -186,7 +186,7 @@ private BaseEntity transformNbtData(BaseEntity state) { .putInt("TileY", newTilePosition.y()) .putInt("TileZ", newTilePosition.z()); - if (tag.value().get("Facing") instanceof LinNumberTag tagFacing) { + if (tryGetFacingData(tag) instanceof FacingTagData(String facingKey, LinNumberTag tagFacing)) { boolean isPainting = state.getType() == EntityTypes.PAINTING; // Paintings have different facing values Direction direction = isPainting ? MCDirections.fromHorizontalHanging(tagFacing.value().intValue()) @@ -202,7 +202,7 @@ private BaseEntity transformNbtData(BaseEntity state) { ? MCDirections.toHorizontalHanging(newDirection) : MCDirections.toHanging(newDirection) ); - builder.putByte("Facing", facingValue); + builder.putByte(facingKey, facingValue); } } } @@ -213,4 +213,17 @@ private BaseEntity transformNbtData(BaseEntity state) { return state; } + + private record FacingTagData(String facingKey, LinNumberTag tagFacing) { + } + + private static FacingTagData tryGetFacingData(LinCompoundTag tag) { + if (tag.value().get("Facing") instanceof LinNumberTag tagFacingCapital) { + return new FacingTagData("Facing", tagFacingCapital); + } else if (tag.value().get("facing") instanceof LinNumberTag tagFacingLower) { + return new FacingTagData("facing", tagFacingLower); + } else { + return null; + } + } }