AbstractExtentMasks should have the correct extent.

- Fixes #843
This commit is contained in:
dordsor21 2021-01-14 16:54:38 +00:00
parent fa69c79160
commit b18c646bce
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
2 changed files with 13 additions and 6 deletions

View File

@ -36,6 +36,7 @@ import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.function.GroundFunction;
import com.sk89q.worldedit.function.generator.FloraGenerator;
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.MaskIntersection;
@ -300,6 +301,9 @@ public class RegionCommands {
if (from == null) {
from = new ExistingBlockMask(editSession);
}
if (from instanceof AbstractExtentMask) {
((AbstractExtentMask) from).setExtent(editSession);
}
int affected = editSession.replaceBlocks(region, from, to);
actor.printInfo(TranslatableComponent.of("worldedit.replace.replaced", TextComponent.of(affected)));
return affected;

View File

@ -34,9 +34,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
/**
* Tests true if the biome at applied points is the same as the one given.
*/
public class BiomeMask extends AbstractMask {
public class BiomeMask extends AbstractExtentMask {
private final Extent extent;
private final Set<BiomeType> biomes = new HashSet<>();
/**
@ -46,9 +45,8 @@ public class BiomeMask extends AbstractMask {
* @param biomes a list of biomes to match
*/
public BiomeMask(Extent extent, Collection<BiomeType> biomes) {
checkNotNull(extent);
super(extent);
checkNotNull(biomes);
this.extent = extent;
this.biomes.addAll(biomes);
}
@ -92,7 +90,7 @@ public class BiomeMask extends AbstractMask {
@Override
public boolean test(BlockVector3 vector) {
BiomeType biome = extent.getBiome(vector);
BiomeType biome = getExtent().getBiome(vector);
return biomes.contains(biome);
}
@ -104,7 +102,12 @@ public class BiomeMask extends AbstractMask {
@Override
public Mask copy() {
return new BiomeMask(extent, new HashSet<>(biomes));
return new BiomeMask(getExtent(), new HashSet<>(biomes));
}
@Override
public boolean test(Extent extent, BlockVector3 position) {
BiomeType biome = getExtent().getBiome(position);
return biomes.contains(biome);
}
}