From 363a86ea526f9b560cf2803dcc5142ac98508b5f Mon Sep 17 00:00:00 2001 From: Maddy Miller Date: Sat, 14 Dec 2024 20:28:45 +1000 Subject: [PATCH 1/3] Add a Full Cube mask to mask to blocks that fill an entire cube --- .../extension/factory/MaskFactory.java | 17 +------ .../parser/mask/FullCubeMaskParser.java | 49 +++++++++++++++++++ .../worldedit/function/mask/FullCubeMask.java | 39 +++++++++++++++ 3 files changed, 90 insertions(+), 15 deletions(-) create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/FullCubeMaskParser.java create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/FullCubeMask.java diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java index a63b194659..d02aacfdc3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java @@ -20,21 +20,7 @@ package com.sk89q.worldedit.extension.factory; import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.extension.factory.parser.mask.AirMaskParser; -import com.sk89q.worldedit.extension.factory.parser.mask.BiomeMaskParser; -import com.sk89q.worldedit.extension.factory.parser.mask.BlockCategoryMaskParser; -import com.sk89q.worldedit.extension.factory.parser.mask.BlockStateMaskParser; -import com.sk89q.worldedit.extension.factory.parser.mask.BlocksMaskParser; -import com.sk89q.worldedit.extension.factory.parser.mask.ClipboardMaskParser; -import com.sk89q.worldedit.extension.factory.parser.mask.ExistingMaskParser; -import com.sk89q.worldedit.extension.factory.parser.mask.ExposedMaskParser; -import com.sk89q.worldedit.extension.factory.parser.mask.ExpressionMaskParser; -import com.sk89q.worldedit.extension.factory.parser.mask.LazyRegionMaskParser; -import com.sk89q.worldedit.extension.factory.parser.mask.NegateMaskParser; -import com.sk89q.worldedit.extension.factory.parser.mask.NoiseMaskParser; -import com.sk89q.worldedit.extension.factory.parser.mask.OffsetMaskParser; -import com.sk89q.worldedit.extension.factory.parser.mask.RegionMaskParser; -import com.sk89q.worldedit.extension.factory.parser.mask.SolidMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.*; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.NoMatchException; import com.sk89q.worldedit.extension.input.ParserContext; @@ -71,6 +57,7 @@ public MaskFactory(WorldEdit worldEdit) { register(new AirMaskParser(worldEdit)); register(new ExposedMaskParser(worldEdit)); register(new SolidMaskParser(worldEdit)); + register(new FullCubeMaskParser(worldEdit)); register(new LazyRegionMaskParser(worldEdit)); register(new RegionMaskParser(worldEdit)); register(new OffsetMaskParser(worldEdit)); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/FullCubeMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/FullCubeMaskParser.java new file mode 100644 index 0000000000..90effacbe3 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/FullCubeMaskParser.java @@ -0,0 +1,49 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.extension.factory.parser.mask; + +import com.google.common.collect.ImmutableList; +import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.extension.input.InputParseException; +import com.sk89q.worldedit.extension.input.ParserContext; +import com.sk89q.worldedit.function.mask.FullCubeMask; +import com.sk89q.worldedit.function.mask.Mask; +import com.sk89q.worldedit.internal.registry.SimpleInputParser; + +import java.util.List; + +public class FullCubeMaskParser extends SimpleInputParser { + + private final List aliases = ImmutableList.of("#fullcube"); + + public FullCubeMaskParser(WorldEdit worldEdit) { + super(worldEdit); + } + + @Override + public List getMatchedAliases() { + return aliases; + } + + @Override + public Mask parseFromSimpleInput(String input, ParserContext context) throws InputParseException { + return new FullCubeMask(context.requireExtent()); + } +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/FullCubeMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/FullCubeMask.java new file mode 100644 index 0000000000..6eafa8b712 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/FullCubeMask.java @@ -0,0 +1,39 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.function.mask; + +import com.sk89q.worldedit.extent.Extent; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.world.block.BlockState; + +public class FullCubeMask extends AbstractExtentMask { + + public FullCubeMask(Extent extent) { + super(extent); + } + + @Override + public boolean test(BlockVector3 vector) { + Extent extent = getExtent(); + BlockState block = extent.getBlock(vector); + return block.getBlockType().getMaterial().isFullCube(); + } + +} From 7dfe07a42e5df234f7bd28734e8710603caabde5 Mon Sep 17 00:00:00 2001 From: Maddy Miller Date: Sat, 14 Dec 2024 20:44:41 +1000 Subject: [PATCH 2/3] IntelliJ is bad --- .../extension/factory/MaskFactory.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java index d02aacfdc3..b5f91ff2aa 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java @@ -20,7 +20,22 @@ package com.sk89q.worldedit.extension.factory; import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.extension.factory.parser.mask.*; +import com.sk89q.worldedit.extension.factory.parser.mask.AirMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.BiomeMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.BlockCategoryMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.BlockStateMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.BlocksMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.ClipboardMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.ExistingMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.ExposedMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.ExpressionMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.FullCubeMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.LazyRegionMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.NegateMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.NoiseMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.OffsetMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.RegionMaskParser; +import com.sk89q.worldedit.extension.factory.parser.mask.SolidMaskParser; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.NoMatchException; import com.sk89q.worldedit.extension.input.ParserContext; From cb5521b092ad29b71b554041aa697877284cd5fc Mon Sep 17 00:00:00 2001 From: Maddy Miller Date: Fri, 3 Jan 2025 14:25:17 +1000 Subject: [PATCH 3/3] fixes from review --- .../extension/factory/parser/mask/FullCubeMaskParser.java | 3 +-- .../java/com/sk89q/worldedit/function/mask/FullCubeMask.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/FullCubeMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/FullCubeMaskParser.java index 90effacbe3..410ff005c6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/FullCubeMaskParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/FullCubeMaskParser.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.extension.factory.parser.mask; -import com.google.common.collect.ImmutableList; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; @@ -31,7 +30,7 @@ public class FullCubeMaskParser extends SimpleInputParser { - private final List aliases = ImmutableList.of("#fullcube"); + private static final List aliases = List.of("#fullcube"); public FullCubeMaskParser(WorldEdit worldEdit) { super(worldEdit); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/FullCubeMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/FullCubeMask.java index 6eafa8b712..d7a8a8165b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/FullCubeMask.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/FullCubeMask.java @@ -23,7 +23,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BlockState; -public class FullCubeMask extends AbstractExtentMask { +public final class FullCubeMask extends AbstractExtentMask { public FullCubeMask(Extent extent) { super(extent);