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).
This commit is contained in:
wizjany 2019-07-16 21:43:14 -04:00
parent f75104f2ac
commit 05cee0a30b
2 changed files with 8 additions and 6 deletions

View File

@ -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;

View File

@ -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);