From 3c371d2eb1aaee961c0623b395bacd8ab22dfb20 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 24 Oct 2016 22:22:55 +1100 Subject: [PATCH] Fix rotation fixes rotation for signs, banners and nbt data --- .../transform/BlockTransformExtent.java | 12 +++++++-- .../sk89q/worldedit/session/PasteBuilder.java | 2 -- .../world/registry/BundledBlockData.java | 27 +++++++++++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java b/core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java index 6b57f6e0..67cf7444 100644 --- a/core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java +++ b/core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java @@ -78,11 +78,19 @@ public class BlockTransformExtent extends AbstractDelegateExtent { } private final BaseBlock transformFast(BaseBlock block) { - return BLOCK_TRANSFORM[FaweCache.getCombined(block)]; + BaseBlock newBlock = BLOCK_TRANSFORM[FaweCache.getCombined(block)]; + if (block.hasNbtData()) { + newBlock.setNbtData(block.getNbtData()); + } + return newBlock; } private final BaseBlock transformFastInverse(BaseBlock block) { - return BLOCK_TRANSFORM_INVERSE[FaweCache.getCombined(block)]; + BaseBlock newBlock = BLOCK_TRANSFORM_INVERSE[FaweCache.getCombined(block)]; + if (block.hasNbtData()) { + newBlock.setNbtData(block.getNbtData()); + } + return newBlock; } /** diff --git a/core/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java b/core/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java index d254b9ed..8a1fff51 100644 --- a/core/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java +++ b/core/src/main/java/com/sk89q/worldedit/session/PasteBuilder.java @@ -21,7 +21,6 @@ package com.sk89q.worldedit.session; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.transform.BlockTransformExtent; import com.sk89q.worldedit.function.mask.ExistingBlockMask; @@ -97,7 +96,6 @@ public class PasteBuilder { extent = new BlockTransformExtent(extent, transform, targetWorldData.getBlockRegistry()); } ForwardExtentCopy copy = new ForwardExtentCopy(extent, clipboard.getRegion(), clipboard.getOrigin(), targetExtent, to); - System.out.println(clipboard.getRegion()); copy.setTransform(transform); if (ignoreAirBlocks) { copy.setSourceMask(new ExistingBlockMask(clipboard)); diff --git a/core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java b/core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java index 7eb90039..2ed350df 100644 --- a/core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java +++ b/core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java @@ -114,6 +114,33 @@ public class BundledBlockData { if (bot != null && bot.getDirection() == null) { bot.setDirection(new Vector(0, -1, 0)); } + } else { + FaweState dir = entry.states.get("rotation"); + if (dir != null && dir.values != null) { + Vector[] dirs = new Vector[]{new Vector(0, 0, -1), + new Vector(0.5, 0, -1), + new Vector(1, 0, -1), + new Vector(1, 0, -0.5), + new Vector(1, 0, 0), + new Vector(1, 0, 0.5), + new Vector(1, 0, 1), + new Vector(0.5, 0, 1), + new Vector(0, 0, 1), + new Vector(-0.5, 0, 1), + new Vector(-1, 0, 1), + new Vector(-1, 0, 0.5), + new Vector(-1, 0, 0), + new Vector(-1, 0, -0.5), + new Vector(-1, 0, -1), + new Vector(-0.5, 0, -1)}; + int len = dir.values.size(); + int increment = 16 / len; + int index = 0; + for (Map.Entry valuesEntry : dir.values.entrySet()) { + valuesEntry.getValue().setDirection(dirs[index]); + index += increment; + } + } } }