Skip to content

Commit f608c01

Browse files
authored
Add a Full Cube mask to mask to blocks that fill an entire cube (#2676)
* Add a Full Cube mask to mask to blocks that fill an entire cube * IntelliJ is bad * fixes from review
1 parent ea21e38 commit f608c01

3 files changed

Lines changed: 89 additions & 0 deletions

File tree

worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.sk89q.worldedit.extension.factory.parser.mask.ExistingMaskParser;
3030
import com.sk89q.worldedit.extension.factory.parser.mask.ExposedMaskParser;
3131
import com.sk89q.worldedit.extension.factory.parser.mask.ExpressionMaskParser;
32+
import com.sk89q.worldedit.extension.factory.parser.mask.FullCubeMaskParser;
3233
import com.sk89q.worldedit.extension.factory.parser.mask.LazyRegionMaskParser;
3334
import com.sk89q.worldedit.extension.factory.parser.mask.NegateMaskParser;
3435
import com.sk89q.worldedit.extension.factory.parser.mask.NoiseMaskParser;
@@ -71,6 +72,7 @@ public MaskFactory(WorldEdit worldEdit) {
7172
register(new AirMaskParser(worldEdit));
7273
register(new ExposedMaskParser(worldEdit));
7374
register(new SolidMaskParser(worldEdit));
75+
register(new FullCubeMaskParser(worldEdit));
7476
register(new LazyRegionMaskParser(worldEdit));
7577
register(new RegionMaskParser(worldEdit));
7678
register(new OffsetMaskParser(worldEdit));
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* WorldEdit, a Minecraft world manipulation toolkit
3+
* Copyright (C) sk89q <http://www.sk89q.com>
4+
* Copyright (C) WorldEdit team and contributors
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
20+
package com.sk89q.worldedit.extension.factory.parser.mask;
21+
22+
import com.sk89q.worldedit.WorldEdit;
23+
import com.sk89q.worldedit.extension.input.InputParseException;
24+
import com.sk89q.worldedit.extension.input.ParserContext;
25+
import com.sk89q.worldedit.function.mask.FullCubeMask;
26+
import com.sk89q.worldedit.function.mask.Mask;
27+
import com.sk89q.worldedit.internal.registry.SimpleInputParser;
28+
29+
import java.util.List;
30+
31+
public class FullCubeMaskParser extends SimpleInputParser<Mask> {
32+
33+
private static final List<String> aliases = List.of("#fullcube");
34+
35+
public FullCubeMaskParser(WorldEdit worldEdit) {
36+
super(worldEdit);
37+
}
38+
39+
@Override
40+
public List<String> getMatchedAliases() {
41+
return aliases;
42+
}
43+
44+
@Override
45+
public Mask parseFromSimpleInput(String input, ParserContext context) throws InputParseException {
46+
return new FullCubeMask(context.requireExtent());
47+
}
48+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* WorldEdit, a Minecraft world manipulation toolkit
3+
* Copyright (C) sk89q <http://www.sk89q.com>
4+
* Copyright (C) WorldEdit team and contributors
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
20+
package com.sk89q.worldedit.function.mask;
21+
22+
import com.sk89q.worldedit.extent.Extent;
23+
import com.sk89q.worldedit.math.BlockVector3;
24+
import com.sk89q.worldedit.world.block.BlockState;
25+
26+
public final class FullCubeMask extends AbstractExtentMask {
27+
28+
public FullCubeMask(Extent extent) {
29+
super(extent);
30+
}
31+
32+
@Override
33+
public boolean test(BlockVector3 vector) {
34+
Extent extent = getExtent();
35+
BlockState block = extent.getBlock(vector);
36+
return block.getBlockType().getMaterial().isFullCube();
37+
}
38+
39+
}

0 commit comments

Comments
 (0)