From 1f921779fa53f63e2379ac723224160f468c10b2 Mon Sep 17 00:00:00 2001 From: zml2008 Date: Tue, 7 Feb 2012 17:14:14 -0800 Subject: [PATCH] Fixed the replaceBlocks that takes a Pattern too. Closes #1083. --- .../java/com/sk89q/worldedit/EditSession.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/EditSession.java b/src/main/java/com/sk89q/worldedit/EditSession.java index e9e6a2f26..756c7b3e7 100644 --- a/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/src/main/java/com/sk89q/worldedit/EditSession.java @@ -1333,12 +1333,13 @@ public class EditSession { public int replaceBlocks(Region region, Set fromBlockTypes, Pattern pattern) throws MaxChangedBlocksException { Set definiteBlockTypes = new HashSet(); Set fuzzyBlockTypes = new HashSet(); - - for (BaseBlock block : fromBlockTypes) { - if (block.getData() == -1) { - fuzzyBlockTypes.add(block.getType()); - } else { - definiteBlockTypes.add(block); + if (fromBlockTypes != null) { + for (BaseBlock block : fromBlockTypes) { + if (block.getData() == -1) { + fuzzyBlockTypes.add(block.getType()); + } else { + definiteBlockTypes.add(block); + } } } @@ -1362,14 +1363,14 @@ public class EditSession { Vector pt = new Vector(x, y, z); BaseBlock curBlockType = getBlock(pt); - if (definiteBlockTypes == null) { + if (fromBlockTypes == null) { //replace if (curBlockType.isAir()) { continue; } } else { //replace - if (!definiteBlockTypes.contains(curBlockType) && fuzzyBlockTypes.contains(curBlockType.getType())) { + if (!definiteBlockTypes.contains(curBlockType) && !fuzzyBlockTypes.contains(curBlockType.getType())) { continue; } } @@ -1384,14 +1385,14 @@ public class EditSession { for (Vector pt : region) { BaseBlock curBlockType = getBlock(pt); - if (definiteBlockTypes == null) { + if (fromBlockTypes == null) { //replace if (curBlockType.isAir()) { continue; } } else { //replace - if (!definiteBlockTypes.contains(curBlockType) && fuzzyBlockTypes.contains(curBlockType.getType())) { + if (!definiteBlockTypes.contains(curBlockType) && !fuzzyBlockTypes.contains(curBlockType.getType())) { continue; } }