From a80420d14b3b3c29c71c0c72984bb445b61595e1 Mon Sep 17 00:00:00 2001 From: wizjany Date: Sat, 30 Mar 2019 00:42:28 -0400 Subject: [PATCH] Add biome storage to BlockArrayClipboard. --- .../extent/clipboard/BlockArrayClipboard.java | 15 +++++++++++++++ .../clipboard/io/SpongeSchematicReader.java | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java index d4ecc26b3..9d13ea579 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java @@ -51,6 +51,7 @@ public class BlockArrayClipboard implements Clipboard { private final Region region; private BlockVector3 origin; private final BaseBlock[][][] blocks; + private BiomeType[][] biomes = null; private final List entities = new ArrayList<>(); /** @@ -162,11 +163,25 @@ public class BlockArrayClipboard implements Clipboard { @Override public BiomeType getBiome(BlockVector2 position) { + if (biomes != null + && position.containedWithin(getMinimumPoint().toBlockVector2(), getMaximumPoint().toBlockVector2())) { + BlockVector2 v = position.subtract(region.getMinimumPoint().toBlockVector2()); + return biomes[v.getBlockX()][v.getBlockZ()]; + } + return BiomeTypes.OCEAN; } @Override public boolean setBiome(BlockVector2 position, BiomeType biome) { + if (position.containedWithin(getMinimumPoint().toBlockVector2(), getMaximumPoint().toBlockVector2())) { + BlockVector2 v = position.subtract(region.getMinimumPoint().toBlockVector2()); + if (biomes == null) { + biomes = new BiomeType[region.getWidth()][region.getLength()]; + } + biomes[v.getBlockX()][v.getBlockZ()] = biome; + return true; + } return false; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java index 8cdc084bc..09594e388 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java @@ -93,7 +93,7 @@ public class SpongeSchematicReader extends NBTSchematicReader { throw new IOException("This schematic version is currently not supported"); } - private Clipboard readVersion1(CompoundTag schematicTag) throws IOException { + private BlockArrayClipboard readVersion1(CompoundTag schematicTag) throws IOException { BlockVector3 origin; Region region; Map schematic = schematicTag.getValue();