This commit aims to fix existing issues regarding the "0/-1 blocks affected" bug. Introducing the new LinkedFilter class allows us to use multiple filters for single-filter operations, e.g. applying a pattern to blocks while also counting the amount of blocks applied to. SetFilter.java was also removed due to not being used.
This commit is contained in:
IronApollo
2020-05-07 12:29:18 -04:00
parent afba834b83
commit 8b1a0bbc34
6 changed files with 93 additions and 39 deletions

View File

@ -20,6 +20,7 @@
package com.sk89q.worldedit.function.mask;
import com.boydti.fawe.beta.Filter;
import com.boydti.fawe.beta.implementation.filter.MaskFilter;
import com.boydti.fawe.beta.implementation.filter.block.FilterBlock;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.NullExtent;

View File

@ -1,38 +0,0 @@
package com.sk89q.worldedit.function.mask;
import com.boydti.fawe.beta.implementation.filter.block.DelegateFilter;
import com.boydti.fawe.beta.Filter;
import com.boydti.fawe.beta.implementation.filter.block.FilterBlock;
import java.util.function.Supplier;
public class MaskFilter<T extends Filter> extends DelegateFilter<T> {
private final Supplier<Mask> supplier;
private final Mask mask;
public MaskFilter(T other, Mask mask) {
this(other, () -> mask);
}
public MaskFilter(T other, Supplier<Mask> supplier) {
this(other, supplier, supplier.get());
}
public MaskFilter(T other, Supplier<Mask> supplier, Mask root) {
super(other);
this.supplier = supplier;
this.mask = root;
}
@Override
public void applyBlock(FilterBlock block) {
if (mask.test(block, block)) {
getParent().applyBlock(block);
}
}
@Override
public MaskFilter newInstance(Filter other) {
return new MaskFilter<>(other, supplier);
}
}