allow more complex patterns to work correctly

This commit is contained in:
SirYwell 2022-10-13 09:16:44 +02:00
parent b740d5854c
commit 42f0b70e85
2 changed files with 6 additions and 3 deletions

View File

@ -183,7 +183,11 @@ public class GenChunk extends ScopedQueueCoordinator {
@Override @Override
public boolean setBlock(int x, int y, int z, @NonNull Pattern pattern) { 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 @Override

View File

@ -29,7 +29,6 @@ import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.BlockPattern;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.pattern.RandomPattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; 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) { public static BaseBlock apply(@NonNull Pattern pattern, int x, int y, int z) {
Preconditions.checkNotNull(pattern, "Pattern may not be null"); 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 BlockState || pattern instanceof BlockType
|| pattern instanceof BaseBlock) { || pattern instanceof BaseBlock) {
return pattern.applyBlock(BlockVector3.ZERO); return pattern.applyBlock(BlockVector3.ZERO);