From 1beea3cd228a6ae5d7ce64d21485ecb975c8f37d Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Thu, 4 Apr 2019 21:28:41 +1100 Subject: [PATCH] Some more upstream merge --- .../com/boydti/fawe/example/IntFaweChunk.java | 10 +-- .../boydti/fawe/example/MappedFaweQueue.java | 8 +- .../boydti/fawe/example/NullFaweChunk.java | 9 +-- .../boydti/fawe/jnbt/SchematicStreamer.java | 3 +- .../jnbt/anvil/HeightMapMCAGenerator.java | 4 +- .../com/boydti/fawe/jnbt/anvil/MCAChunk.java | 14 ++-- .../com/boydti/fawe/jnbt/anvil/MCAQueue.java | 4 +- .../com/boydti/fawe/object/FaweChunk.java | 8 +- .../brush/visualization/VisualChunk.java | 7 +- .../AbstractDelegateFaweClipboard.java | 4 +- .../clipboard/CPUOptimizedClipboard.java | 4 +- .../clipboard/DiskOptimizedClipboard.java | 9 ++- .../fawe/object/clipboard/FaweClipboard.java | 4 +- .../clipboard/MemoryOptimizedClipboard.java | 9 ++- .../object/clipboard/ReadOnlyClipboard.java | 6 +- .../object/extent/FastWorldEditExtent.java | 2 +- .../fawe/object/queue/LazyFaweChunk.java | 9 +-- .../fawe/object/queue/NullFaweQueue.java | 2 +- .../object/schematic/visualizer/SchemVis.java | 3 +- .../regions/general/plot/PlotSetBiome.java | 3 +- .../com/sk89q/worldedit/CuboidClipboard.java | 8 +- .../worldedit/command/BrushCommands.java | 2 + .../worldedit/command/ChunkCommands.java | 1 + .../command/FlattenedClipboardTransform.java | 9 ++- .../worldedit/command/NavigationCommands.java | 1 + .../sk89q/worldedit/command/ToolCommands.java | 1 + .../command/tool/FloatingTreeRemover.java | 81 ++++++++++++++++--- .../command/tool/LongRangeBuildTool.java | 1 + .../worldedit/command/tool/QueryTool.java | 2 +- .../worldedit/command/tool/TreePlanter.java | 28 ++++--- .../factory/parser/DefaultBlockParser.java | 3 + .../extent/AbstractDelegateExtent.java | 9 +++ .../worldedit/extent/ChangeSetExtent.java | 1 + .../com/sk89q/worldedit/extent/Extent.java | 45 ++++++++++- .../sk89q/worldedit/extent/MaskingExtent.java | 2 + .../extent/clipboard/BlockArrayClipboard.java | 1 + .../clipboard/io/SpongeSchematicReader.java | 6 +- .../worldedit/math/convolution/HeightMap.java | 4 +- .../worldedit/regions/EllipsoidRegion.java | 2 +- .../world/registry/ItemRegistry.java | 9 --- 40 files changed, 222 insertions(+), 116 deletions(-) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/example/IntFaweChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/example/IntFaweChunk.java index 6b924faaf..73c7661fd 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/example/IntFaweChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/example/IntFaweChunk.java @@ -5,6 +5,7 @@ import com.boydti.fawe.object.FaweChunk; import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.util.MathMan; import com.sk89q.jnbt.CompoundTag; +import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockTypes; import java.util.*; @@ -16,7 +17,7 @@ public abstract class IntFaweChunk extends FaweChunk public final short[] air; public final byte[] heightMap; - public byte[] biomes; + public BiomeType[] biomes; public HashMap tiles; public HashSet entities; public HashSet entityRemoves; @@ -129,7 +130,7 @@ public abstract class IntFaweChunk extends FaweChunk } @Override - public byte[] getBiomeArray() { + public BiomeType[] getBiomeArray() { return this.biomes; } @@ -216,11 +217,10 @@ public abstract class IntFaweChunk extends FaweChunk } @Override - public void setBiome(final int x, final int z, byte biome) { + public void setBiome(final int x, final int z, BiomeType biome) { if (this.biomes == null) { - this.biomes = new byte[256]; + this.biomes = new BiomeType[256]; } - if (biome == 0) biome = -1; biomes[((z & 15) << 4) + (x & 15)] = biome; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/example/MappedFaweQueue.java b/worldedit-core/src/main/java/com/boydti/fawe/example/MappedFaweQueue.java index 81f5cf836..4b403e132 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/example/MappedFaweQueue.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/example/MappedFaweQueue.java @@ -385,7 +385,7 @@ public abstract class MappedFaweQueue impl return getCombinedId4Data(lastSection, x, y, z); } - public abstract int getBiome(CHUNK chunk, int x, int z); + public abstract BiomeType getBiome(CHUNK chunk, int x, int z); public abstract CompoundTag getTileEntity(CHUNK chunk, int x, int y, int z); @@ -765,12 +765,12 @@ public abstract class MappedFaweQueue impl lastChunkSections = getSections(lastChunk); } else { lastChunkSections = null; - return 0; + return null; } } else if (lastChunk == null) { - return 0; + return null; } - return getBiome(lastChunk, x, z) & 0xFF; + return getBiome(lastChunk, x, z); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/example/NullFaweChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/example/NullFaweChunk.java index 0f76863c9..b3bba3396 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/example/NullFaweChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/example/NullFaweChunk.java @@ -37,8 +37,8 @@ public class NullFaweChunk extends FaweChunk { } @Override - public byte[] getBiomeArray() { - return new byte[256]; + public BiomeType[] getBiomeArray() { + return new BiomeType[256]; } @Override @@ -101,11 +101,6 @@ public class NullFaweChunk extends FaweChunk { } - @Override - public void setBiome(int x, int z, byte biome) { - - } - @Override public FaweChunk copy(boolean shallow) { return this; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/SchematicStreamer.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/SchematicStreamer.java index 2ecfc7101..f5c14a526 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/SchematicStreamer.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/SchematicStreamer.java @@ -22,6 +22,7 @@ import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.registry.state.PropertyKey; import com.sk89q.worldedit.util.Direction; +import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.block.*; import com.sk89q.worldedit.world.entity.EntityType; import com.sk89q.worldedit.world.entity.EntityTypes; @@ -118,7 +119,7 @@ public class SchematicStreamer extends NBTStreamer { ByteReader biomeReader = new ByteReader() { @Override public void run(int index, int value) { - fc.setBiome(index, value); + fc.setBiome(index, BiomeTypes.get(value)); } }; NBTStreamReader initializer23 = new NBTStreamReader() { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java index 23cc02cf6..4f40c6ae0 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java @@ -923,7 +923,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr public BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException { int index = z * getWidth() + x; if (index < 0 || index >= getArea()) index = Math.floorMod(index, getArea()); - return biomes.getByte(index) & 0xFF; + return BiomeTypes.get(biomes.getByte(index)); } @Override @@ -1011,7 +1011,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr @Override public BiomeType getBiome(BlockVector2 position) { - return BiomeTypes.get(getBiomeType(position.getBlockX(), position.getBlockZ())); + return getBiomeType(position.getBlockX(), position.getBlockZ()); } @Override 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 b90c63794..38dcfb0e0 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 @@ -11,6 +11,8 @@ import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.ReflectionUtils; import com.sk89q.jnbt.*; +import com.sk89q.worldedit.world.biome.BiomeType; + import java.io.DataOutput; import java.io.DataOutputStream; import java.io.IOException; @@ -590,9 +592,9 @@ public class MCAChunk extends FaweChunk { } @Override - public void setBiome(int x, int z, byte biome) { + public void setBiome(int x, int z, BiomeType biome) { setModified(); - biomes[x + (z << 4)] = biome; + biomes[x + (z << 4)] = (byte) biome.getInternalId(); } @Override @@ -644,8 +646,8 @@ public class MCAChunk extends FaweChunk { } @Override - public byte[] getBiomeArray() { - return this.biomes; + public BiomeType[] getBiomeArray() { + return null; } @Override @@ -771,8 +773,8 @@ public class MCAChunk extends FaweChunk { } @Override - public void setBiome(byte biome) { - Arrays.fill(biomes, biome); + public void setBiome(BiomeType biome) { + Arrays.fill(biomes, (byte) biome.getInternalId()); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAQueue.java b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAQueue.java index 7010e0aa2..5a96a16cf 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAQueue.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAQueue.java @@ -86,13 +86,13 @@ public class MCAQueue extends NMSMappedFaweQueue implements Callable { */ public abstract CompoundTag getTile(int x, int y, int z); - public void setBiome(final int x, final int z, final BiomeType biome) { - setBiome(x, z, biome); - } + public abstract void setBiome(final int x, final int z, final BiomeType biome); - public abstract void setBiome(final int x, final int z, final byte biome); - - public void setBiome(final byte biome) { + public void setBiome(final BiomeType biome) { for (int z = 0; z < 16; z++) { for (int x = 0; x < 16; x++) { setBiome(x, z, biome); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualChunk.java index 3ab6dac36..aa7951e93 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/brush/visualization/VisualChunk.java @@ -5,6 +5,7 @@ import com.boydti.fawe.object.collection.SparseBitSet; import com.boydti.fawe.object.visitor.FaweChunkVisitor; import com.boydti.fawe.util.MathMan; import com.sk89q.jnbt.CompoundTag; +import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockTypes; @@ -87,8 +88,8 @@ public class VisualChunk extends FaweChunk { } @Override - public byte[] getBiomeArray() { - return new byte[256]; + public BiomeType[] getBiomeArray() { + return new BiomeType[256]; } @Override @@ -154,7 +155,7 @@ public class VisualChunk extends FaweChunk { } @Override - public void setBiome(int x, int z, byte biome) { + public void setBiome(int x, int z, BiomeType biome) { // Unsupported } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/AbstractDelegateFaweClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/AbstractDelegateFaweClipboard.java index c2b477fb5..f41a37790 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/AbstractDelegateFaweClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/AbstractDelegateFaweClipboard.java @@ -42,7 +42,7 @@ public class AbstractDelegateFaweClipboard extends FaweClipboard { } @Override - public boolean setBiome(int x, int z, int biome) { + public boolean setBiome(int x, int z, BiomeType biome) { return parent.setBiome(x, z, biome); } @@ -62,7 +62,7 @@ public class AbstractDelegateFaweClipboard extends FaweClipboard { } @Override - public void setBiome(int index, int biome) { + public void setBiome(int index, BiomeType biome) { parent.setBiome(index, biome); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java index 77281d639..a012b5358 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/CPUOptimizedClipboard.java @@ -59,7 +59,7 @@ public class CPUOptimizedClipboard extends FaweClipboard { } @Override - public boolean setBiome(int x, int z, int biome) { + public boolean setBiome(int x, int z, BiomeType biome) { setBiome(getIndex(x, 0, z), biome); return true; } @@ -78,7 +78,7 @@ public class CPUOptimizedClipboard extends FaweClipboard { int index = 0; for (int z = 0; z < length; z++) { for (int x = 0; x < width; x++, index++) { - task.run(index, biomes[index] & 0xFF); + task.run(index, biomes[index].getInternalId()); } } } 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 291aecad6..72fc58050 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 @@ -11,6 +11,7 @@ import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.IntTag; import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.entity.BaseEntity; @@ -127,15 +128,15 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable { } @Override - public boolean setBiome(int x, int z, int biome) { + public boolean setBiome(int x, int z, BiomeType biome) { setBiome(getIndex(x, 0, z), biome); return true; } @Override - public void setBiome(int index, int biome) { + public void setBiome(int index, BiomeType biome) { if (initBiome()) { - mbb.put(HEADER_SIZE + (volume << 2) + index, (byte) biome); + mbb.put(HEADER_SIZE + (volume << 2) + index, (byte) biome.getInternalId()); } } @@ -145,7 +146,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable { return null; } int biomeId = mbb.get(HEADER_SIZE + (volume << 2) + index) & 0xFF; - return FaweCache.CACHE_BIOME[biomeId]; + return BiomeTypes.get(biomeId); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/FaweClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/FaweClipboard.java index e082718ec..d7f9534e8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/FaweClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/FaweClipboard.java @@ -33,7 +33,7 @@ public abstract class FaweClipboard { public abstract boolean hasBiomes(); - public abstract boolean setBiome(int x, int z, int biome); + public abstract boolean setBiome(int x, int z, BiomeType biome); public abstract BiomeType getBiome(int x, int z); @@ -41,7 +41,7 @@ public abstract class FaweClipboard { public abstract BaseBlock getBlock(int index); - public abstract void setBiome(int index, int biome); + public abstract void setBiome(int index, BiomeType biome); public abstract boolean setTile(int x, int y, int z, CompoundTag tag); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MemoryOptimizedClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MemoryOptimizedClipboard.java index a9d08f5b0..b0dc34196 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MemoryOptimizedClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/MemoryOptimizedClipboard.java @@ -10,6 +10,7 @@ import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.IntTag; import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.entity.BaseEntity; @@ -92,17 +93,17 @@ public class MemoryOptimizedClipboard extends FaweClipboard { } @Override - public boolean setBiome(int x, int z, int biome) { + public boolean setBiome(int x, int z, BiomeType biome) { setBiome(getIndex(x, 0, z), biome); return true; } @Override - public void setBiome(int index, int biome) { + public void setBiome(int index, BiomeType biome) { if (biomes == null) { biomes = new byte[area]; } - biomes[index] = (byte) biome; + biomes[index] = (byte) biome.getInternalId(); } @Override @@ -121,7 +122,7 @@ public class MemoryOptimizedClipboard extends FaweClipboard { if (!hasBiomes()) { return null; } - return FaweCache.CACHE_BIOME[biomes[index] & 0xFF]; + return BiomeTypes.get(biomes[index]); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/ReadOnlyClipboard.java b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/ReadOnlyClipboard.java index 3c3a4a3c3..8ffc068cf 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/ReadOnlyClipboard.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/clipboard/ReadOnlyClipboard.java @@ -56,12 +56,12 @@ public abstract class ReadOnlyClipboard extends FaweClipboard { } @Override - public boolean setBiome(int x, int z, int biome) { + public boolean setBiome(int x, int z, BiomeType biome) { throw new UnsupportedOperationException("Clipboard is immutable"); } @Override - public void setBiome(int index, int biome) { + public void setBiome(int index, BiomeType biome) { throw new UnsupportedOperationException("Clipboard is immutable"); } @@ -71,7 +71,7 @@ public abstract class ReadOnlyClipboard extends FaweClipboard { int index = 0; for (int z = 0; z <= dim.getBlockZ(); z++) { for (int x = 0; x <= dim.getBlockX(); x++, index++) { - task.run(index, getBiome(x, z)); + task.run(index, getBiome(x, z).getInternalId()); } } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/FastWorldEditExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/FastWorldEditExtent.java index 8cf582179..e8853dda8 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/extent/FastWorldEditExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/extent/FastWorldEditExtent.java @@ -105,7 +105,7 @@ public class FastWorldEditExtent extends AbstractDelegateExtent implements HasFa @Override public BiomeType getBiome(final BlockVector2 position) { - return BiomeTypes.get(queue.getBiomeType(position.getBlockX(), position.getBlockZ())); + return queue.getBiomeType(position.getBlockX(), position.getBlockZ()); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/queue/LazyFaweChunk.java b/worldedit-core/src/main/java/com/boydti/fawe/object/queue/LazyFaweChunk.java index 1020e90d4..02343d2dc 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/queue/LazyFaweChunk.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/queue/LazyFaweChunk.java @@ -91,7 +91,7 @@ public abstract class LazyFaweChunk extends FaweChunk { } @Override - public byte[] getBiomeArray() { + public BiomeType[] getBiomeArray() { return internalGetOrCacheChunk().getBiomeArray(); } @@ -176,12 +176,7 @@ public abstract class LazyFaweChunk extends FaweChunk { } @Override - public void setBiome(int x, int z, byte biome) { - internalGetOrCacheChunk().setBiome(x, z, biome); - } - - @Override - public void setBiome(byte biome) { + public void setBiome(BiomeType biome) { internalGetOrCacheChunk().setBiome(biome); } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/queue/NullFaweQueue.java b/worldedit-core/src/main/java/com/boydti/fawe/object/queue/NullFaweQueue.java index 221b79d2c..23f6ac293 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/queue/NullFaweQueue.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/queue/NullFaweQueue.java @@ -184,7 +184,7 @@ public class NullFaweQueue implements FaweQueue { @Override public BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException { - return 0; + return null; } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/visualizer/SchemVis.java b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/visualizer/SchemVis.java index f089cbc19..2026fff0c 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/visualizer/SchemVis.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/schematic/visualizer/SchemVis.java @@ -33,6 +33,7 @@ import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.TargetBlock; import com.sk89q.worldedit.world.biome.BiomeType; +import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; @@ -580,7 +581,7 @@ public class SchemVis extends ImmutableVirtualWorld { @Override public BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException { // TODO later (currently not used) - return 0; + return BiomeTypes.FOREST; } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/PlotSetBiome.java b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/PlotSetBiome.java index b7a4986dc..9b04d02f9 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/PlotSetBiome.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/regions/general/plot/PlotSetBiome.java @@ -24,6 +24,7 @@ import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.world.biome.BiomeType; +import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.biome.Biomes; import com.sk89q.worldedit.world.registry.BiomeRegistry; import java.util.HashSet; @@ -55,7 +56,7 @@ public class PlotSetBiome extends Command { checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage()); final HashSet regions = plot.getRegions(); BiomeRegistry biomeRegistry = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBiomeRegistry(); - List knownBiomes = biomeRegistry.getBiomes(); + List knownBiomes = BiomeTypes.values(); final BiomeType biome = Biomes.findBiomeByName(knownBiomes, args[0], biomeRegistry); if (biome == null) { String biomes = StringMan.join(WorldUtil.IMP.getBiomeList(), Captions.BLOCK_LIST_SEPARATER.s()); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/CuboidClipboard.java b/worldedit-core/src/main/java/com/sk89q/worldedit/CuboidClipboard.java index 3df93c3bf..c4e957a05 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/CuboidClipboard.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/CuboidClipboard.java @@ -457,8 +457,8 @@ public class CuboidClipboard { */ public List> getBlockDistribution() { List> distribution = new ArrayList<>(); - List> distr = clipboard.getBlockDistributionWithData(clipboard.getRegion()); - for (Countable item : distr) { + List> distr = clipboard.getBlockDistributionWithData(clipboard.getRegion()); + for (Countable item : distr) { BlockStateHolder state = item.getID(); int[] legacyId = LegacyMapper.getInstance().getLegacyFromBlock(state.toImmutableState()); if (legacyId[0] != 0) distribution.add(new Countable<>(legacyId[0], item.getAmount())); @@ -473,8 +473,8 @@ public class CuboidClipboard { */ public List> getBlockDistributionWithData() { List> distribution = new ArrayList<>(); - List> distr = clipboard.getBlockDistributionWithData(clipboard.getRegion()); - for (Countable item : distr) { + List> distr = clipboard.getBlockDistributionWithData(clipboard.getRegion()); + for (Countable item : distr) { distribution.add(new Countable<>(item.getID().toBaseBlock(), item.getAmount())); } return distribution; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java index 9559d35e1..5d9139ae5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java @@ -38,10 +38,12 @@ import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandPermissions; import com.sk89q.minecraft.util.commands.Step; import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.EmptyClipboardException; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.command.tool.brush.Brush; import com.sk89q.worldedit.command.tool.brush.ButcherBrush; import com.sk89q.worldedit.command.tool.brush.ClipboardBrush; import com.sk89q.worldedit.command.tool.brush.CylinderBrush; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java index 91c4c9684..48aaa4d39 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java @@ -21,6 +21,7 @@ package com.sk89q.worldedit.command; import com.boydti.fawe.config.BBC; import com.sk89q.minecraft.util.commands.Command; +import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandPermissions; import com.sk89q.minecraft.util.commands.Logging; import com.sk89q.worldedit.EditSession; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java index 83780a342..aa448581f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/FlattenedClipboardTransform.java @@ -26,6 +26,7 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.transform.BlockTransformExtent; import com.sk89q.worldedit.function.operation.ForwardExtentCopy; import com.sk89q.worldedit.function.operation.Operation; +import com.sk89q.worldedit.math.MutableVector3; import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.CombinedTransform; @@ -92,12 +93,12 @@ public class FlattenedClipboardTransform { corners[i] = transformAround.apply(corners[i]); } - MutableVector3 newMinimum = new MutableVector3(corners[0]); - MutableVector3 newMaximum = new MutableVector3(corners[0]); + Vector3 newMinimum = corners[0]; + Vector3 newMaximum = corners[0]; for (int i = 1; i < corners.length; i++) { Vector3 cbv = corners[i]; - newMinimum = newMinimum.setComponents(newMinimum.getMinimum(cbv)); - newMaximum = newMaximum.setComponents(newMaximum.getMaximum(cbv)); + newMinimum = newMinimum.getMinimum(cbv); + newMaximum = newMaximum.getMaximum(cbv); } // After transformation, the points may not really sit on a block, diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/NavigationCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/NavigationCommands.java index 91c0c29a3..e9832489e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/NavigationCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/NavigationCommands.java @@ -27,6 +27,7 @@ import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandPermissions; import com.sk89q.minecraft.util.commands.Logging; import com.sk89q.worldedit.LocalConfiguration; +import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.Player; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java index 8e756271b..0b2db093b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java @@ -24,6 +24,7 @@ import com.boydti.fawe.object.brush.InspectBrush; import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandPermissions; +import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java index 3f21e2b13..78bcec914 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java @@ -20,6 +20,7 @@ package com.sk89q.worldedit.command.tool; import com.boydti.fawe.object.collection.BlockVectorSet; +import com.boydti.fawe.object.collection.LocalBlockVectorSet; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; @@ -27,10 +28,6 @@ import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Platform; -import com.sk89q.worldedit.function.mask.BlockMask; -import com.sk89q.worldedit.function.operation.Operations; -import com.sk89q.worldedit.function.pattern.Pattern; -import com.sk89q.worldedit.function.visitor.RecursiveVisitor; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Location; @@ -41,6 +38,7 @@ import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import java.util.HashSet; +import java.util.Iterator; import java.util.LinkedList; import java.util.Set; @@ -71,11 +69,10 @@ public class FloatingTreeRemover implements BlockTool { @Override public boolean actPrimary(Platform server, LocalConfiguration config, - Player player, LocalSession session, Location clicked) { + Player player, LocalSession session, Location clicked) { final World world = (World) clicked.getExtent(); - BlockVector3 pos = clicked.toBlockPoint(); - final BlockState state = world.getBlock(pos); + final BlockState state = world.getBlock(clicked.toVector().toBlockPoint()); if (!isTreeBlock(state.getBlockType())) { player.printError("That's not a tree."); @@ -84,10 +81,20 @@ public class FloatingTreeRemover implements BlockTool { try (EditSession editSession = session.createEditSession(player)) { try { - Pattern replace = BlockTypes.AIR; - RecursiveVisitor visitor = new RecursiveVisitor(new BlockMask(editSession, logs, leaves), replace, 64, editSession); - visitor.visit(pos); - Operations.completeBlindly(visitor); + final Set blockSet = bfs(world, clicked.toVector().toBlockPoint()); + if (blockSet == null) { + player.printError("That's not a floating tree."); + return true; + } + + for (BlockVector3 blockVector : blockSet) { + final BlockState otherState = editSession.getBlock(blockVector); + if (isTreeBlock(otherState.getBlockType())) { + editSession.setBlock(blockVector, BlockTypes.AIR.getDefaultState()); + } + } + } catch (MaxChangedBlocksException e) { + player.printError("Max blocks change limit reached."); } finally { session.remember(editSession); } @@ -97,10 +104,60 @@ public class FloatingTreeRemover implements BlockTool { } private BlockVector3[] recurseDirections = { + Direction.NORTH.toBlockVector(), Direction.EAST.toBlockVector(), Direction.SOUTH.toBlockVector(), Direction.WEST.toBlockVector(), Direction.UP.toBlockVector(), Direction.DOWN.toBlockVector(), }; -} + + /** + * Helper method. + * + * @param world the world that contains the tree + * @param origin any point contained in the floating tree + * @return a set containing all blocks in the tree/shroom or null if this is not a floating tree/shroom. + */ + private Set bfs(World world, BlockVector3 origin) throws MaxChangedBlocksException { + final LocalBlockVectorSet visited = new LocalBlockVectorSet(); + final LocalBlockVectorSet queue = new LocalBlockVectorSet(); + + queue.add(origin); + visited.add(origin); + + while (!queue.isEmpty()) { + Iterator iter = queue.iterator(); + while (iter.hasNext()) { + final BlockVector3 current = iter.next(); + iter.remove(); + for (BlockVector3 recurseDirection : recurseDirections) { + final BlockVector3 next = current.add(recurseDirection); + if (origin.distanceSq(next) > rangeSq) { + // Maximum range exceeded => stop walking + continue; + } + + if (visited.add(next)) { + BlockState state = world.getBlock(next); + if (state.getBlockType().getMaterial().isAir() || state.getBlockType() == BlockTypes.SNOW) { + continue; + } + if (isTreeBlock(state.getBlockType())) { + queue.add(next); + } else { + // we hit something solid - evaluate where we came from + final BlockType currentType = world.getBlock(current).getBlockType(); + if (!BlockCategories.LEAVES.contains(currentType) && currentType != BlockTypes.VINE) { + // log/shroom touching a wall/the ground => this is not a floating tree, bail out + return null; + } + } + } + } + } + } + + return visited; + } +} \ No newline at end of file diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java index b902a39b8..3c45185ef 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java @@ -72,6 +72,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo @Override public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) { + Location pos = getTargetFace(player); try (EditSession eS = session.createEditSession(player)) { BlockVector3 blockPoint = pos.toBlockPoint(); BaseBlock applied = primary.apply(blockPoint); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/QueryTool.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/QueryTool.java index 29d655d08..8ae0302f3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/QueryTool.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/QueryTool.java @@ -48,7 +48,7 @@ public class QueryTool implements BlockTool { BlockVector3 blockPoint = clicked.toBlockPoint(); BaseBlock block = editSession.getFullBlock(blockPoint); - player.print("\u00A79@" + clicked + ": " + "\u00A7e" + player.print("\u00A79@" + blockPoint + ": " + "\u00A7e" + block.getBlockType().getName() + "\u00A77" + " (" + block.toString() + ") " + "\u00A7f" diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/TreePlanter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/TreePlanter.java index 2eafbb4d5..56c44a985 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/TreePlanter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/TreePlanter.java @@ -49,22 +49,24 @@ public class TreePlanter implements BlockTool { public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) { try (EditSession editSession = session.createEditSession(player)) { - boolean successful = false; + try { + boolean successful = false; - for (int i = 0; i < 10; i++) { - if (treeType.generate(editSession, clicked.add(0, 1, 0).toBlockPoint())) { - successful = true; - break; + for (int i = 0; i < 10; i++) { + if (treeType.generate(editSession, clicked.add(0, 1, 0).toBlockPoint())) { + successful = true; + break; + } } + + if (!successful) { + player.printError("A tree can't go there."); + } + } catch (MaxChangedBlocksException e) { + player.printError("Max. blocks changed reached."); + } finally { + session.remember(editSession); } - - if (!successful) { - player.printError("A tree can't go there."); - } - } catch (MaxChangedBlocksException e) { - player.printError("Max. blocks changed reached."); - } finally { - session.remember(editSession); } return true; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java index 0f346352c..ad3ce9674 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java @@ -24,10 +24,12 @@ import com.boydti.fawe.jnbt.JSON2NBT; import com.boydti.fawe.jnbt.NBTException; import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.StringMan; +import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.NotABlockException; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.blocks.MobSpawnerBlock; import com.sk89q.worldedit.blocks.SignBlock; import com.sk89q.worldedit.blocks.SkullBlock; @@ -39,6 +41,7 @@ import com.sk89q.worldedit.extension.input.NoMatchException; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Capability; +import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.extent.inventory.SlottableBlockBag; import com.sk89q.worldedit.internal.registry.InputParser; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java index 41aeab1cb..14ccef8e7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java @@ -204,6 +204,11 @@ public class AbstractDelegateExtent implements LightingExtent { return extent.getNearestSurfaceLayer(x, z, y, minY, maxY); } + @Override + public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) { + return extent.getHighestTerrainBlock(x, z, minY, maxY, filter); + } + @Override public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, boolean ignoreAir) { return extent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, ignoreAir); @@ -219,6 +224,10 @@ public class AbstractDelegateExtent implements LightingExtent { return extent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax); } + public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, Mask mask) { + return extent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, mask); + } + @Override public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, boolean ignoreAir) { return extent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, ignoreAir); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/ChangeSetExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/ChangeSetExtent.java index 284cf044a..f1f68924d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/ChangeSetExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/ChangeSetExtent.java @@ -40,6 +40,7 @@ import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java index 6523ae829..9c2416eb0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java @@ -31,6 +31,8 @@ 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.math.MutableBlockVector3; +import com.sk89q.worldedit.math.MutableVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.registry.state.PropertyGroup; import com.sk89q.worldedit.session.ClipboardHolder; @@ -149,6 +151,17 @@ public interface Extent extends InputExtent, OutputExtent { return minY; } + default int getHighestTerrainBlock(final int x, final int z, int minY, int maxY, Mask filter) { + maxY = Math.min(maxY, Math.max(0, maxY)); + minY = Math.max(0, minY); + for (int y = maxY; y >= minY; --y) { + if (filter.test(MutableBlockVector3.get(x, y, z))) { + return y; + } + } + return minY; + } + default int getNearestSurfaceLayer(int x, int z, int y, int minY, int maxY) { int clearanceAbove = maxY - y; int clearanceBelow = y - minY; @@ -178,10 +191,6 @@ public interface Extent extends InputExtent, OutputExtent { for (int layer = y - clearance - 1; layer >= minY; layer--) { block = getLazyBlock(x, layer, z); if (!block.getBlockType().getMaterial().isMovementBlocker() != state) { - -// int blockHeight = (newHeight) >> 3; -// int layerHeight = (newHeight) & 0x7; - int data = (state ? PropertyGroup.LEVEL.get(block) : data1); return ((layer + offset) << 4) + 0; } @@ -212,6 +221,34 @@ public interface Extent extends InputExtent, OutputExtent { return getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, true); } + default int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, Mask mask) { + y = Math.max(minY, Math.min(maxY, y)); + int clearanceAbove = maxY - y; + int clearanceBelow = y - minY; + int clearance = Math.min(clearanceAbove, clearanceBelow); + boolean state = !mask.test(MutableBlockVector3.get(x, y, z)); + int offset = state ? 0 : 1; + for (int d = 0; d <= clearance; d++) { + int y1 = y + d; + if (mask.test(MutableBlockVector3.get(x, y1, z)) != state) return y1 - offset; + int y2 = y - d; + if (mask.test(MutableBlockVector3.get(x, y2, z)) != state) return y2 + offset; + } + if (clearanceAbove != clearanceBelow) { + if (clearanceAbove < clearanceBelow) { + for (int layer = y - clearance - 1; layer >= minY; layer--) { + if (mask.test(MutableBlockVector3.get(x, layer, z)) != state) return layer + offset; + } + } else { + for (int layer = y + clearance + 1; layer <= maxY; layer++) { + if (mask.test(MutableBlockVector3.get(x, layer, z)) != state) return layer - offset; + } + } + } + int result = state ? failedMin : failedMax; + return result; + } + default int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, boolean ignoreAir) { y = Math.max(minY, Math.min(maxY, y)); int clearanceAbove = maxY - y; 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 4fd83e2da..9e8eaf8b8 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 @@ -23,6 +23,8 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.math.BlockVector2; +import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.math.BlockVector3; 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 7b98adbd0..819329d64 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 @@ -29,6 +29,7 @@ import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockState; import static com.google.common.base.Preconditions.checkNotNull; 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 1aa22a9e5..c25b8fde8 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 @@ -45,6 +45,7 @@ import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.entity.BaseEntity; +import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; @@ -60,6 +61,8 @@ import com.sk89q.worldedit.world.entity.EntityType; import com.sk89q.worldedit.world.entity.EntityTypes; import net.jpountz.lz4.LZ4BlockInputStream; import net.jpountz.lz4.LZ4BlockOutputStream; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.DataInputStream; import java.io.IOException; @@ -70,7 +73,6 @@ import java.util.List; import java.util.Map; import java.util.UUID; import java.util.function.BiConsumer; -import java.util.logging.Logger; import java.util.stream.Collectors; import static com.google.common.base.Preconditions.checkNotNull; @@ -238,7 +240,7 @@ public class SpongeSchematicReader extends NBTSchematicReader { try (FaweInputStream fis = new FaweInputStream(new LZ4BlockInputStream(new FastByteArraysInputStream(biomesOut.toByteArrays())))) { int volume = width * length; for (int index = 0; index < volume; index++) { - fc.setBiome(index, fis.read()); + fc.setBiome(index, BiomeTypes.get(fis.read())); } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java index f3cb35c9b..78efb8a7c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java @@ -44,7 +44,7 @@ public class HeightMap { * @param region the region */ public HeightMap(EditSession session, Region region) { - this(session, region, false); + this(session, region, (Mask) null, false); } public HeightMap(EditSession session, Region region, Mask mask) { @@ -83,7 +83,7 @@ public class HeightMap { BlockVector2 pos = iter.next(); int x = pos.getBlockX(); int z = pos.getBlockZ(); - layer = session.getNearestSurfaceLayer(x, z, (layer + 7) >> 3, 0, maxY, mask); + layer = session.getNearestSurfaceLayer(x, z, (layer + 7) >> 3, 0, maxY); data[(z - bz) * width + (x - bx)] = layer; } } else { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java index 415f92244..9cef04a0e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/EllipsoidRegion.java @@ -129,7 +129,7 @@ public class EllipsoidRegion extends AbstractRegion { @Override public void expand(BlockVector3... changes) throws RegionOperationException { center = center.add(calculateDiff(changes)); - setRadius(radius.add(calculateChanges(changes).toVector3())); + setRadius(radius.add(calculateChanges(changes))); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/ItemRegistry.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/ItemRegistry.java index d129992d4..bc25c7cb1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/ItemRegistry.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/ItemRegistry.java @@ -27,15 +27,6 @@ import java.util.Collections; public interface ItemRegistry { - /** - * Gets the name for the given item. - * - * @param itemType the item - * @return The name, or null if it's unknown - */ - @Nullable - String getName(ItemType itemType); - /** * Register all items */