Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-26 11:00:04 +01:00
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) {
|
||||
FuzzyBlockMask mask = new FuzzyBlockMask(searchBlocks);
|
||||
BlockCount counter = new BlockCount(this, mask);
|
||||
RegionVisitor visitor = new RegionVisitor(region, counter);
|
||||
BlockCount count = new BlockCount();
|
||||
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
|
||||
return counter.getCount();
|
||||
return count.getCount();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,30 +19,15 @@
|
||||
|
||||
package com.sk89q.worldedit.operation;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
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 {
|
||||
|
||||
private final EditSession editSession;
|
||||
private Mask mask;
|
||||
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.
|
||||
@ -55,9 +40,7 @@ import com.sk89q.worldedit.masks.Mask;
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
if (mask.matches(editSession, position)) {
|
||||
count++;
|
||||
}
|
||||
count++;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren