From 627e029fbb7eca1614cbabe47c0bc4cbef81951f Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Tue, 29 Oct 2013 08:04:52 +0100 Subject: [PATCH] Added a SolidBlockMask (#solid). --- src/main/java/com/sk89q/worldedit/WorldEdit.java | 3 +++ .../com/sk89q/worldedit/masks/SolidBlockMask.java | 15 +++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 src/main/java/com/sk89q/worldedit/masks/SolidBlockMask.java diff --git a/src/main/java/com/sk89q/worldedit/WorldEdit.java b/src/main/java/com/sk89q/worldedit/WorldEdit.java index afda8b67a..ea89a7845 100644 --- a/src/main/java/com/sk89q/worldedit/WorldEdit.java +++ b/src/main/java/com/sk89q/worldedit/WorldEdit.java @@ -84,6 +84,7 @@ import com.sk89q.worldedit.masks.InvertedMask; 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 @@ public class WorldEdit { 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")) { diff --git a/src/main/java/com/sk89q/worldedit/masks/SolidBlockMask.java b/src/main/java/com/sk89q/worldedit/masks/SolidBlockMask.java new file mode 100644 index 000000000..f78170efc --- /dev/null +++ b/src/main/java/com/sk89q/worldedit/masks/SolidBlockMask.java @@ -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)); + } +}