diff --git a/src/main/java/com/sk89q/worldedit/EditSession.java b/src/main/java/com/sk89q/worldedit/EditSession.java
index 5562eedea..82ebf74ef 100644
--- a/src/main/java/com/sk89q/worldedit/EditSession.java
+++ b/src/main/java/com/sk89q/worldedit/EditSession.java
@@ -367,24 +367,19 @@ public int getHighestTerrainBlock(int x, int z, int minY, int maxY, boolean natu
* @param level the level
* @return whether the block changed
*/
- public boolean setBlock(Vector position, BaseBlock block, boolean notifyAdjacent, Level level) throws WorldEditException {
+ public boolean setBlock(Vector position, BaseBlock block, Level level) throws WorldEditException {
switch (level) {
case NORMAL:
- return bypassNone.setBlock(position, block, notifyAdjacent);
+ return bypassNone.setBlock(position, block);
case NO_HISTORY_REORDER:
- return bypassHistory.setBlock(position, block, notifyAdjacent);
+ return bypassHistory.setBlock(position, block);
case NO_HISTORY:
- return bypassReorderHistory.setBlock(position, block, notifyAdjacent);
+ return bypassReorderHistory.setBlock(position, block);
}
throw new RuntimeException("New enum entry added that is unhandled here");
}
- @Override
- public boolean setBlock(Vector location, BaseBlock block, boolean notifyAdjacent) throws WorldEditException {
- return setBlock(location, block, notifyAdjacent, Level.NORMAL);
- }
-
/**
* Set a block, bypassing both history and block re-ordering.
*
@@ -396,7 +391,7 @@ public boolean setBlock(Vector location, BaseBlock block, boolean notifyAdjacent
@Deprecated
public boolean rawSetBlock(Vector position, BaseBlock block) {
try {
- return setBlock(position, block, true, Level.NO_HISTORY_REORDER);
+ return setBlock(position, block, Level.NO_HISTORY_REORDER);
} catch (WorldEditException e) {
throw new RuntimeException("Unexpected exception", e);
}
@@ -413,23 +408,16 @@ public boolean rawSetBlock(Vector position, BaseBlock block) {
@Deprecated
public boolean smartSetBlock(Vector position, BaseBlock block) {
try {
- return setBlock(position, block, true, Level.NO_HISTORY);
+ return setBlock(position, block, Level.NO_HISTORY);
} catch (WorldEditException e) {
throw new RuntimeException("Unexpected exception", e);
}
}
- /**
- * Sets the block at a position, subject to both history and block re-ordering.
- *
- * @param position the position
- * @param block the block
- * @return Whether the block changed -- not entirely dependable
- * @throws MaxChangedBlocksException thrown if too many blocks are changed
- */
+ @Override
public boolean setBlock(Vector position, BaseBlock block) throws MaxChangedBlocksException {
try {
- return setBlock(position, block, true, Level.NORMAL);
+ return setBlock(position, block, Level.NORMAL);
} catch (MaxChangedBlocksException e) {
throw e;
} catch (WorldEditException e) {
diff --git a/src/main/java/com/sk89q/worldedit/LocalWorld.java b/src/main/java/com/sk89q/worldedit/LocalWorld.java
index e5ed7edfb..433ec7fd0 100644
--- a/src/main/java/com/sk89q/worldedit/LocalWorld.java
+++ b/src/main/java/com/sk89q/worldedit/LocalWorld.java
@@ -526,8 +526,8 @@ public int killEntities(LocalEntity... entities) {
}
@Override
- public boolean setBlock(Vector pt, BaseBlock block, boolean notifyAdjacent) {
- return setBlock(pt, (Block) block, notifyAdjacent);
+ public boolean setBlock(Vector pt, BaseBlock block) {
+ return setBlock(pt, block, true);
}
@Override
diff --git a/src/main/java/com/sk89q/worldedit/extent/BlockBagExtent.java b/src/main/java/com/sk89q/worldedit/extent/BlockBagExtent.java
index 734e6883c..3e6122957 100644
--- a/src/main/java/com/sk89q/worldedit/extent/BlockBagExtent.java
+++ b/src/main/java/com/sk89q/worldedit/extent/BlockBagExtent.java
@@ -87,7 +87,7 @@ public Map
null
+ * should not be returned.
+ *
+ * The returned block is mutable and is a snapshot of the block at the time
+ * of call. It has no position attached to it, so it could be reused in
+ * {@link Pattern}s and so on.
+ *
+ * Calls to this method can actually be quite expensive, so cache results
+ * whenever it is possible, while being aware of the mutability aspect.
+ * The cost, however, depends on the implementation and particular extent.
*
- * @param location location of the block
+ * @param position position of the block
* @return the block, or null if the block does not exist
*/
- BaseBlock getBlock(Vector location);
+ BaseBlock getBlock(Vector position);
/**
* Get the block ID at the given location.
*
- * @param location location of the block
+ * @param position position of the block
* @return the block ID
*/
- int getBlockType(Vector location);
+ int getBlockType(Vector position);
/**
* Get the data value of the block at the given location.
*
- * @param location the location of the block
+ * @param position position of the block
* @return the block data value
*/
- int getBlockData(Vector location);
+ int getBlockData(Vector position);
/**
* Change the block at the given location to the given block. The operation may
* not tie the given {@link BaseBlock} to the world, so future changes to the
* {@link BaseBlock} do not affect the world until this method is called again.
+ *
+ * The return value of this method indicates whether the change was probably
+ * successful. It may not be successful if, for example, the location is out
+ * of the bounds of the extent. It may be unsuccessful if the block passed
+ * is the same as the one in the world. However, the return value is only an
+ * estimation and it may be incorrect, but it could be used to count, for
+ * example, the approximate number of changes.
*
- * The return value of this method indicates whether the change "went through," as - * in the block was changed in the world in any way. If the new block is no different - * than the block already at the position in the world, 'false' would be returned. - * If the position is invalid (out of bounds, for example), then nothing should - * occur and 'false' should be returned. If possible, the return value should be - * accurate as possible, but implementations may choose to not provide an accurate - * value if it is not possible to know.
- * - * @param location location of the block + * @param position position of the block * @param block block to set - * @param notifyAdjacent true to notify adjacent blocks of changes * @return true if the block was successfully set (return value may not be accurate) */ - boolean setBlock(Vector location, BaseBlock block, boolean notifyAdjacent) throws WorldEditException; + boolean setBlock(Vector position, BaseBlock block) throws WorldEditException; /** * Return an {@link Operation} that should be called to tie up loose ends diff --git a/src/main/java/com/sk89q/worldedit/extent/ExtentDelegate.java b/src/main/java/com/sk89q/worldedit/extent/ExtentDelegate.java index 8a23b1209..17b5801bd 100644 --- a/src/main/java/com/sk89q/worldedit/extent/ExtentDelegate.java +++ b/src/main/java/com/sk89q/worldedit/extent/ExtentDelegate.java @@ -71,8 +71,8 @@ public int getBlockData(Vector location) { } @Override - public boolean setBlock(Vector location, BaseBlock block, boolean notifyAdjacent) throws WorldEditException { - return extent.setBlock(location, block, notifyAdjacent); + public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException { + return extent.setBlock(location, block); } protected Operation commitBefore() { diff --git a/src/main/java/com/sk89q/worldedit/extent/FastModeExtent.java b/src/main/java/com/sk89q/worldedit/extent/FastModeExtent.java index 1a2e7cada..750b26b3f 100644 --- a/src/main/java/com/sk89q/worldedit/extent/FastModeExtent.java +++ b/src/main/java/com/sk89q/worldedit/extent/FastModeExtent.java @@ -81,9 +81,9 @@ public void setEnabled(boolean enabled) { } @Override - public boolean setBlock(Vector location, BaseBlock block, boolean notifyAdjacent) throws WorldEditException { + public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException { dirtyChunks.add(new BlockVector2D(location.getBlockX() >> 4, location.getBlockZ() >> 4)); - return super.setBlock(location, block, notifyAdjacent || enabled); + return world.setBlock(location, block, !enabled); } @Override diff --git a/src/main/java/com/sk89q/worldedit/extent/ForgetfulExtentBuffer.java b/src/main/java/com/sk89q/worldedit/extent/ForgetfulExtentBuffer.java index fe1322c2e..ce8df1606 100644 --- a/src/main/java/com/sk89q/worldedit/extent/ForgetfulExtentBuffer.java +++ b/src/main/java/com/sk89q/worldedit/extent/ForgetfulExtentBuffer.java @@ -77,7 +77,7 @@ public ForgetfulExtentBuffer(Extent delegate, Mask mask) { } @Override - public boolean setBlock(Vector location, BaseBlock block, boolean notifyAdjacent) throws WorldEditException { + public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException { // Update minimum if (min == null) { min = location; @@ -97,7 +97,7 @@ public boolean setBlock(Vector location, BaseBlock block, boolean notifyAdjacent buffer.put(blockVector, block); return true; } else { - return getExtent().setBlock(location, block, notifyAdjacent); + return getExtent().setBlock(location, block); } } diff --git a/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java b/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java index 1571258f2..5eb4e1d08 100644 --- a/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java +++ b/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java @@ -62,9 +62,9 @@ public void setMask(Mask mask) { } @Override - public boolean setBlock(Vector location, BaseBlock block, boolean notifyAdjacent) throws WorldEditException { + public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException { if (mask.test(location)) { - return super.setBlock(location, block, notifyAdjacent); + return super.setBlock(location, block); } else { return false; } diff --git a/src/main/java/com/sk89q/worldedit/extent/reorder/SimpleBlockReorder.java b/src/main/java/com/sk89q/worldedit/extent/reorder/SimpleBlockReorder.java index e3d7fd266..18f9a919c 100644 --- a/src/main/java/com/sk89q/worldedit/extent/reorder/SimpleBlockReorder.java +++ b/src/main/java/com/sk89q/worldedit/extent/reorder/SimpleBlockReorder.java @@ -82,9 +82,9 @@ public void setEnabled(boolean enabled) { } @Override - public boolean setBlock(Vector location, BaseBlock block, boolean notifyAdjacent) throws WorldEditException { + public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException { if (!enabled) { - return super.setBlock(location, block, notifyAdjacent); + return super.setBlock(location, block); } if (BlockType.shouldPlaceLast(block.getType())) { @@ -97,8 +97,8 @@ public boolean setBlock(Vector location, BaseBlock block, boolean notifyAdjacent return !(getBlockType(location) == block.getType() && getBlockData(location) == block.getData()); } else if (BlockType.shouldPlaceLast(getBlockType(location))) { // Destroy torches, etc. first - super.setBlock(location, new BaseBlock(BlockID.AIR), notifyAdjacent); - return super.setBlock(location, block, notifyAdjacent); + super.setBlock(location, new BaseBlock(BlockID.AIR)); + return super.setBlock(location, block); } else { stage1.put(location.toBlockVector(), block); return !(getBlockType(location) == block.getType() && getBlockData(location) == block.getData()); @@ -191,7 +191,7 @@ public Operation resume() throws WorldEditException { } for (BlockVector pt : walked) { - extent.setBlock(pt, blockTypes.get(pt), true); + extent.setBlock(pt, blockTypes.get(pt)); blocks.remove(pt); } } diff --git a/src/main/java/com/sk89q/worldedit/function/block/BlockReplace.java b/src/main/java/com/sk89q/worldedit/function/block/BlockReplace.java index c8a5dbedc..d05a7df7c 100644 --- a/src/main/java/com/sk89q/worldedit/function/block/BlockReplace.java +++ b/src/main/java/com/sk89q/worldedit/function/block/BlockReplace.java @@ -50,7 +50,7 @@ public BlockReplace(Extent extent, Pattern pattern) { @Override public boolean apply(Vector position) throws WorldEditException { - return extent.setBlock(position, pattern.apply(position), true); + return extent.setBlock(position, pattern.apply(position)); } } \ No newline at end of file diff --git a/src/main/java/com/sk89q/worldedit/function/block/ExtentBlockCopy.java b/src/main/java/com/sk89q/worldedit/function/block/ExtentBlockCopy.java index af28924a9..4632b387c 100644 --- a/src/main/java/com/sk89q/worldedit/function/block/ExtentBlockCopy.java +++ b/src/main/java/com/sk89q/worldedit/function/block/ExtentBlockCopy.java @@ -64,7 +64,7 @@ public ExtentBlockCopy(Extent source, Vector from, Extent destination, Vector to @Override public boolean apply(Vector position) throws WorldEditException { BaseBlock block = source.getBlock(position); - return destination.setBlock(transform.apply(position.subtract(from)).add(to), block, true); + return destination.setBlock(transform.apply(position.subtract(from)).add(to), block); } } diff --git a/src/main/java/com/sk89q/worldedit/function/visitor/BlockMapEntryVisitor.java b/src/main/java/com/sk89q/worldedit/function/visitor/BlockMapEntryVisitor.java index 08324b118..dee6106ae 100644 --- a/src/main/java/com/sk89q/worldedit/function/visitor/BlockMapEntryVisitor.java +++ b/src/main/java/com/sk89q/worldedit/function/visitor/BlockMapEntryVisitor.java @@ -46,7 +46,7 @@ public BlockMapEntryVisitor(Extent extent, Iterator