mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
New masks
This commit is contained in:
@ -5,7 +5,6 @@ import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -32,6 +32,7 @@ import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import javax.annotation.Nullable;
|
||||
@ -71,7 +72,7 @@ public class BlockMask extends ABlockMask {
|
||||
public BlockMask(Extent extent, Collection<BaseBlock> blocks) {
|
||||
this(extent);
|
||||
checkNotNull(blocks);
|
||||
add(blocks);
|
||||
this.add(blocks);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -166,6 +167,14 @@ public class BlockMask extends ABlockMask {
|
||||
add(Arrays.asList(checkNotNull(block)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of blocks that are tested with.
|
||||
*
|
||||
* @return a list of blocks
|
||||
*/
|
||||
public Collection<BaseBlock> getBlocks() {
|
||||
return Collections.emptyList(); //TODO Not supported in FAWE yet
|
||||
}
|
||||
@Override
|
||||
public boolean test(BlockState state) {
|
||||
return ordinals[state.getOrdinal()];
|
||||
|
@ -33,39 +33,22 @@ import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||
|
||||
/**
|
||||
* Utility class to apply region functions to {@link com.sk89q.worldedit.regions.Region}.
|
||||
* @deprecated let the queue iterate, not the region function which lacks any kind of optimizations / parallelism
|
||||
* @deprecated Let the queue iterate, not the region function which lacks any kind of optimizations / parallelism
|
||||
*/
|
||||
@Deprecated
|
||||
public class RegionVisitor implements Operation {
|
||||
|
||||
public final Region region;
|
||||
public final RegionFunction function;
|
||||
public int affected = 0;
|
||||
public final Iterable<? extends BlockVector3> iterable;
|
||||
|
||||
private final Region region;
|
||||
private final RegionFunction function;
|
||||
private int affected = 0;
|
||||
|
||||
/**
|
||||
* Deprecated in favor of the other constructors which will preload chunks during iteration
|
||||
*
|
||||
* @param region
|
||||
* @param function
|
||||
* @deprecated Use other constructors which will preload chunks during iteration
|
||||
*/
|
||||
@Deprecated
|
||||
public RegionVisitor(Region region, RegionFunction function) {
|
||||
this((Iterable<BlockVector3>) region, function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated in favor of the other constructors which will preload chunks during iteration
|
||||
*
|
||||
* @param iterable
|
||||
* @param function
|
||||
*/
|
||||
@Deprecated
|
||||
public RegionVisitor(Iterable<BlockVector3> iterable, RegionFunction function) {
|
||||
this.region = iterable instanceof Region ? (Region) iterable : null;
|
||||
this.region = region;
|
||||
this.function = function;
|
||||
this.iterable = iterable;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,7 +62,7 @@ public class RegionVisitor implements Operation {
|
||||
|
||||
@Override
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
for (BlockVector3 pt : iterable) {
|
||||
for (BlockVector3 pt : region) {
|
||||
if (function.apply(pt)) {
|
||||
affected++;
|
||||
}
|
||||
@ -97,7 +80,7 @@ public class RegionVisitor implements Operation {
|
||||
return ImmutableList.of(TranslatableComponent.of(
|
||||
"worldedit.operation.affected.block",
|
||||
TextComponent.of(getAffected())
|
||||
).color(TextColor.GRAY));
|
||||
).color(TextColor.LIGHT_PURPLE));
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user