From e244527538c1168af4247495dde63198f1cb835c Mon Sep 17 00:00:00 2001 From: Hannes Greule Date: Thu, 13 Oct 2022 19:16:19 +0200 Subject: [PATCH] Make more complex patterns work correctly (#3847) allow more complex patterns to work correctly --- .../main/java/com/plotsquared/bukkit/queue/GenChunk.java | 6 +++++- .../main/java/com/plotsquared/core/util/PatternUtil.java | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/GenChunk.java b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/GenChunk.java index 44ec39545..558a86f51 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/GenChunk.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/GenChunk.java @@ -183,7 +183,11 @@ public class GenChunk extends ScopedQueueCoordinator { @Override public boolean setBlock(int x, int y, int z, @NonNull Pattern pattern) { - return setBlock(x, y, z, PatternUtil.apply(Preconditions.checkNotNull(pattern, "Pattern may not be null"), x, y, z)); + final BaseBlock block = PatternUtil.apply(Preconditions.checkNotNull( + pattern, + "Pattern may not be null" + ), x + (chunkX << 4), y, z + (chunkZ << 4)); + return setBlock(x, y, z, block); } @Override diff --git a/Core/src/main/java/com/plotsquared/core/util/PatternUtil.java b/Core/src/main/java/com/plotsquared/core/util/PatternUtil.java index 26100f811..e90ac3595 100644 --- a/Core/src/main/java/com/plotsquared/core/util/PatternUtil.java +++ b/Core/src/main/java/com/plotsquared/core/util/PatternUtil.java @@ -29,7 +29,6 @@ import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.Pattern; -import com.sk89q.worldedit.function.pattern.RandomPattern; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; @@ -44,7 +43,7 @@ public class PatternUtil { public static BaseBlock apply(@NonNull Pattern pattern, int x, int y, int z) { Preconditions.checkNotNull(pattern, "Pattern may not be null"); - if (pattern instanceof BlockPattern || pattern instanceof RandomPattern + if (pattern instanceof BlockPattern || pattern instanceof BlockState || pattern instanceof BlockType || pattern instanceof BaseBlock) { return pattern.applyBlock(BlockVector3.ZERO);