From ae39f7bba35ec7f346eb5c3b328fa4425471f925 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Fri, 11 Dec 2020 16:13:09 +0000 Subject: [PATCH] use full chunks for distr and account for __RESERVED__ blocks fixes #759 --- .../fawe/beta/implementation/filter/DistrFilter.java | 6 +++++- .../implementation/queue/ParallelQueueExtent.java | 4 ++-- .../main/java/com/sk89q/worldedit/extent/Extent.java | 11 +++++++++++ .../com/sk89q/worldedit/extent/PassthroughExtent.java | 1 - 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/DistrFilter.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/DistrFilter.java index 38494b82e..936ccbd82 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/DistrFilter.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/filter/DistrFilter.java @@ -40,7 +40,11 @@ public class DistrFilter extends ForkedFilter { @Override public final void applyBlock(FilterBlock block) { - counter[block.getOrdinal()]++; + int ordinal = block.getOrdinal(); + if (ordinal == 0) { + ordinal = 1; + } + counter[ordinal]++; } public int getTotal(ABlockMask mask) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/ParallelQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/ParallelQueueExtent.java index e558e2cea..0314c1b6e 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/ParallelQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/ParallelQueueExtent.java @@ -178,12 +178,12 @@ public class ParallelQueueExtent extends PassthroughExtent implements IQueueWrap @Override public List> getBlockDistributionWithData(Region region) { - return apply(region, new DistrFilter(), false).getDistribution(); + return apply(region, new DistrFilter(), true).getDistribution(); } @Override public List> getBlockDistribution(Region region) { - return apply(region, new DistrFilter(), false).getTypeDistribution(); + return apply(region, new DistrFilter(), true).getTypeDistribution(); } /** 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 1c9348fa9..f16a67d5b 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 @@ -421,6 +421,10 @@ public interface Extent extends InputExtent, OutputExtent { for (final BlockVector3 pt : region) { BlockType type = getBlock(pt).getBlockType(); + if (type == BlockTypes.__RESERVED__) { + counter[1]++; + continue; + } counter[type.getInternalId()]++; } List> distribution = new ArrayList<>(); @@ -446,6 +450,13 @@ public interface Extent extends InputExtent, OutputExtent { for (final BlockVector3 pt : region) { BlockState blk = this.getBlock(pt); BlockType type = blk.getBlockType(); + if (type == BlockTypes.__RESERVED__) { + int[] stateCounter = counter[1]; + if (stateCounter == null) { + counter[1] = stateCounter = new int[BlockTypes.AIR.getMaxStateId() + 1]; + } + stateCounter[BlockTypes.AIR.getDefaultState().getInternalPropertiesId()]++; + } int[] stateCounter = counter[type.getInternalId()]; if (stateCounter == null) { counter[type.getInternalId()] = stateCounter = new int[type.getMaxStateId() + 1]; 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 73b6f9b37..1f3cee85e 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 @@ -22,7 +22,6 @@ import com.sk89q.worldedit.world.block.BlockType; import java.util.List; import java.util.Set; -import java.util.UUID; import javax.annotation.Nullable; public class PassthroughExtent extends AbstractDelegateExtent {