geforkt von Mirrors/FastAsyncWorldEdit
Removed mask support from BlockCount.
RegionMaskFilter handles it.
Dieser Commit ist enthalten in:
Ursprung
a6e979ec6c
Commit
9cd164ae98
@ -551,10 +551,11 @@ public class EditSession {
|
|||||||
*/
|
*/
|
||||||
public int countBlocks(Region region, Set<BaseBlock> searchBlocks) {
|
public int countBlocks(Region region, Set<BaseBlock> searchBlocks) {
|
||||||
FuzzyBlockMask mask = new FuzzyBlockMask(searchBlocks);
|
FuzzyBlockMask mask = new FuzzyBlockMask(searchBlocks);
|
||||||
BlockCount counter = new BlockCount(this, mask);
|
BlockCount count = new BlockCount();
|
||||||
RegionVisitor visitor = new RegionVisitor(region, counter);
|
RegionMaskFilter filter = new RegionMaskFilter(this, mask, count);
|
||||||
|
RegionVisitor visitor = new RegionVisitor(region, filter);
|
||||||
OperationHelper.completeBlindly(visitor); // We can't throw exceptions, nor do we expect any
|
OperationHelper.completeBlindly(visitor); // We can't throw exceptions, nor do we expect any
|
||||||
return counter.getCount();
|
return count.getCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,31 +19,16 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.operation;
|
package com.sk89q.worldedit.operation;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.masks.Mask;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Counts the number of blocks that match a given mask.
|
* Counts the number of blocks.
|
||||||
*/
|
*/
|
||||||
public class BlockCount implements RegionFunction {
|
public class BlockCount implements RegionFunction {
|
||||||
|
|
||||||
private final EditSession editSession;
|
|
||||||
private Mask mask;
|
|
||||||
private int count;
|
private int count;
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new block counter.
|
|
||||||
*
|
|
||||||
* @param editSession the edit session
|
|
||||||
* @param mask the mask
|
|
||||||
*/
|
|
||||||
public BlockCount(EditSession editSession, Mask mask) {
|
|
||||||
this.editSession = editSession;
|
|
||||||
this.mask = mask;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of blocks that have been counted.
|
* Returns the number of blocks that have been counted.
|
||||||
*
|
*
|
||||||
@ -55,9 +40,7 @@ import com.sk89q.worldedit.masks.Mask;
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Vector position) throws WorldEditException {
|
public boolean apply(Vector position) throws WorldEditException {
|
||||||
if (mask.matches(editSession, position)) {
|
|
||||||
count++;
|
count++;
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren