From 465c81d193ceeb7a2568677e76903bc611c1d4a3 Mon Sep 17 00:00:00 2001 From: Jordan Date: Fri, 18 Mar 2022 21:28:25 +0000 Subject: [PATCH] Remove hardcoding of heightmap compressed long size (#1668) --- .../adapter/impl/fawe/v1_17_R1_2/PaperweightGetBlocks.java | 4 +++- .../adapter/impl/fawe/v1_18_R1/PaperweightGetBlocks.java | 4 +++- .../adapter/impl/fawe/v1_18_R2/PaperweightGetBlocks.java | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightGetBlocks.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightGetBlocks.java index 446cb81d3..6c2e77c7d 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightGetBlocks.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightGetBlocks.java @@ -11,6 +11,7 @@ import com.fastasyncworldedit.core.queue.IChunkGet; import com.fastasyncworldedit.core.queue.IChunkSet; import com.fastasyncworldedit.core.queue.implementation.QueueHandler; import com.fastasyncworldedit.core.queue.implementation.blocks.CharGetBlocks; +import com.fastasyncworldedit.core.util.MathMan; import com.fastasyncworldedit.core.util.collection.AdaptedMap; import com.google.common.base.Suppliers; import com.google.common.collect.Iterables; @@ -173,7 +174,8 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc @Override public void setHeightmapToGet(HeightMapType type, int[] data) { - BitArrayUnstretched bitArray = new BitArrayUnstretched(9, 256); + // height + 1 to match server internal + BitArrayUnstretched bitArray = new BitArrayUnstretched(MathMan.log2nlz(getChunk().getHeight() + 1), 256); bitArray.fromRaw(data); Heightmap.Types nativeType = Heightmap.Types.valueOf(type.name()); Heightmap heightMap = getChunk().heightmaps.get(nativeType); diff --git a/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightGetBlocks.java b/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightGetBlocks.java index 33e72f39e..ca1882d8d 100644 --- a/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightGetBlocks.java +++ b/worldedit-bukkit/adapters/adapter-1_18/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R1/PaperweightGetBlocks.java @@ -11,6 +11,7 @@ import com.fastasyncworldedit.core.queue.IChunkGet; import com.fastasyncworldedit.core.queue.IChunkSet; import com.fastasyncworldedit.core.queue.implementation.QueueHandler; import com.fastasyncworldedit.core.queue.implementation.blocks.CharGetBlocks; +import com.fastasyncworldedit.core.util.MathMan; import com.fastasyncworldedit.core.util.collection.AdaptedMap; import com.google.common.base.Suppliers; import com.google.common.collect.Iterables; @@ -175,7 +176,8 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc @Override public void setHeightmapToGet(HeightMapType type, int[] data) { - BitArrayUnstretched bitArray = new BitArrayUnstretched(9, 256); + // height + 1 to match server internal + BitArrayUnstretched bitArray = new BitArrayUnstretched(MathMan.log2nlz(getChunk().getHeight() + 1), 256); bitArray.fromRaw(data); Heightmap.Types nativeType = Heightmap.Types.valueOf(type.name()); Heightmap heightMap = getChunk().heightmaps.get(nativeType); diff --git a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightGetBlocks.java b/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightGetBlocks.java index a9a893538..6c381231b 100644 --- a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightGetBlocks.java +++ b/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightGetBlocks.java @@ -11,6 +11,7 @@ import com.fastasyncworldedit.core.queue.IChunkGet; import com.fastasyncworldedit.core.queue.IChunkSet; import com.fastasyncworldedit.core.queue.implementation.QueueHandler; import com.fastasyncworldedit.core.queue.implementation.blocks.CharGetBlocks; +import com.fastasyncworldedit.core.util.MathMan; import com.fastasyncworldedit.core.util.collection.AdaptedMap; import com.google.common.base.Suppliers; import com.google.common.collect.Iterables; @@ -178,7 +179,8 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc @Override public void setHeightmapToGet(HeightMapType type, int[] data) { - BitArrayUnstretched bitArray = new BitArrayUnstretched(9, 256); + // height + 1 to match server internal + BitArrayUnstretched bitArray = new BitArrayUnstretched(MathMan.log2nlz(getChunk().getHeight() + 1), 256); bitArray.fromRaw(data); Heightmap.Types nativeType = Heightmap.Types.valueOf(type.name()); Heightmap heightMap = getChunk().heightmaps.get(nativeType);