From 761d05ac198e132aa99760bc6ca3a2d6ed67fd42 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 14 Jan 2021 14:38:37 +0000 Subject: [PATCH] actually delegate in AbstractDelegateExtent fixes #843 --- .../extent/AbstractDelegateExtent.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) 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 5daf419b1..fe1de9336 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 @@ -19,6 +19,7 @@ package com.sk89q.worldedit.extent; +import com.boydti.fawe.beta.Filter; import com.boydti.fawe.beta.IBatchProcessor; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.HistoryExtent; @@ -30,8 +31,10 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extent.buffer.ForgetfulExtentBuffer; +import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.OperationQueue; +import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Location; @@ -44,6 +47,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.List; +import java.util.Set; import java.util.UUID; import javax.annotation.Nullable; @@ -275,6 +279,46 @@ public class AbstractDelegateExtent implements Extent { } } + @Override + public > int setBlocks(Region region, B block) { + checkNotNull(region); + checkNotNull(block); + boolean hasNbt = block instanceof BaseBlock && block.hasNbtData(); + + int changes = 0; + for (BlockVector3 pos : region) { + if (setBlock(pos, block)) { + changes++; + } + } + return changes; + } + + @Override + public int setBlocks(Region region, Pattern pattern) { + return getExtent().setBlocks(region, pattern); + } + + @Override + public > int replaceBlocks(Region region, Set filter, B replacement) { + return getExtent().replaceBlocks(region, filter, replacement); + } + + @Override + public int replaceBlocks(Region region, Set filter, Pattern pattern) { + return getExtent().replaceBlocks(region, filter, pattern); + } + + @Override + public int replaceBlocks(Region region, Mask mask, Pattern pattern) { + return getExtent().replaceBlocks(region, mask, pattern); + } + + @Override + public int setBlocks(final Set vset, final Pattern pattern) { + return getExtent().setBlocks(vset, pattern); + } + @Override public int getMaxY() { return extent.getMaxY(); @@ -343,4 +387,14 @@ public class AbstractDelegateExtent implements Extent { protected Operation commitBefore() { return null; } + + @Override + public T apply(Region region, T filter, boolean full) { + return getExtent().apply(region, filter, full); + } + + @Override + public T apply(Iterable positions, T filter) { + return getExtent().apply(positions, filter); + } }