mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-02 10:57:11 +00:00
Add BlockMask which is able to filter by data
This commit is contained in:
parent
21d603ce4e
commit
c759b9062c
@ -642,7 +642,7 @@ public class WorldEdit {
|
||||
}
|
||||
|
||||
default:
|
||||
return new BlockTypeMask(getBlockIDs(player, component, true));
|
||||
return new BlockMask(getBlocks(player, component, true, true));
|
||||
}
|
||||
}
|
||||
|
||||
|
46
src/main/java/com/sk89q/worldedit/masks/BlockMask.java
Normal file
46
src/main/java/com/sk89q/worldedit/masks/BlockMask.java
Normal file
@ -0,0 +1,46 @@
|
||||
package com.sk89q.worldedit.masks;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
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 {
|
||||
|
||||
protected Set<BaseBlock> blocks;
|
||||
|
||||
public BlockMask() {
|
||||
blocks = new HashSet<BaseBlock>();
|
||||
}
|
||||
|
||||
public BlockMask(Set<BaseBlock> types) {
|
||||
this.blocks = types;
|
||||
}
|
||||
|
||||
public BlockMask(BaseBlock block) {
|
||||
this();
|
||||
add(block);
|
||||
}
|
||||
|
||||
public void add(BaseBlock block) {
|
||||
blocks.add(block);
|
||||
}
|
||||
|
||||
public void addAll(Collection<BaseBlock> blocks) {
|
||||
blocks.addAll(blocks);
|
||||
}
|
||||
|
||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||
}
|
||||
|
||||
public boolean matches(EditSession editSession, Vector pos) {
|
||||
BaseBlock block = editSession.getBlock(pos);
|
||||
return blocks.contains(block)
|
||||
|| blocks.contains(new BaseBlock(block.getType(), -1));
|
||||
}
|
||||
}
|
@ -19,27 +19,27 @@
|
||||
|
||||
package com.sk89q.worldedit.masks;
|
||||
|
||||
import java.util.HashSet;
|
||||
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;
|
||||
|
||||
/**
|
||||
* A filter that matches blocks based on block types.
|
||||
*
|
||||
* @deprecated replaced by {@link #BlockMask}
|
||||
* @author sk89q
|
||||
*/
|
||||
public class BlockTypeMask implements Mask {
|
||||
protected Set<Integer> types;
|
||||
@Deprecated
|
||||
public class BlockTypeMask extends BlockMask {
|
||||
|
||||
public BlockTypeMask() {
|
||||
types = new HashSet<Integer>();
|
||||
super();
|
||||
}
|
||||
|
||||
public BlockTypeMask(Set<Integer> types) {
|
||||
this.types = types;
|
||||
super();
|
||||
for (int type : types) {
|
||||
add(type);
|
||||
}
|
||||
}
|
||||
|
||||
public BlockTypeMask(int type) {
|
||||
@ -48,14 +48,6 @@ public class BlockTypeMask implements Mask {
|
||||
}
|
||||
|
||||
public void add(int type) {
|
||||
types.add(type);
|
||||
add(new BaseBlock(type));
|
||||
}
|
||||
|
||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||
}
|
||||
|
||||
public boolean matches(EditSession editSession, Vector pos) {
|
||||
return types.contains(editSession.getBlockType(pos));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class InvertedBlockTypeMask extends BlockTypeMask {
|
||||
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector pos) {
|
||||
return !types.contains(editSession.getBlockType(pos));
|
||||
return !super.matches(editSession, pos);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user