From 05cee0a30b305e1bb2a003c71183992a2296e46f Mon Sep 17 00:00:00 2001 From: wizjany Date: Tue, 16 Jul 2019 21:43:14 -0400 Subject: [PATCH] Don't overwrite history during changes. Fixes issues with some changes not being undone. I mean, the sphere algorithm needs to not set blocks 20 times, but other things can trigger this too. Also allow radius 0 sphere via //sphere (because /br sphere allows it). --- .../sk89q/worldedit/command/GenerationCommands.java | 10 +++++----- .../history/changeset/BlockOptimizedHistory.java | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java index 4ae72b9d7..9fcfd2c37 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java @@ -162,13 +162,13 @@ public class GenerationCommands { final double radiusX, radiusY, radiusZ; switch (radii.size()) { case 1: - radiusX = radiusY = radiusZ = Math.max(1, radii.get(0)); + radiusX = radiusY = radiusZ = Math.max(0, radii.get(0)); break; case 3: - radiusX = Math.max(1, radii.get(0)); - radiusY = Math.max(1, radii.get(1)); - radiusZ = Math.max(1, radii.get(2)); + radiusX = Math.max(0, radii.get(0)); + radiusY = Math.max(0, radii.get(1)); + radiusZ = Math.max(0, radii.get(2)); break; default: @@ -205,7 +205,7 @@ public class GenerationCommands { @Arg(desc = "The density of the forest, between 0 and 100", def = "5") double density) throws WorldEditException { checkCommandArgument(0 <= density && density <= 100, "Density must be between 0 and 100"); - density = density / 100; + density /= 100; int affected = editSession.makeForest(session.getPlacementPosition(player), size, density, type); player.print(affected + " trees created."); return affected; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/BlockOptimizedHistory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/BlockOptimizedHistory.java index 9c9ad2a85..05ac90c78 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/BlockOptimizedHistory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/history/changeset/BlockOptimizedHistory.java @@ -55,7 +55,9 @@ public class BlockOptimizedHistory extends ArrayListHistory { if (change instanceof BlockChange) { BlockChange blockChange = (BlockChange) change; BlockVector3 position = blockChange.getPosition(); - previous.add(position, blockChange.getPrevious()); + if (!previous.containsLocation(position)) { + previous.add(position, blockChange.getPrevious()); + } current.add(position, blockChange.getCurrent()); } else { super.add(change);