Skip to content

Commit

Permalink
Add fork method
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeranny committed Mar 17, 2024
1 parent be4c6ea commit 3911e32
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
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;
import com.sk89q.worldedit.function.pattern.Pattern;
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;
Expand All @@ -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;
Expand Down

0 comments on commit 3911e32

Please sign in to comment.