Make more complex patterns work correctly (#3847)

allow more complex patterns to work correctly
This commit is contained in:
Hannes Greule 2022-10-13 19:16:19 +02:00 committed by GitHub
parent 11dd013333
commit e244527538
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -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

View File

@ -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);