From c6ef1bc1de9e0753fe618950b1448ad9a6fe8ac6 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 22 Oct 2020 22:18:16 +0100 Subject: [PATCH] Full support for 3D biomes (#714) * Full support for 3D biomes Since we're only supporting 1.15+ there's no need to try anything other than compatibility * this is not part of the PR * Clipboards should still always be y 0 for biomes (this "bug" has existed for ages) --- .../mc1_15_2/BukkitGetBlocks_1_15_2.java | 16 +++++++-------- .../mc1_16_1/BukkitGetBlocks_1_16_1.java | 16 +++++++-------- .../mc1_16_2/BukkitGetBlocks_1_16_2.java | 18 ++++++++--------- .../java/com/boydti/fawe/beta/IChunkSet.java | 6 ++++++ .../implementation/blocks/CharSetBlocks.java | 6 +++--- .../blocks/FallbackChunkGet.java | 12 ++++++----- .../implementation/chunk/ChunkHolder.java | 6 +++--- .../com/boydti/fawe/jnbt/anvil/MCAChunk.java | 6 +++--- .../com/boydti/fawe/object/HistoryExtent.java | 4 ++-- .../com/boydti/fawe/object/NullChangeSet.java | 2 +- .../brush/visualization/VisualExtent.java | 6 ++++++ .../object/change/MutableBiomeChange.java | 7 ++++--- .../object/changeset/AbstractChangeSet.java | 18 +++++++++-------- .../changeset/AbstractDelegateChangeSet.java | 4 ++-- .../fawe/object/changeset/CFIChangeSet.java | 2 +- .../object/changeset/FaweStreamChangeSet.java | 6 ++++-- .../clipboard/DiskOptimizedClipboard.java | 2 +- .../fawe/object/extent/MultiTransform.java | 3 +-- .../fawe/object/extent/OffsetExtent.java | 13 ++---------- .../fawe/object/extent/ProcessedWEExtent.java | 3 +-- .../object/extent/RandomOffsetTransform.java | 9 +++------ .../fawe/object/extent/ScaleTransform.java | 20 ++++++++++--------- .../fawe/object/extent/SelectTransform.java | 2 +- .../sk89q/worldedit/extent/MaskingExtent.java | 6 ------ .../sk89q/worldedit/extent/OutputExtent.java | 6 +++++- .../worldedit/extent/PassthroughExtent.java | 3 +-- .../extent/world/ChunkLoadingExtent.java | 4 ++-- .../extent/world/WatchdogTickingExtent.java | 3 +-- 28 files changed, 106 insertions(+), 103 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java index 21e19e33e..0cb058215 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java @@ -419,14 +419,14 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks { if (createCopy) { copy.storeBiomes(currentBiomes); } - for (int z = 0, i = 0; z < 16; z++) { - for (int x = 0; x < 16; x++, i++) { - final BiomeType biome = biomes[i]; - if (biome != null) { - final Biome craftBiome = BukkitAdapter.adapt(biome); - BiomeBase nmsBiome = CraftBlock.biomeToBiomeBase(craftBiome); - for (int y = 0; y < FaweCache.IMP.WORLD_HEIGHT; y++) { - currentBiomes.setBiome(x >> 2, y >> 2, z >> 2, nmsBiome); + for (int y = 0, i = 0; y < 64; y++) { + for (int z = 0; z < 4; z++) { + for (int x = 0; x < 4; x++, i++) { + final BiomeType biome = biomes[i]; + if (biome != null) { + final Biome craftBiome = BukkitAdapter.adapt(biome); + BiomeBase nmsBiome = CraftBlock.biomeToBiomeBase(craftBiome); + currentBiomes.setBiome(x, y, z, nmsBiome); } } } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java index a4d4c1227..a2538a143 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_1/BukkitGetBlocks_1_16_1.java @@ -421,14 +421,14 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks { if (createCopy) { copy.storeBiomes(currentBiomes); } - for (int z = 0, i = 0; z < 16; z++) { - for (int x = 0; x < 16; x++, i++) { - final BiomeType biome = biomes[i]; - if (biome != null) { - final Biome craftBiome = BukkitAdapter.adapt(biome); - BiomeBase nmsBiome = CraftBlock.biomeToBiomeBase(craftBiome); - for (int y = 0; y < FaweCache.IMP.WORLD_HEIGHT; y++) { - currentBiomes.setBiome(x >> 2, y >> 2, z >> 2, nmsBiome); + for (int y = 0, i = 0; y < 64; y++) { + for (int z = 0; z < 4; z++) { + for (int x = 0; x < 4; x++, i++) { + final BiomeType biome = biomes[i]; + if (biome != null) { + final Biome craftBiome = BukkitAdapter.adapt(biome); + BiomeBase nmsBiome = CraftBlock.biomeToBiomeBase(craftBiome); + currentBiomes.setBiome(x, y, z, nmsBiome); } } } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitGetBlocks_1_16_2.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitGetBlocks_1_16_2.java index e61453ddf..e19038d48 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitGetBlocks_1_16_2.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_16_2/BukkitGetBlocks_1_16_2.java @@ -59,6 +59,7 @@ import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.annotation.Nullable; import java.util.AbstractSet; import java.util.Arrays; import java.util.Collection; @@ -72,7 +73,6 @@ import java.util.UUID; import java.util.concurrent.Callable; import java.util.concurrent.Future; import java.util.function.Function; -import javax.annotation.Nullable; import static org.slf4j.LoggerFactory.getLogger; @@ -424,14 +424,14 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks { if (createCopy) { copy.storeBiomes(currentBiomes); } - for (int z = 0, i = 0; z < 16; z++) { - for (int x = 0; x < 16; x++, i++) { - final BiomeType biome = biomes[i]; - if (biome != null) { - final Biome craftBiome = BukkitAdapter.adapt(biome); - BiomeBase nmsBiome = CraftBlock.biomeToBiomeBase(nmsWorld.r().b(IRegistry.ay), craftBiome); - for (int y = 0; y < FaweCache.IMP.WORLD_HEIGHT; y++) { - currentBiomes.setBiome(x >> 2, y >> 2, z >> 2, nmsBiome); + for (int y = 0, i = 0; y < 64; y++) { + for (int z = 0; z < 4; z++) { + for (int x = 0; x < 4; x++, i++) { + final BiomeType biome = biomes[i]; + if (biome != null) { + final Biome craftBiome = BukkitAdapter.adapt(biome); + BiomeBase nmsBiome = CraftBlock.biomeToBiomeBase(nmsWorld.r().b(IRegistry.ay), craftBiome); + currentBiomes.setBiome(x, y, z, nmsBiome); } } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkSet.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkSet.java index 1395fa4af..73ed38ce8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/IChunkSet.java @@ -60,6 +60,12 @@ public interface IChunkSet extends IBlocks, OutputExtent { Set getEntityRemoves(); + /** + * This will return only biomes SET to the EXTENT or QUEUE. This will NOT return the current biomes in the world. + * This is used for history purposes. + * + * @return Array of biomes set + */ BiomeType[] getBiomes(); default boolean hasBiomes() { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharSetBlocks.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharSetBlocks.java index fcb899b58..249b3e1b0 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharSetBlocks.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/CharSetBlocks.java @@ -57,7 +57,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet { if (biomes == null) { return null; } - return biomes[(z << 4) | x]; + return biomes[y << 2 | z & 12 | x >> 2]; } @Override @@ -88,9 +88,9 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet { @Override public boolean setBiome(int x, int y, int z, BiomeType biome) { if (biomes == null) { - biomes = new BiomeType[256]; + biomes = new BiomeType[1024]; } - biomes[x + (z << 4)] = biome; + biomes[y << 2 | z & 12 | x >> 2] = biome; return true; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/FallbackChunkGet.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/FallbackChunkGet.java index 3babb36c8..0dd9ab884 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/FallbackChunkGet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/blocks/FallbackChunkGet.java @@ -159,11 +159,13 @@ public class FallbackChunkGet implements IChunkGet { } BiomeType[] biomes = set.getBiomes(); if (biomes != null) { - for (int z = 0, i = 0; z < 16; z++) { - for (int x = 0; x < 16; x++, i++) { - BiomeType biome = biomes[i]; - if (biome != null) { - extent.setBiome(bx + x, 0, bz + z, biome); + for (int y = 0, i = 0; y < 64; y++) { + for (int z = 0; z < 4; z++) { + for (int x = 0; x < 4; x++, i++) { + BiomeType biome = biomes[i]; + if (biome != null) { + extent.setBiome(bx + (x << 2), y << 2, bz + (z << 2), biome); + } } } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ChunkHolder.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ChunkHolder.java index 1ca097b80..9c4122fac 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ChunkHolder.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/chunk/ChunkHolder.java @@ -94,7 +94,8 @@ public class ChunkHolder> implements IQueueChunk { @Override public BiomeType[] getBiomes() { - return delegate.set(this).getBiomes(); // TODO return get? + // Uses set as this method is only used to retrieve biomes that have been set to the extent/chunk. + return delegate.set(this).getBiomes(); } @Override public char[][] getLight() { @@ -218,8 +219,7 @@ public class ChunkHolder> implements IQueueChunk { } @Override - public BaseBlock getFullBlock(ChunkHolder chunk, int x, int y, - int z) { + public BaseBlock getFullBlock(ChunkHolder chunk, int x, int y, int z) { return chunk.chunkExisting.getFullBlock(x, y, z); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java index e2cecd706..dac042616 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java @@ -50,7 +50,7 @@ public class MCAChunk implements IChunk { public final boolean[] hasSections = new boolean[16]; public boolean hasBiomes = false; - public final BiomeType[] biomes = new BiomeType[256]; + public final BiomeType[] biomes = new BiomeType[1024]; public final char[] blocks = new char[65536]; @@ -481,7 +481,7 @@ public class MCAChunk implements IChunk { @Override public BiomeType getBiomeType(int x, int y, int z) { - return this.biomes[(z << 4) | x]; + return this.biomes[y << 2 | z & 12 | x >> 2]; } @Override @@ -505,7 +505,7 @@ public class MCAChunk implements IChunk { @Override public boolean setBiome(int x, int y, int z, BiomeType biome) { setModified(); - biomes[x + (z << 4)] = biome; //TODO Support 3D Biomes + biomes[y << 2 | z & 12 | x >> 2] = biome; return true; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/HistoryExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/HistoryExtent.java index 15f372e1e..f05338fa1 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/HistoryExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/HistoryExtent.java @@ -98,7 +98,7 @@ public class HistoryExtent extends AbstractDelegateExtent { public boolean setBiome(BlockVector3 position, BiomeType newBiome) { BiomeType oldBiome = this.getBiome(position); if (oldBiome.getId() != newBiome.getId()) { - this.changeSet.addBiomeChange(position.getBlockX(), position.getBlockZ(), oldBiome, newBiome); + this.changeSet.addBiomeChange(position.getBlockX(), position.getBlockY(), position.getBlockZ(), oldBiome, newBiome); return getExtent().setBiome(position, newBiome); } else { return false; @@ -109,7 +109,7 @@ public class HistoryExtent extends AbstractDelegateExtent { public boolean setBiome(int x, int y, int z, BiomeType newBiome) { BiomeType oldBiome = this.getBiome(BlockVector3.at(x, y, z)); if (oldBiome.getId() != newBiome.getId()) { - this.changeSet.addBiomeChange(x, z, oldBiome, newBiome); + this.changeSet.addBiomeChange(x, y, z, oldBiome, newBiome); return getExtent().setBiome(x, y, z, newBiome); } else { return false; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/NullChangeSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/NullChangeSet.java index 5d63474c3..5313dcf4a 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/NullChangeSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/NullChangeSet.java @@ -46,7 +46,7 @@ public class NullChangeSet extends AbstractChangeSet { } @Override - public void addBiomeChange(int x, int z, BiomeType from, BiomeType to) { + public void addBiomeChange(int x, int y, int z, BiomeType from, BiomeType to) { } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualExtent.java index b3edc1cc4..73ab7309b 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualExtent.java @@ -57,6 +57,12 @@ public class VisualExtent extends AbstractDelegateExtent { return false; } + @Override + public boolean setBiome(BlockVector3 position, BiomeType biome) { + // Do nothing + return false; + } + public void clear() { IQueueExtent queue = (IQueueExtent) getExtent(); queue.cancel(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableBiomeChange.java b/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableBiomeChange.java index db2b83226..2fb27950f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableBiomeChange.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/change/MutableBiomeChange.java @@ -4,11 +4,12 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.history.UndoContext; import com.sk89q.worldedit.history.change.Change; import com.sk89q.worldedit.math.MutableBlockVector2; +import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.world.biome.BiomeTypes; public class MutableBiomeChange implements Change { - private MutableBlockVector2 mutable = new MutableBlockVector2(); + private final MutableBlockVector3 mutable = new MutableBlockVector3(); private int from; private int to; @@ -17,8 +18,8 @@ public class MutableBiomeChange implements Change { this.to = 0; } - public void setBiome(int x, int z, int from, int to) { - mutable.setComponents(x, z); + public void setBiome(int x, int y, int z, int from, int to) { + mutable.setComponents(x, y, z); this.from = from; this.to = to; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AbstractChangeSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AbstractChangeSet.java index 88d9a923d..c41457655 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AbstractChangeSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AbstractChangeSet.java @@ -188,13 +188,15 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor { BiomeType[] biomes = set.getBiomes(); if (biomes != null) { - for (int z = 0, index = 0; z < 16; z++) { - for (int x = 0; x < 16; x++, index++) { - BiomeType newBiome = biomes[index]; - if (newBiome != null) { - BiomeType oldBiome = get.getBiomeType(x, 0, z); - if (oldBiome != newBiome) { - addBiomeChange(bx + x, bz + z, oldBiome, newBiome); + for (int y = 0, index = 0; y < 64; y++) { + for (int z = 0; z < 4; z++) { + for (int x = 0; x < 4; x++, index++) { + BiomeType newBiome = biomes[index]; + if (newBiome != null) { + BiomeType oldBiome = get.getBiomeType(x, y, z); + if (oldBiome != newBiome) { + addBiomeChange(bx + (x << 2), y << 2,bz + (z << 2), oldBiome, newBiome); + } } } } @@ -216,7 +218,7 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor { public abstract void addEntityCreate(CompoundTag tag); - public abstract void addBiomeChange(int x, int z, BiomeType from, BiomeType to); + public abstract void addBiomeChange(int x, int y, int z, BiomeType from, BiomeType to); public Iterator getIterator(BlockBag blockBag, int mode, boolean redo) { return getIterator(redo); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AbstractDelegateChangeSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AbstractDelegateChangeSet.java index f4a6af0d5..54e2ddeb5 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AbstractDelegateChangeSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/AbstractDelegateChangeSet.java @@ -69,8 +69,8 @@ public class AbstractDelegateChangeSet extends AbstractChangeSet { } @Override - public void addBiomeChange(int x, int z, BiomeType from, BiomeType to) { - parent.addBiomeChange(x, z, from, to); + public void addBiomeChange(int x, int y, int z, BiomeType from, BiomeType to) { + parent.addBiomeChange(x, y, z, from, to); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/CFIChangeSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/CFIChangeSet.java index 3059013f0..83bcee1ce 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/CFIChangeSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/CFIChangeSet.java @@ -68,7 +68,7 @@ public class CFIChangeSet extends AbstractChangeSet { } @Override - public void addBiomeChange(int x, int z, BiomeType from, BiomeType to) { + public void addBiomeChange(int x, int y, int z, BiomeType from, BiomeType to) { throw new UnsupportedOperationException("Only CFI operations are supported"); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/FaweStreamChangeSet.java b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/FaweStreamChangeSet.java index 3eb4d6cb7..aa90fa9bc 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/FaweStreamChangeSet.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/FaweStreamChangeSet.java @@ -321,7 +321,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet { } @Override - public void addBiomeChange(int x, int z, BiomeType from, BiomeType to) { + public void addBiomeChange(int x, int y, int z, BiomeType from, BiomeType to) { blockSize++; try { FaweOutputStream os = getBiomeOS(); @@ -333,6 +333,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet { os.write((byte) (z >> 16)); os.write((byte) (z >> 8)); os.write((byte) (z)); + os.write((byte) (y)); os.writeVarInt(from.getInternalId()); os.writeVarInt(to.getInternalId()); } catch (Throwable e) { @@ -462,9 +463,10 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet { if (int1 != -1) { int x = ((int1 << 24) + (is.read() << 16) + (is.read() << 8) + is.read()); int z = ((is.read() << 24) + (is.read() << 16) + (is.read() << 8) + is.read()); + int y = is.read(); int from = is.readVarInt(); int to = is.readVarInt(); - change.setBiome(x, z, from, to); + change.setBiome(x, y, z, from, to); return change; } } catch (EOFException ignored) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java index b0dcd3035..aa2160029 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/DiskOptimizedClipboard.java @@ -185,7 +185,7 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable @Override public boolean setBiome(int x, int y, int z, BiomeType biome) { - setBiome(getIndex(x, y, z), biome); + setBiome(getIndex(x, 0, z), biome); return true; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/MultiTransform.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/MultiTransform.java index 1f6a36ff2..e9531246e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/MultiTransform.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/MultiTransform.java @@ -4,7 +4,6 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extent.AbstractDelegateExtent; -import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.biome.BiomeType; @@ -56,7 +55,7 @@ public class MultiTransform extends RandomTransform { } @Override - public boolean setBiome(BlockVector2 position, BiomeType biome) { + public boolean setBiome(BlockVector3 position, BiomeType biome) { // don't use streams for each block place, it'd be incredibly slow boolean result = false; for (AbstractDelegateExtent extent : extents) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/OffsetExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/OffsetExtent.java index 32117eba1..fea7bcd3f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/OffsetExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/OffsetExtent.java @@ -2,9 +2,7 @@ package com.boydti.fawe.object.extent; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector2; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -13,7 +11,6 @@ public class OffsetExtent extends ResettableExtent { private final int dx; private final int dy; private final int dz; - private transient MutableBlockVector2 mutable = new MutableBlockVector2(); public OffsetExtent(Extent parent, int dx, int dy, int dz) { super(parent); @@ -23,9 +20,9 @@ public class OffsetExtent extends ResettableExtent { } @Override - public boolean setBiome(BlockVector2 position, BiomeType biome) { + public boolean setBiome(BlockVector3 position, BiomeType biome) { return getExtent() - .setBiome(mutable.setComponents(position.getBlockX() + dx, position.getBlockZ() + dz), + .setBiome(position.getBlockX() + dx, position.getBlockY() + dy, position.getBlockZ() + dz, biome); } @@ -46,10 +43,4 @@ public class OffsetExtent extends ResettableExtent { throws WorldEditException { return getExtent().setBlock(x + dx, y + dy, z + dz, block); } - - @Override - public ResettableExtent setExtent(Extent extent) { - mutable = new MutableBlockVector2(); - return super.setExtent(extent); - } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ProcessedWEExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ProcessedWEExtent.java index a1ff5f79a..51a07bee2 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ProcessedWEExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ProcessedWEExtent.java @@ -8,7 +8,6 @@ import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.biome.BiomeType; @@ -100,7 +99,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent { } @Override - public boolean setBiome(BlockVector2 position, BiomeType biome) { + public boolean setBiome(BlockVector3 position, BiomeType biome) { if (!limit.MAX_CHANGES()) { WEManager.IMP.cancelEditSafe(this, FaweCache.MAX_CHANGES); return false; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/RandomOffsetTransform.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/RandomOffsetTransform.java index f275d4d45..d6251e798 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/RandomOffsetTransform.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/RandomOffsetTransform.java @@ -2,9 +2,7 @@ package com.boydti.fawe.object.extent; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.math.MutableBlockVector2; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -16,7 +14,6 @@ public class RandomOffsetTransform extends ResettableExtent { private final int dy; private final int dz; private transient SplittableRandom random; - private transient MutableBlockVector2 mutable = new MutableBlockVector2(); public RandomOffsetTransform(Extent parent, int dx, int dy, int dz) { super(parent); @@ -27,10 +24,11 @@ public class RandomOffsetTransform extends ResettableExtent { } @Override - public boolean setBiome(BlockVector2 pos, BiomeType biome) { + public boolean setBiome(BlockVector3 pos, BiomeType biome) { int x = pos.getBlockX() + random.nextInt(1 + (dx << 1)) - dx; + int y = pos.getBlockY() + random.nextInt(1 + (dy << 1)) - dy; int z = pos.getBlockZ() + random.nextInt(1 + (dz << 1)) - dz; - return getExtent().setBiome(mutable.setComponents(x, z), biome); + return getExtent().setBiome(x, y, z, biome); } @Override @@ -54,7 +52,6 @@ public class RandomOffsetTransform extends ResettableExtent { @Override public ResettableExtent setExtent(Extent extent) { random = new SplittableRandom(); - mutable = new MutableBlockVector2(); return super.setExtent(extent); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ScaleTransform.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ScaleTransform.java index 2e3364543..fc7edc33c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ScaleTransform.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/ScaleTransform.java @@ -4,7 +4,6 @@ import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.util.Location; @@ -82,17 +81,20 @@ public class ScaleTransform extends ResettableExtent { } @Override - public boolean setBiome(BlockVector2 position, BiomeType biome) { + public boolean setBiome(BlockVector3 position, BiomeType biome) { boolean result = false; - MutableBlockVector3 pos = new MutableBlockVector3( - getPos(position.getBlockX(), 0, position.getBlockZ())); + MutableBlockVector3 pos = new MutableBlockVector3(getPos(position)); double sx = pos.getX(); + double sy = pos.getY(); double sz = pos.getZ(); - double ex = pos.getX() + dx; - double ez = pos.getZ() + dz; - for (pos.mutZ(sz); pos.getZ() < ez; pos.mutZ(pos.getZ() + 1)) { - for (pos.mutX(sx); pos.getX() < ex; pos.mutX(pos.getX() + 1)) { - result |= super.setBiome(pos.toBlockVector2(), biome); + double ex = sx + dx; + double ey = Math.min(maxy, sy + dy); + double ez = sz + dz; + for (pos.mutY(sy); pos.getY() < ey; pos.mutY(pos.getY() + 1)) { + for (pos.mutZ(sz); pos.getZ() < ez; pos.mutZ(pos.getZ() + 1)) { + for (pos.mutX(sx); pos.getX() < ex; pos.mutX(pos.getX() + 1)) { + result |= super.setBiome(pos, biome); + } } } return result; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SelectTransform.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SelectTransform.java index 0a7f0937a..a0bf46070 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SelectTransform.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/SelectTransform.java @@ -52,7 +52,7 @@ public abstract class SelectTransform extends ResettableExtent { } @Override - public boolean setBiome(BlockVector2 position, BiomeType biome) { + public boolean setBiome(BlockVector3 position, BiomeType biome) { return getExtent(position).setBiome(position, biome); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java index 3b47245fd..1d0078eef 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java @@ -31,7 +31,6 @@ import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; import com.google.common.cache.LoadingCache; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.mask.Mask; -import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -93,11 +92,6 @@ public class MaskingExtent extends AbstractDelegateExtent implements IBatchProce return this.mask.test(location) && super.setBlock(location, block); } - @Override - public boolean setBiome(BlockVector2 position, BiomeType biome) { - return this.mask.test(position.toBlockVector3()) && super.setBiome(position, biome); - } - @Override public boolean setBiome(int x, int y, int z, BiomeType biome) { return this.mask.test(BlockVector3.at(x, y, z)) && super.setBiome(x, y, z, biome); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/OutputExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/OutputExtent.java index 6ef2dd34d..3532bfeac 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/OutputExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/OutputExtent.java @@ -94,7 +94,11 @@ public interface OutputExtent { */ @Deprecated default boolean setBiome(BlockVector2 position, BiomeType biome) { - return setBiome(position.toBlockVector3(), biome); + boolean result = false; + for (int y = 0; y < 256; y ++) { + result |= setBiome(position.toBlockVector3().mutY(y), biome); + } + return result; } @NonAbstractForCompatibility( diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/PassthroughExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/PassthroughExtent.java index 5488ee124..73b6f9b37 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/PassthroughExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/PassthroughExtent.java @@ -10,7 +10,6 @@ import com.sk89q.worldedit.function.generator.Resource; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.pattern.Pattern; -import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.session.ClipboardHolder; @@ -199,7 +198,7 @@ public class PassthroughExtent extends AbstractDelegateExtent { } @Override - public boolean setBiome(BlockVector2 position, BiomeType biome) { + public boolean setBiome(BlockVector3 position, BiomeType biome) { return getExtent().setBiome(position, biome); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/ChunkLoadingExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/ChunkLoadingExtent.java index 6e2cb413b..84bc7e88d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/ChunkLoadingExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/ChunkLoadingExtent.java @@ -71,9 +71,9 @@ public class ChunkLoadingExtent extends AbstractDelegateExtent { } @Override - public boolean setBiome(BlockVector2 position, BiomeType biome) { + public boolean setBiome(BlockVector3 position, BiomeType biome) { if (enabled) { - world.checkLoadedChunk(position.toBlockVector3()); + world.checkLoadedChunk(position); } return super.setBiome(position, biome); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/WatchdogTickingExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/WatchdogTickingExtent.java index cc19952bf..811bbde75 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/WatchdogTickingExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/WatchdogTickingExtent.java @@ -25,7 +25,6 @@ import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extension.platform.Watchdog; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; -import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.biome.BiomeType; @@ -88,7 +87,7 @@ public class WatchdogTickingExtent extends AbstractDelegateExtent { } @Override - public boolean setBiome(BlockVector2 position, BiomeType biome) { + public boolean setBiome(BlockVector3 position, BiomeType biome) { onOperation(); return super.setBiome(position, biome); }