From 1d87642b5221f798aeed3e074d887b534f87816d Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Wed, 26 Dec 2018 18:15:17 +1000 Subject: [PATCH] Minor improvements to the server side CUI --- .../com/sk89q/worldedit/LocalSession.java | 24 ++++++++++++------- .../selector/CuboidRegionSelector.java | 2 ++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java index b9dcbe074..c4331d27d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -1144,23 +1144,25 @@ public class LocalSession implements TextureHolder { return; // If it's not enabled, ignore this. } - // Remove the old block. - if (cuiTemporaryBlock != null) { - player.sendFakeBlock(cuiTemporaryBlock, null); - cuiTemporaryBlock = null; - } - BaseBlock block = ServerCUIHandler.createStructureBlock(player); if (block != null) { // If it's null, we don't need to do anything. The old was already removed. Map tags = block.getNbtData().getValue(); - cuiTemporaryBlock = BlockVector3.at( + BlockVector3 tempCuiTemporaryBlock = BlockVector3.at( ((IntTag) tags.get("x")).getValue(), ((IntTag) tags.get("y")).getValue(), ((IntTag) tags.get("z")).getValue() ); - + if (cuiTemporaryBlock != null && !tempCuiTemporaryBlock.equals(cuiTemporaryBlock)) { + // Update the existing block if it's the same location + player.sendFakeBlock(cuiTemporaryBlock, null); + } + cuiTemporaryBlock = tempCuiTemporaryBlock; player.sendFakeBlock(cuiTemporaryBlock, block); + } else if (cuiTemporaryBlock != null) { + // Remove the old block + player.sendFakeBlock(cuiTemporaryBlock, null); + cuiTemporaryBlock = null; } } @@ -1200,6 +1202,12 @@ public class LocalSession implements TextureHolder { */ public void dispatchCUISelection(Actor actor) { checkNotNull(actor); + + if (!hasCUISupport && useServerCUI) { + updateServerCUI(actor); + return; + } + if (selector instanceof CUIRegion) { CUIRegion tempSel = (CUIRegion) selector; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java index c526cdfea..14adfc8e7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java @@ -249,6 +249,8 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion { public void clear() { position1 = null; position2 = null; + region.setPos1(BlockVector3.ZERO); + region.setPos2(BlockVector3.ZERO); } @Override