From 3911e32b780ffcdd64f7790cb4b02bb06a59643d Mon Sep 17 00:00:00 2001 From: Zeranny Date: Sun, 17 Mar 2024 22:13:12 +0000 Subject: [PATCH] Add fork method --- .../core/function/pattern/LinearBlockPattern.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/LinearBlockPattern.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/LinearBlockPattern.java index 77504e45a0..0b6ef1be9a 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/LinearBlockPattern.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/pattern/LinearBlockPattern.java @@ -1,5 +1,6 @@ package com.fastasyncworldedit.core.function.pattern; +import com.fastasyncworldedit.core.queue.Filter; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.function.pattern.AbstractPattern; @@ -7,6 +8,8 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; +import java.util.Arrays; + public class LinearBlockPattern extends AbstractPattern implements ResettablePattern { private final Pattern[] patternsArray; @@ -33,6 +36,12 @@ public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws W return patternsArray[index].apply(extent, get, set); } + @Override + public Filter fork() { + final Pattern[] forked = Arrays.stream(this.patternsArray).map(Pattern::fork).toArray(Pattern[]::new); + return new LinearBlockPattern(forked); + } + @Override public void reset() { index = 0;