mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2024-12-21 04:49:51 +08:00
commit
69bcaa7133
@ -84,6 +84,7 @@
|
||||
import com.sk89q.worldedit.masks.Mask;
|
||||
import com.sk89q.worldedit.masks.RandomMask;
|
||||
import com.sk89q.worldedit.masks.RegionMask;
|
||||
import com.sk89q.worldedit.masks.SolidBlockMask;
|
||||
import com.sk89q.worldedit.masks.UnderOverlayMask;
|
||||
import com.sk89q.worldedit.patterns.BlockChance;
|
||||
import com.sk89q.worldedit.patterns.ClipboardPattern;
|
||||
@ -731,6 +732,8 @@ private Mask getBlockMaskComponent(LocalPlayer player, LocalSession session, Lis
|
||||
case '#':
|
||||
if (component.equalsIgnoreCase("#existing")) {
|
||||
return new ExistingBlockMask();
|
||||
} else if (component.equalsIgnoreCase("#solid")) {
|
||||
return new SolidBlockMask();
|
||||
} else if (component.equalsIgnoreCase("#dregion")
|
||||
|| component.equalsIgnoreCase("#dselection")
|
||||
|| component.equalsIgnoreCase("#dsel")) {
|
||||
|
11
src/main/java/com/sk89q/worldedit/masks/AbstractMask.java
Normal file
11
src/main/java/com/sk89q/worldedit/masks/AbstractMask.java
Normal file
@ -0,0 +1,11 @@
|
||||
package com.sk89q.worldedit.masks;
|
||||
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
|
||||
public abstract class AbstractMask implements Mask {
|
||||
@Override
|
||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||
}
|
||||
}
|
@ -5,12 +5,10 @@
|
||||
|
||||
import com.sk89q.worldedit.BiomeType;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
|
||||
public class BiomeTypeMask implements Mask {
|
||||
public class BiomeTypeMask extends AbstractMask {
|
||||
private final Set<BiomeType> biomes;
|
||||
|
||||
public BiomeTypeMask() {
|
||||
@ -21,9 +19,6 @@ public BiomeTypeMask(Set<BiomeType> biomes) {
|
||||
this.biomes = biomes;
|
||||
}
|
||||
|
||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||
}
|
||||
|
||||
public boolean matches2D(EditSession editSession, Vector2D pos) {
|
||||
BiomeType biome = editSession.getWorld().getBiome(pos);
|
||||
return biomes.contains(biome);
|
||||
|
@ -5,12 +5,10 @@
|
||||
import java.util.Set;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
|
||||
public class BlockMask implements Mask {
|
||||
public class BlockMask extends AbstractMask {
|
||||
private final Set<BaseBlock> blocks;
|
||||
|
||||
public BlockMask() {
|
||||
@ -34,9 +32,6 @@ public void addAll(Collection<BaseBlock> blocks) {
|
||||
blocks.addAll(blocks);
|
||||
}
|
||||
|
||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector pos) {
|
||||
BaseBlock block = editSession.getBlock(pos);
|
||||
|
@ -26,7 +26,7 @@
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
|
||||
public class CombinedMask implements Mask {
|
||||
public class CombinedMask extends AbstractMask {
|
||||
private final List<Mask> masks = new ArrayList<Mask>();
|
||||
|
||||
public CombinedMask() {
|
||||
|
@ -20,15 +20,10 @@
|
||||
package com.sk89q.worldedit.masks;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
|
||||
public class ExistingBlockMask implements Mask {
|
||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||
}
|
||||
|
||||
public class ExistingBlockMask extends AbstractMask {
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector pos) {
|
||||
return editSession.getBlockType(pos) != BlockID.AIR;
|
||||
|
@ -5,7 +5,7 @@
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
|
||||
public class InvertedMask implements Mask {
|
||||
public class InvertedMask extends AbstractMask {
|
||||
private final Mask mask;
|
||||
|
||||
public InvertedMask(Mask mask) {
|
||||
|
@ -26,7 +26,9 @@
|
||||
|
||||
/**
|
||||
* Base matcher for the block filtering framework. Implementing classes
|
||||
* can be used to filter blocks to set or replace
|
||||
* can be used to filter blocks to set or replace.
|
||||
* <p>
|
||||
* <u>Do NOT</u> implement this interface. Extend {@link AbstractMask} instead.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
|
@ -1,21 +1,15 @@
|
||||
package com.sk89q.worldedit.masks;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
|
||||
public class RandomMask implements Mask {
|
||||
public class RandomMask extends AbstractMask {
|
||||
private final double ratio;
|
||||
|
||||
public RandomMask(double ratio) {
|
||||
this.ratio = ratio;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector pos) {
|
||||
return Math.random() < ratio;
|
||||
|
@ -20,21 +20,16 @@
|
||||
package com.sk89q.worldedit.masks;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
public class RegionMask implements Mask {
|
||||
public class RegionMask extends AbstractMask {
|
||||
private final Region region;
|
||||
|
||||
public RegionMask(Region region) {
|
||||
this.region = region.clone();
|
||||
}
|
||||
|
||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector pos) {
|
||||
return region.contains(pos);
|
||||
|
15
src/main/java/com/sk89q/worldedit/masks/SolidBlockMask.java
Normal file
15
src/main/java/com/sk89q/worldedit/masks/SolidBlockMask.java
Normal file
@ -0,0 +1,15 @@
|
||||
package com.sk89q.worldedit.masks;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BlockType;
|
||||
|
||||
/**
|
||||
* Works like {@link ExistingBlockMask}, except also dealing with non-solid non-air blocks the same way as with air.
|
||||
*/
|
||||
public class SolidBlockMask extends AbstractMask {
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector pos) {
|
||||
return !BlockType.canPassThrough(editSession.getBlockType(pos), editSession.getBlockData(pos));
|
||||
}
|
||||
}
|
@ -31,7 +31,7 @@
|
||||
*
|
||||
* @author 1337
|
||||
*/
|
||||
public class UnderOverlayMask implements Mask {
|
||||
public class UnderOverlayMask extends AbstractMask {
|
||||
private final int yMod;
|
||||
private Mask mask;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user