From 4d3d820f51f048a87996cfd5e9eaf6d901d53397 Mon Sep 17 00:00:00 2001
From: Maddy Miller
Date: Sun, 7 Jul 2024 15:03:10 +1000
Subject: [PATCH 1/2] Deprecate fullySupports3DBiomes and BiomeQuirkExtent
(#2496)
---
.../src/main/java/com/sk89q/worldedit/EditSession.java | 7 -------
.../sk89q/worldedit/extent/AbstractDelegateExtent.java | 5 -----
.../java/com/sk89q/worldedit/extent/NullExtent.java | 5 -----
.../java/com/sk89q/worldedit/extent/OutputExtent.java | 2 ++
.../sk89q/worldedit/extent/world/BiomeQuirkExtent.java | 10 ++++------
.../sk89q/worldedit/session/request/RequestExtent.java | 5 -----
.../main/java/com/sk89q/worldedit/world/NullWorld.java | 5 -----
7 files changed, 6 insertions(+), 33 deletions(-)
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java
index f39025cef4..64b52f6d8b 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java
@@ -39,7 +39,6 @@
import com.sk89q.worldedit.extent.reorder.MultiStageReorder;
import com.sk89q.worldedit.extent.validation.BlockChangeLimiter;
import com.sk89q.worldedit.extent.validation.DataValidatorExtent;
-import com.sk89q.worldedit.extent.world.BiomeQuirkExtent;
import com.sk89q.worldedit.extent.world.ChunkLoadingExtent;
import com.sk89q.worldedit.extent.world.SideEffectExtent;
import com.sk89q.worldedit.extent.world.SurvivalModeExtent;
@@ -261,7 +260,6 @@ public String getDisplayName() {
watchdogExtents.add(watchdogExtent);
}
extent = traceIfNeeded(survivalExtent = new SurvivalModeExtent(extent, world));
- extent = traceIfNeeded(new BiomeQuirkExtent(extent));
extent = traceIfNeeded(new ChunkLoadingExtent(extent, world));
extent = traceIfNeeded(new LastAccessExtentCache(extent));
extent = traceIfNeeded(blockBagExtent = new BlockBagExtent(extent, blockBag));
@@ -682,11 +680,6 @@ public int getBlockChangeCount() {
return changeSet.size();
}
- @Override
- public boolean fullySupports3DBiomes() {
- return bypassNone.fullySupports3DBiomes();
- }
-
@Override
public BiomeType getBiome(BlockVector3 position) {
return bypassNone.getBiome(position);
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java
index beb1a2e834..d0fd789d69 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java
@@ -94,11 +94,6 @@ public List extends Entity> getEntities(Region region) {
return extent.getEntities(region);
}
- @Override
- public boolean fullySupports3DBiomes() {
- return extent.fullySupports3DBiomes();
- }
-
@Override
public BiomeType getBiome(BlockVector3 position) {
return extent.getBiome(position);
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java
index 34b7760194..9cab1a567f 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java
@@ -89,11 +89,6 @@ public > boolean setBlock(BlockVector3 position, B
return false;
}
- @Override
- public boolean fullySupports3DBiomes() {
- return false;
- }
-
@Override
public boolean setBiome(BlockVector3 position, BiomeType biome) {
return false;
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/OutputExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/OutputExtent.java
index dc1febda9f..3027f28ad3 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/OutputExtent.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/OutputExtent.java
@@ -65,7 +65,9 @@ public interface OutputExtent {
*
*
* @return if the extent fully supports 3D biomes
+ * @deprecated All supported platforms now support this, the check is no longer necessary
*/
+ @Deprecated
default boolean fullySupports3DBiomes() {
return true;
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/BiomeQuirkExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/BiomeQuirkExtent.java
index 1abdccfa73..73efe1301f 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/BiomeQuirkExtent.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/BiomeQuirkExtent.java
@@ -26,7 +26,10 @@
/**
* Handles quirks when placing biomes.
+ *
+ * @deprecated This extent currently performs no functions.
*/
+@Deprecated
public class BiomeQuirkExtent extends AbstractDelegateExtent {
/**
@@ -40,11 +43,6 @@ public BiomeQuirkExtent(Extent extent) {
@Override
public boolean setBiome(BlockVector3 position, BiomeType biome) {
- boolean success = false;
- if (!fullySupports3DBiomes()) {
- // Also place at Y = 0 for proper handling
- success = super.setBiome(position.withY(0), biome);
- }
- return super.setBiome(position, biome) || success;
+ return super.setBiome(position, biome);
}
}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestExtent.java
index 5d835e3316..9aec3db506 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestExtent.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/session/request/RequestExtent.java
@@ -94,11 +94,6 @@ public > boolean setBlock(BlockVector3 position, T
return getExtent().setBlock(position, block);
}
- @Override
- public boolean fullySupports3DBiomes() {
- return getExtent().fullySupports3DBiomes();
- }
-
@Override
public boolean setBiome(BlockVector3 position, BiomeType biome) {
return getExtent().setBiome(position, biome);
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java
index b6b6c8cbcb..d235dedf25 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java
@@ -90,11 +90,6 @@ public boolean clearContainerBlockContents(BlockVector3 position) {
return false;
}
- @Override
- public boolean fullySupports3DBiomes() {
- return false;
- }
-
@Override
public BiomeType getBiome(BlockVector3 position) {
return BiomeTypes.THE_VOID;
From 856d1202182021582fa4f31795d0c4e2263defa7 Mon Sep 17 00:00:00 2001
From: Maddy Miller
Date: Sun, 7 Jul 2024 15:17:50 +1000
Subject: [PATCH 2/2] Add a #clipboard mask, to mask to blocks that match the
clipboard (#2502)
* Add a #match mask, to mask to blocks that match the clipboard
* Rename the parser mask to #clipboard
* Fix import order
* Add documentation to the MatchMask class
* PR review feedback
* add #copy as an alias
* use native Java List.of
---
.../extension/factory/MaskFactory.java | 2 +
.../parser/mask/ClipboardMaskParser.java | 54 +++++++++++++++
.../worldedit/function/mask/MatchMask.java | 65 +++++++++++++++++++
3 files changed, 121 insertions(+)
create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ClipboardMaskParser.java
create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MatchMask.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 211d876d79..a63b194659 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
@@ -25,6 +25,7 @@
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;
@@ -65,6 +66,7 @@ public final class MaskFactory extends AbstractFactory {
public MaskFactory(WorldEdit worldEdit) {
super(worldEdit, new BlocksMaskParser(worldEdit));
+ register(new ClipboardMaskParser(worldEdit));
register(new ExistingMaskParser(worldEdit));
register(new AirMaskParser(worldEdit));
register(new ExposedMaskParser(worldEdit));
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ClipboardMaskParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ClipboardMaskParser.java
new file mode 100644
index 0000000000..3b1aa216ae
--- /dev/null
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/ClipboardMaskParser.java
@@ -0,0 +1,54 @@
+/*
+ * 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.sk89q.worldedit.EmptyClipboardException;
+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.Mask;
+import com.sk89q.worldedit.function.mask.MatchMask;
+import com.sk89q.worldedit.internal.registry.SimpleInputParser;
+import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
+
+import java.util.List;
+
+public class ClipboardMaskParser extends SimpleInputParser {
+
+ private static final List aliases = List.of("#clipboard", "#copy");
+
+ public ClipboardMaskParser(WorldEdit worldEdit) {
+ super(worldEdit);
+ }
+
+ @Override
+ public List getMatchedAliases() {
+ return aliases;
+ }
+
+ @Override
+ public Mask parseFromSimpleInput(String input, ParserContext context) throws InputParseException {
+ try {
+ return new MatchMask(context.requireExtent(), context.requireSession().getClipboard().getClipboard());
+ } catch (EmptyClipboardException e) {
+ throw new InputParseException(TranslatableComponent.of("worldedit.error.empty-clipboard"));
+ }
+ }
+}
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MatchMask.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MatchMask.java
new file mode 100644
index 0000000000..38872fee69
--- /dev/null
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MatchMask.java
@@ -0,0 +1,65 @@
+/*
+ * 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;
+
+/**
+ * A mask that returns true if the two given extents have the same block at the given position, with offset support.
+ */
+public final class MatchMask extends AbstractMask {
+
+ private final Extent extent;
+ private final Extent matchExtent;
+ private final BlockVector3 offset;
+
+ /**
+ * Create a new match mask.
+ *
+ *
+ * This will assume an offset of zero. To specify an offset, use {@link #MatchMask(Extent, Extent, BlockVector3)}.
+ *
+ *
+ * @param extent The base extent
+ * @param matchExtent The match extent
+ */
+ public MatchMask(Extent extent, Extent matchExtent) {
+ this(extent, matchExtent, BlockVector3.ZERO);
+ }
+
+ /**
+ * Create a new match mask.
+ *
+ * @param extent The base extent
+ * @param matchExtent The match extent
+ * @param offset The offset of comparisons applied to the match extent
+ */
+ public MatchMask(Extent extent, Extent matchExtent, BlockVector3 offset) {
+ this.extent = extent;
+ this.matchExtent = matchExtent;
+ this.offset = offset;
+ }
+
+ @Override
+ public boolean test(BlockVector3 vector) {
+ return extent.getBlock(vector).equals(matchExtent.getBlock(vector.add(offset)));
+ }
+}