3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-27 03:12:37 +01:00

Removed notifyAdjacent from Extent.setBlock().

Also fixed Extent's incorrect Javadocs.
Dieser Commit ist enthalten in:
sk89q 2014-03-31 17:20:54 -07:00
Ursprung e7fe787b20
Commit fe25d08267
18 geänderte Dateien mit 69 neuen und 73 gelöschten Zeilen

Datei anzeigen

@ -367,24 +367,19 @@ public class EditSession implements Extent {
* @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 class EditSession implements Extent {
@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 class EditSession implements Extent {
@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) {

Datei anzeigen

@ -526,8 +526,8 @@ public abstract class LocalWorld implements World, Extent {
}
@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

Datei anzeigen

@ -87,7 +87,7 @@ public class BlockBagExtent extends ExtentDelegate {
}
@Override
public boolean setBlock(Vector location, BaseBlock block, boolean notifyAdjacent) throws WorldEditException {
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
if (blockBag != null) {
final int type = block.getType();
final int existing = world.getBlockType(location);
@ -115,6 +115,6 @@ public class BlockBagExtent extends ExtentDelegate {
}
}
return super.setBlock(location, block, notifyAdjacent);
return super.setBlock(location, block);
}
}

Datei anzeigen

@ -75,13 +75,13 @@ public class BlockChangeLimiter extends ExtentDelegate {
}
@Override
public boolean setBlock(Vector location, BaseBlock block, boolean notifyAdjacent) throws WorldEditException {
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
if (limit >= 0) {
if (count >= limit) {
throw new MaxChangedBlocksException(limit);
}
count++;
}
return super.setBlock(location, block, notifyAdjacent);
return super.setBlock(location, block);
}
}

Datei anzeigen

@ -49,7 +49,7 @@ public class BlockQuirkExtent extends ExtentDelegate {
}
@Override
public boolean setBlock(Vector location, BaseBlock block, boolean notifyAdjacent) throws WorldEditException {
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
final int existing = world.getBlockType(location);
if (BlockType.isContainerBlock(existing)) {
@ -58,7 +58,7 @@ public class BlockQuirkExtent extends ExtentDelegate {
world.setBlockType(location, BlockID.AIR); // Ice turns until water so this has to be done first
}
return super.setBlock(location, block, notifyAdjacent);
return super.setBlock(location, block);
}
}

Datei anzeigen

@ -47,10 +47,10 @@ public class ChangeSetExtent extends ExtentDelegate {
}
@Override
public boolean setBlock(Vector location, BaseBlock block, boolean notifyAdjacent) throws WorldEditException {
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
BaseBlock previous = getBlock(location);
changeSet.add(new BlockChange(location.toBlockVector(), previous, block));
return super.setBlock(location, block, notifyAdjacent);
return super.setBlock(location, block);
}
}

Datei anzeigen

@ -59,8 +59,8 @@ public class ChunkLoadingExtent extends ExtentDelegate {
}
@Override
public boolean setBlock(Vector location, BaseBlock block, boolean notifyAdjacent) throws WorldEditException {
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
world.checkLoadedChunk(location);
return super.setBlock(location, block, notifyAdjacent);
return super.setBlock(location, block);
}
}

Datei anzeigen

@ -46,7 +46,7 @@ public class DataValidatorExtent extends ExtentDelegate {
}
@Override
public boolean setBlock(Vector location, BaseBlock block, boolean notifyAdjacent) throws WorldEditException {
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
final int y = location.getBlockY();
final int type = block.getType();
if (y < 0 || y > world.getMaxY()) {
@ -58,6 +58,6 @@ public class DataValidatorExtent extends ExtentDelegate {
return false;
}
return super.setBlock(location, block, notifyAdjacent);
return super.setBlock(location, block);
}
}

Datei anzeigen

@ -23,6 +23,7 @@ import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.pattern.Pattern;
import javax.annotation.Nullable;
@ -33,51 +34,58 @@ import javax.annotation.Nullable;
public interface Extent {
/**
* Get a copy of the block at the given location. May return null if the location
* given is out of bounds. The returned block must not be tied to any real block
* in the world, so changes to the returned {@link BaseBlock} have no effect until
* {@link #setBlock(Vector, BaseBlock, boolean)} is called.
* Get a snapshot of the block at the given location.
* </p>
* If the given position is out of the bounds of the extent, then the behavior
* is undefined (an air block could be returned). However, <code>null</code>
* should <strong>not</strong> be returned.
* </p>
* 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.
* </p>
* 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.
* </p>
* 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.
*
* <p>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.</p>
*
* @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

Datei anzeigen

@ -71,8 +71,8 @@ public class ExtentDelegate implements Extent {
}
@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() {

Datei anzeigen

@ -81,9 +81,9 @@ public class FastModeExtent extends ExtentDelegate {
}
@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

Datei anzeigen

@ -77,7 +77,7 @@ public class ForgetfulExtentBuffer extends ExtentDelegate implements Pattern {
}
@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 class ForgetfulExtentBuffer extends ExtentDelegate implements Pattern {
buffer.put(blockVector, block);
return true;
} else {
return getExtent().setBlock(location, block, notifyAdjacent);
return getExtent().setBlock(location, block);
}
}

Datei anzeigen

@ -62,9 +62,9 @@ public class MaskingExtent extends ExtentDelegate {
}
@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;
}

Datei anzeigen

@ -82,9 +82,9 @@ public class SimpleBlockReorder extends ExtentDelegate {
}
@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 class SimpleBlockReorder extends ExtentDelegate {
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 class SimpleBlockReorder extends ExtentDelegate {
}
for (BlockVector pt : walked) {
extent.setBlock(pt, blockTypes.get(pt), true);
extent.setBlock(pt, blockTypes.get(pt));
blocks.remove(pt);
}
}

Datei anzeigen

@ -50,7 +50,7 @@ public class BlockReplace implements RegionFunction {
@Override
public boolean apply(Vector position) throws WorldEditException {
return extent.setBlock(position, pattern.apply(position), true);
return extent.setBlock(position, pattern.apply(position));
}
}

Datei anzeigen

@ -64,7 +64,7 @@ public class ExtentBlockCopy implements RegionFunction {
@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);
}
}

Datei anzeigen

@ -46,7 +46,7 @@ public class BlockMapEntryVisitor implements Operation {
public Operation resume() throws WorldEditException {
while (iterator.hasNext()) {
Map.Entry<BlockVector, BaseBlock> entry = iterator.next();
extent.setBlock(entry.getKey(), entry.getValue(), true);
extent.setBlock(entry.getKey(), entry.getValue());
}
return null;

Datei anzeigen

@ -85,12 +85,12 @@ public class BlockChange implements Change {
@Override
public void undo(UndoContext context) throws WorldEditException {
checkNotNull(context.getExtent()).setBlock(position, previous, true);
checkNotNull(context.getExtent()).setBlock(position, previous);
}
@Override
public void redo(UndoContext context) throws WorldEditException {
checkNotNull(context.getExtent()).setBlock(position, current, true);
checkNotNull(context.getExtent()).setBlock(position, current);
}
}