From 0ebc73d17f6982d2f65e9782d308a24d2c5910cf Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 28 Aug 2017 23:48:18 +1000 Subject: [PATCH] Fixes #710 --- .../boydti/fawe/example/NMSMappedFaweQueue.java | 2 +- .../main/java/com/boydti/fawe/util/SetQueue.java | 14 ++++++++------ .../function/entity/ExtentEntityCopy.java | 7 +++++++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/com/boydti/fawe/example/NMSMappedFaweQueue.java b/core/src/main/java/com/boydti/fawe/example/NMSMappedFaweQueue.java index 336ac667..efaa2000 100644 --- a/core/src/main/java/com/boydti/fawe/example/NMSMappedFaweQueue.java +++ b/core/src/main/java/com/boydti/fawe/example/NMSMappedFaweQueue.java @@ -39,7 +39,7 @@ public abstract class NMSMappedFaweQueue ex public void runTasks() { super.runTasks(); if (!getRelighter().isEmpty()) { - TaskManager.IMP.taskNowAsync(new Runnable() { + TaskManager.IMP.async(new Runnable() { @Override public void run() { getRelighter().fixLightingSafe(hasSky()); diff --git a/core/src/main/java/com/boydti/fawe/util/SetQueue.java b/core/src/main/java/com/boydti/fawe/util/SetQueue.java index 2b312145..e419fa8a 100644 --- a/core/src/main/java/com/boydti/fawe/util/SetQueue.java +++ b/core/src/main/java/com/boydti/fawe/util/SetQueue.java @@ -108,18 +108,20 @@ public class SetQueue { boolean wait = false; do { Runnable task = tasks.poll(); - if (task != null) { - task.run(); - wait = true; - } else { + if (task == null) { if (wait) { synchronized (tasks) { tasks.wait(1); } + task = tasks.poll(); wait = false; - continue; + } else { + break; } - break; + } + if (task != null) { + task.run(); + wait = true; } } while ((used = System.currentTimeMillis() - now) < taskAllocate); currentAllocate -= used; diff --git a/core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java b/core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java index a6f38e84..e487f933 100644 --- a/core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java +++ b/core/src/main/java/com/sk89q/worldedit/function/entity/ExtentEntityCopy.java @@ -134,6 +134,7 @@ public class ExtentEntityCopy implements EntityFunction { private BaseEntity transformNbtData(BaseEntity state) { CompoundTag tag = state.getNbtData(); if (tag != null) { + boolean changed = false; // Handle hanging entities (paintings, item frames, etc.) tag = tag.createBuilder().build(); @@ -146,6 +147,7 @@ public class ExtentEntityCopy implements EntityFunction { boolean hasFacing = tag.containsKey("Facing"); if (hasTilePosition) { + changed = true; Vector tilePosition = new Vector(tag.asInt("TileX"), tag.asInt("TileY"), tag.asInt("TileZ")); Vector newTilePosition = transform.apply(tilePosition.subtract(from)).add(to); @@ -181,6 +183,7 @@ public class ExtentEntityCopy implements EntityFunction { ListTag rotation = tag.getListTag("Rotation"); if (rotation != null && rotation.getValue().size() >= 2) { + changed = true; double yaw = Math.toRadians(rotation.getFloat(0)); double pitch = Math.toRadians(rotation.getFloat(1)); @@ -191,6 +194,10 @@ public class ExtentEntityCopy implements EntityFunction { FloatTag pitchTag = new FloatTag(direction.toPitch()); values.put("Rotation", new ListTag(FloatTag.class, Arrays.asList(yawTag, pitchTag))); } + + if (changed) { + return new BaseEntity(state.getTypeId(), tag); + } } return state;