geforkt von Mirrors/FastAsyncWorldEdit
Removed notifyAdjacent from Extent.setBlock().
Also fixed Extent's incorrect Javadocs.
Dieser Commit ist enthalten in:
Ursprung
e7fe787b20
Commit
fe25d08267
@ -367,24 +367,19 @@ public class EditSession implements Extent {
|
|||||||
* @param level the level
|
* @param level the level
|
||||||
* @return whether the block changed
|
* @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) {
|
switch (level) {
|
||||||
case NORMAL:
|
case NORMAL:
|
||||||
return bypassNone.setBlock(position, block, notifyAdjacent);
|
return bypassNone.setBlock(position, block);
|
||||||
case NO_HISTORY_REORDER:
|
case NO_HISTORY_REORDER:
|
||||||
return bypassHistory.setBlock(position, block, notifyAdjacent);
|
return bypassHistory.setBlock(position, block);
|
||||||
case NO_HISTORY:
|
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");
|
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.
|
* Set a block, bypassing both history and block re-ordering.
|
||||||
*
|
*
|
||||||
@ -396,7 +391,7 @@ public class EditSession implements Extent {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean rawSetBlock(Vector position, BaseBlock block) {
|
public boolean rawSetBlock(Vector position, BaseBlock block) {
|
||||||
try {
|
try {
|
||||||
return setBlock(position, block, true, Level.NO_HISTORY_REORDER);
|
return setBlock(position, block, Level.NO_HISTORY_REORDER);
|
||||||
} catch (WorldEditException e) {
|
} catch (WorldEditException e) {
|
||||||
throw new RuntimeException("Unexpected exception", e);
|
throw new RuntimeException("Unexpected exception", e);
|
||||||
}
|
}
|
||||||
@ -413,23 +408,16 @@ public class EditSession implements Extent {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean smartSetBlock(Vector position, BaseBlock block) {
|
public boolean smartSetBlock(Vector position, BaseBlock block) {
|
||||||
try {
|
try {
|
||||||
return setBlock(position, block, true, Level.NO_HISTORY);
|
return setBlock(position, block, Level.NO_HISTORY);
|
||||||
} catch (WorldEditException e) {
|
} catch (WorldEditException e) {
|
||||||
throw new RuntimeException("Unexpected exception", e);
|
throw new RuntimeException("Unexpected exception", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
public boolean setBlock(Vector position, BaseBlock block) throws MaxChangedBlocksException {
|
public boolean setBlock(Vector position, BaseBlock block) throws MaxChangedBlocksException {
|
||||||
try {
|
try {
|
||||||
return setBlock(position, block, true, Level.NORMAL);
|
return setBlock(position, block, Level.NORMAL);
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (WorldEditException e) {
|
} catch (WorldEditException e) {
|
||||||
|
@ -526,8 +526,8 @@ public abstract class LocalWorld implements World, Extent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector pt, BaseBlock block, boolean notifyAdjacent) {
|
public boolean setBlock(Vector pt, BaseBlock block) {
|
||||||
return setBlock(pt, (Block) block, notifyAdjacent);
|
return setBlock(pt, block, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -87,7 +87,7 @@ public class BlockBagExtent extends ExtentDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector location, BaseBlock block, boolean notifyAdjacent) throws WorldEditException {
|
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
|
||||||
if (blockBag != null) {
|
if (blockBag != null) {
|
||||||
final int type = block.getType();
|
final int type = block.getType();
|
||||||
final int existing = world.getBlockType(location);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,13 +75,13 @@ public class BlockChangeLimiter extends ExtentDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 (limit >= 0) {
|
||||||
if (count >= limit) {
|
if (count >= limit) {
|
||||||
throw new MaxChangedBlocksException(limit);
|
throw new MaxChangedBlocksException(limit);
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
return super.setBlock(location, block, notifyAdjacent);
|
return super.setBlock(location, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ public class BlockQuirkExtent extends ExtentDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
final int existing = world.getBlockType(location);
|
||||||
|
|
||||||
if (BlockType.isContainerBlock(existing)) {
|
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
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -47,10 +47,10 @@ public class ChangeSetExtent extends ExtentDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
BaseBlock previous = getBlock(location);
|
||||||
changeSet.add(new BlockChange(location.toBlockVector(), previous, block));
|
changeSet.add(new BlockChange(location.toBlockVector(), previous, block));
|
||||||
return super.setBlock(location, block, notifyAdjacent);
|
return super.setBlock(location, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -59,8 +59,8 @@ public class ChunkLoadingExtent extends ExtentDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector location, BaseBlock block, boolean notifyAdjacent) throws WorldEditException {
|
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
|
||||||
world.checkLoadedChunk(location);
|
world.checkLoadedChunk(location);
|
||||||
return super.setBlock(location, block, notifyAdjacent);
|
return super.setBlock(location, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class DataValidatorExtent extends ExtentDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 y = location.getBlockY();
|
||||||
final int type = block.getType();
|
final int type = block.getType();
|
||||||
if (y < 0 || y > world.getMaxY()) {
|
if (y < 0 || y > world.getMaxY()) {
|
||||||
@ -58,6 +58,6 @@ public class DataValidatorExtent extends ExtentDelegate {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.setBlock(location, block, notifyAdjacent);
|
return super.setBlock(location, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import com.sk89q.worldedit.Vector;
|
|||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
@ -33,51 +34,58 @@ import javax.annotation.Nullable;
|
|||||||
public interface Extent {
|
public interface Extent {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a copy of the block at the given location. May return null if the location
|
* Get a snapshot of the block at the given location.
|
||||||
* given is out of bounds. The returned block must not be tied to any real block
|
* </p>
|
||||||
* in the world, so changes to the returned {@link BaseBlock} have no effect until
|
* If the given position is out of the bounds of the extent, then the behavior
|
||||||
* {@link #setBlock(Vector, BaseBlock, boolean)} is called.
|
* 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
|
* @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.
|
* Get the block ID at the given location.
|
||||||
*
|
*
|
||||||
* @param location location of the block
|
* @param position position of the block
|
||||||
* @return the block ID
|
* @return the block ID
|
||||||
*/
|
*/
|
||||||
int getBlockType(Vector location);
|
int getBlockType(Vector position);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the data value of the block at the given location.
|
* 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
|
* @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
|
* 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
|
* 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.
|
* {@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
|
* @param position position of the block
|
||||||
* 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 block block to set
|
* @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)
|
* @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
|
* Return an {@link Operation} that should be called to tie up loose ends
|
||||||
|
@ -71,8 +71,8 @@ public class ExtentDelegate implements Extent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector location, BaseBlock block, boolean notifyAdjacent) throws WorldEditException {
|
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
|
||||||
return extent.setBlock(location, block, notifyAdjacent);
|
return extent.setBlock(location, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Operation commitBefore() {
|
protected Operation commitBefore() {
|
||||||
|
@ -81,9 +81,9 @@ public class FastModeExtent extends ExtentDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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));
|
dirtyChunks.add(new BlockVector2D(location.getBlockX() >> 4, location.getBlockZ() >> 4));
|
||||||
return super.setBlock(location, block, notifyAdjacent || enabled);
|
return world.setBlock(location, block, !enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -77,7 +77,7 @@ public class ForgetfulExtentBuffer extends ExtentDelegate implements Pattern {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector location, BaseBlock block, boolean notifyAdjacent) throws WorldEditException {
|
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
|
||||||
// Update minimum
|
// Update minimum
|
||||||
if (min == null) {
|
if (min == null) {
|
||||||
min = location;
|
min = location;
|
||||||
@ -97,7 +97,7 @@ public class ForgetfulExtentBuffer extends ExtentDelegate implements Pattern {
|
|||||||
buffer.put(blockVector, block);
|
buffer.put(blockVector, block);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return getExtent().setBlock(location, block, notifyAdjacent);
|
return getExtent().setBlock(location, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,9 +62,9 @@ public class MaskingExtent extends ExtentDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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)) {
|
if (mask.test(location)) {
|
||||||
return super.setBlock(location, block, notifyAdjacent);
|
return super.setBlock(location, block);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -82,9 +82,9 @@ public class SimpleBlockReorder extends ExtentDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector location, BaseBlock block, boolean notifyAdjacent) throws WorldEditException {
|
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
return super.setBlock(location, block, notifyAdjacent);
|
return super.setBlock(location, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BlockType.shouldPlaceLast(block.getType())) {
|
if (BlockType.shouldPlaceLast(block.getType())) {
|
||||||
@ -97,8 +97,8 @@ public class SimpleBlockReorder extends ExtentDelegate {
|
|||||||
return !(getBlockType(location) == block.getType() && getBlockData(location) == block.getData());
|
return !(getBlockType(location) == block.getType() && getBlockData(location) == block.getData());
|
||||||
} else if (BlockType.shouldPlaceLast(getBlockType(location))) {
|
} else if (BlockType.shouldPlaceLast(getBlockType(location))) {
|
||||||
// Destroy torches, etc. first
|
// Destroy torches, etc. first
|
||||||
super.setBlock(location, new BaseBlock(BlockID.AIR), notifyAdjacent);
|
super.setBlock(location, new BaseBlock(BlockID.AIR));
|
||||||
return super.setBlock(location, block, notifyAdjacent);
|
return super.setBlock(location, block);
|
||||||
} else {
|
} else {
|
||||||
stage1.put(location.toBlockVector(), block);
|
stage1.put(location.toBlockVector(), block);
|
||||||
return !(getBlockType(location) == block.getType() && getBlockData(location) == block.getData());
|
return !(getBlockType(location) == block.getType() && getBlockData(location) == block.getData());
|
||||||
@ -191,7 +191,7 @@ public class SimpleBlockReorder extends ExtentDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (BlockVector pt : walked) {
|
for (BlockVector pt : walked) {
|
||||||
extent.setBlock(pt, blockTypes.get(pt), true);
|
extent.setBlock(pt, blockTypes.get(pt));
|
||||||
blocks.remove(pt);
|
blocks.remove(pt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ public class BlockReplace implements RegionFunction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Vector position) throws WorldEditException {
|
public boolean apply(Vector position) throws WorldEditException {
|
||||||
return extent.setBlock(position, pattern.apply(position), true);
|
return extent.setBlock(position, pattern.apply(position));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -64,7 +64,7 @@ public class ExtentBlockCopy implements RegionFunction {
|
|||||||
@Override
|
@Override
|
||||||
public boolean apply(Vector position) throws WorldEditException {
|
public boolean apply(Vector position) throws WorldEditException {
|
||||||
BaseBlock block = source.getBlock(position);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class BlockMapEntryVisitor implements Operation {
|
|||||||
public Operation resume() throws WorldEditException {
|
public Operation resume() throws WorldEditException {
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Map.Entry<BlockVector, BaseBlock> entry = iterator.next();
|
Map.Entry<BlockVector, BaseBlock> entry = iterator.next();
|
||||||
extent.setBlock(entry.getKey(), entry.getValue(), true);
|
extent.setBlock(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -85,12 +85,12 @@ public class BlockChange implements Change {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void undo(UndoContext context) throws WorldEditException {
|
public void undo(UndoContext context) throws WorldEditException {
|
||||||
checkNotNull(context.getExtent()).setBlock(position, previous, true);
|
checkNotNull(context.getExtent()).setBlock(position, previous);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void redo(UndoContext context) throws WorldEditException {
|
public void redo(UndoContext context) throws WorldEditException {
|
||||||
checkNotNull(context.getExtent()).setBlock(position, current, true);
|
checkNotNull(context.getExtent()).setBlock(position, current);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren