diff --git a/bukkit/build.gradle b/bukkit/build.gradle index 034b6f55..1f5463eb 100644 --- a/bukkit/build.gradle +++ b/bukkit/build.gradle @@ -41,7 +41,7 @@ shadowJar { dependencies { include(dependency('com.github.luben:zstd-jni:1.1.1')) // include(dependency('org.javassist:javassist:3.22.0-CR1')) - include(dependency('it.unimi.dsi:fastutil:6.5.1')) + include(dependency('co.aikar:fastutil-lite:1.0')) include(dependency(':core')) } archiveName = "${parent.name}-${project.name}-${parent.version}.jar" diff --git a/core/build.gradle b/core/build.gradle index 7783633a..834dc4fd 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -11,7 +11,7 @@ dependencies { compile 'org.primesoft:BlocksHub:2.0' compile 'com.github.luben:zstd-jni:1.1.1' // compile 'org.javassist:javassist:3.22.0-CR1' - compile 'it.unimi.dsi:fastutil:6.5.1' + compile 'co.aikar:fastutil-lite:1.0' compile(group: 'com.sk89q.worldedit', name: 'worldedit-core', version:'6.1.3-SNAPSHOT') { exclude(module: 'bukkit-classloader-check') } diff --git a/core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java b/core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java index 8fbd82ac..25cd2a55 100644 --- a/core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java +++ b/core/src/main/java/com/boydti/fawe/jnbt/anvil/HeightMapMCAGenerator.java @@ -19,8 +19,6 @@ import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.registry.WorldData; -import it.unimi.dsi.fastutil.chars.Char2CharMap; -import it.unimi.dsi.fastutil.chars.Char2CharOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import java.awt.image.BufferedImage; import java.io.File; @@ -34,7 +32,7 @@ public class HeightMapMCAGenerator implements Extent { private final MutableBlockVector mutable = new MutableBlockVector(); private final ForkJoinPool pool = new ForkJoinPool(); - final Int2ObjectOpenHashMap blocks = new Int2ObjectOpenHashMap<>(); + final Int2ObjectOpenHashMap blocks = new Int2ObjectOpenHashMap<>(); private final byte[] heights; private final byte[] biomes; @@ -139,16 +137,36 @@ public class HeightMapMCAGenerator implements Extent { short chunkX = (short) (x >> 4); short chunkZ = (short) (z >> 4); int pair = MathMan.pair(chunkX, chunkZ); - Char2CharOpenHashMap map = blocks.get(pair); + char[][][] map = blocks.get(pair); if (map == null) { - map = new Char2CharOpenHashMap(); + map = new char[256][][]; blocks.put(pair, map); } - char blockPair = (char) (((y >> 4) << 12) + (x & 15) + ((z & 15) << 4) + ((y & 15) << 8)); - map.put(blockPair, combined != 0 ? combined : 1); + char[][] yMap = map[y]; + if (yMap == null) { + map[y] = yMap = new char[16][]; + } + z = z & 15; + char[] zMap = yMap[z]; + if (zMap == null) { + yMap[z] = zMap = new char[16]; + } + zMap[x & 15] = combined != 0 ? combined : 1; return true; } + private char get(char[][][] map, int x, int y, int z) { + char[][] yMap = map[y]; + if (yMap == null) { + return 0; + } + char[] zMap = yMap[z & 15]; + if (zMap == null) { + return 0; + } + return zMap[x & 15]; + } + @Override public BaseBiome getBiome(Vector2D position) { int index = position.getBlockZ() * width + position.getBlockX(); @@ -179,10 +197,9 @@ public class HeightMapMCAGenerator implements Extent { short chunkX = (short) (x >> 4); short chunkZ = (short) (z >> 4); int pair = MathMan.pair(chunkX, chunkZ); - Char2CharOpenHashMap map = blocks.get(pair); + char[][][] map = blocks.get(pair); if (map != null) { - char blockPair = (char)(((y >> 4) << 12) + (x & 15) + ((z & 15) << 4) + ((y & 15) << 8)); - char combined = map.get(blockPair); + char combined = get(map, x, y, z); if (combined != 0) { return FaweCache.CACHE_BLOCK[combined]; } @@ -196,10 +213,9 @@ public class HeightMapMCAGenerator implements Extent { short chunkX = (short) (x >> 4); short chunkZ = (short) (z >> 4); int pair = MathMan.pair(chunkX, chunkZ); - Char2CharOpenHashMap map = blocks.get(pair); + char[][][] map = blocks.get(pair); if (map != null) { - char blockPair = (char)(((y >> 4) << 12) + (x & 15) + ((z & 15) << 4) + ((y & 15) << 8)); - char combined = map.get(blockPair); + char combined = get(map, x, y, z); if (combined != 0) { return FaweCache.CACHE_BLOCK[combined]; } @@ -702,7 +718,7 @@ public class HeightMapMCAGenerator implements Extent { final int fcx = cx; final int fcz = cz; int chunkPair = MathMan.pair((short) cx, (short) cz); - final Char2CharOpenHashMap localBlocks = blocks.get(chunkPair); + final char[][][] localBlocks = blocks.get(chunkPair); pool.submit(new Runnable() { @Override public void run() { @@ -845,32 +861,41 @@ public class HeightMapMCAGenerator implements Extent { } } } - if (localBlocks != null && !localBlocks.isEmpty()) { - for (Char2CharMap.Entry entry : localBlocks.char2CharEntrySet()) { - char key = entry.getCharKey(); - char combined = entry.getCharValue(); - byte id = (byte) FaweCache.getId(combined); - - int and = key & 4095; - int y = ((key >> 12) << 4) + (and >> 8); - int x = and & 0xF; - int z = (and >> 4) & 0xF; - int layer = key >> 12; - int localIndex = key & 4095; - if (!FaweCache.hasData(id)) { - if (chunk.ids[layer] == null) { - chunk.ids[layer] = new byte[4096]; - chunk.data[layer] = new byte[2048]; - chunk.skyLight[layer] = new byte[2048]; - chunk.blockLight[layer] = new byte[2048]; + if (localBlocks != null) { + for (int layer = 0; layer < 16; layer++) { + int by = layer << 4; + int ty = by + 15; + index = 0; + for (int y = by; y <= ty; y++, index += 256) { + char[][] yBlocks = localBlocks[y]; + if (yBlocks != null) { + if (chunk.ids[layer] == null) { + chunk.ids[layer] = new byte[4096]; + chunk.data[layer] = new byte[2048]; + chunk.skyLight[layer] = new byte[2048]; + chunk.blockLight[layer] = new byte[2048]; + } + byte[] idsLayer = chunk.ids[layer]; + byte[] dataLayer = chunk.data[layer]; + for (int z = 0; z < yBlocks.length; z++) { + char[] zBlocks = yBlocks[z]; + if (zBlocks != null) { + int zIndex = index + (z << 4); + for (int x = 0; x < zBlocks.length; x++, zIndex++) { + char combined = zBlocks[x]; + if (combined == 0) continue; + int id = FaweCache.getId(combined); + if (!FaweCache.hasData(id)) { + chunk.setIdUnsafe(idsLayer, zIndex, (byte) id); + } else { + chunk.setBlockUnsafe(idsLayer, dataLayer, zIndex, (byte) id, FaweCache.getData(combined)); + } + } + } + } } - chunk.setIdUnsafe(layer, localIndex, id); - } else { - int data = FaweCache.getData(combined); - chunk.setBlockUnsafe(layer, localIndex, id, data); } } - } chunk.setLoc(null, fcx, fcz); byte[] bytes = chunk.toBytes(byteStore1.get()); diff --git a/core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java b/core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java index 95eaff34..dfdab809 100644 --- a/core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java +++ b/core/src/main/java/com/boydti/fawe/jnbt/anvil/MCAChunk.java @@ -467,21 +467,12 @@ public class MCAChunk extends FaweChunk { } } - public void setIdUnsafe(int layer, int index, byte id) { - byte[] idsLayer = ids[layer]; + public void setIdUnsafe(byte[] idsLayer, int index, byte id) { idsLayer[index] = id; } - public void setBlockUnsafe(int layer, int index, byte id, int data) { - byte[] idsLayer = ids[layer]; - if (idsLayer == null) { - idsLayer = this.ids[layer] = new byte[4096]; - this.data[layer] = new byte[2048]; - this.skyLight[layer] = new byte[2048]; - this.blockLight[layer] = new byte[2048]; - } + public void setBlockUnsafe(byte[] idsLayer, byte[] dataLayer, int index, byte id, int data) { idsLayer[index] = id; - byte[] dataLayer = this.data[layer]; setNibble(index, dataLayer, data); } diff --git a/core/src/main/java/com/sk89q/worldedit/extent/Extent.java b/core/src/main/java/com/sk89q/worldedit/extent/Extent.java index 3a3773c9..27aca12c 100644 --- a/core/src/main/java/com/sk89q/worldedit/extent/Extent.java +++ b/core/src/main/java/com/sk89q/worldedit/extent/Extent.java @@ -175,11 +175,11 @@ public interface Extent extends InputExtent, OutputExtent { } default public void addOres(Region region, Mask mask) throws WorldEditException { - addOre(region, mask, new BlockPattern(BlockID.DIRT), 20, 2, 100, 0, 255); - addOre(region, mask, new BlockPattern(BlockID.GRAVEL), 20, 1, 100, 0, 255); - addOre(region, mask, new BlockPattern(BlockID.STONE, 1), 20, 2, 100, 0, 79); - addOre(region, mask, new BlockPattern(BlockID.STONE, 3), 20, 2, 100, 0, 79); - addOre(region, mask, new BlockPattern(BlockID.STONE, 5), 20, 2, 100, 0, 79); + addOre(region, mask, new BlockPattern(BlockID.DIRT), 20, 4, 100, 0, 255); + addOre(region, mask, new BlockPattern(BlockID.GRAVEL), 20, 2, 100, 0, 255); + addOre(region, mask, new BlockPattern(BlockID.STONE, 1), 20, 4, 100, 0, 79); + addOre(region, mask, new BlockPattern(BlockID.STONE, 3), 20, 4, 100, 0, 79); + addOre(region, mask, new BlockPattern(BlockID.STONE, 5), 20, 4, 100, 0, 79); addOre(region, mask, new BlockPattern(BlockID.COAL_ORE), 17, 20, 100, 0, 127); addOre(region, mask, new BlockPattern(BlockID.IRON_ORE), 9, 20, 100, 0, 63); addOre(region, mask, new BlockPattern(BlockID.GOLD_ORE), 9, 2, 100, 0, 31); diff --git a/forge110/build.gradle b/forge110/build.gradle index 99fd736e..2c4c16df 100644 --- a/forge110/build.gradle +++ b/forge110/build.gradle @@ -59,7 +59,7 @@ shadowJar { dependencies { include(dependency('com.github.luben:zstd-jni:1.1.1')) // include(dependency('org.javassist:javassist:3.22.0-CR1')) - include(dependency('it.unimi.dsi:fastutil:6.5.1')) + include(dependency('co.aikar:fastutil-lite:1.0')) include(dependency(':core')) include(dependency('org.yaml:snakeyaml:1.16')) } diff --git a/forge111/build.gradle b/forge111/build.gradle index e38e0cc6..282aa6a0 100644 --- a/forge111/build.gradle +++ b/forge111/build.gradle @@ -59,7 +59,7 @@ shadowJar { dependencies { include(dependency('com.github.luben:zstd-jni:1.1.1')) // include(dependency('org.javassist:javassist:3.22.0-CR1')) - include(dependency('it.unimi.dsi:fastutil:6.5.1')) + include(dependency('co.aikar:fastutil-lite:1.0')) include(dependency(':core')) include(dependency('org.yaml:snakeyaml:1.16')) } diff --git a/forge1710/build.gradle b/forge1710/build.gradle index 9d90f76c..d78d5077 100644 --- a/forge1710/build.gradle +++ b/forge1710/build.gradle @@ -50,7 +50,7 @@ shadowJar { dependencies { include(dependency('com.github.luben:zstd-jni:1.1.1')) // include(dependency('org.javassist:javassist:3.22.0-CR1')) - include(dependency('it.unimi.dsi:fastutil:6.5.1')) + include(dependency('co.aikar:fastutil-lite:1.0')) include(dependency(':core')) include(dependency('org.yaml:snakeyaml:1.16')) } diff --git a/forge189/build.gradle b/forge189/build.gradle index 48dd6197..73c0173c 100644 --- a/forge189/build.gradle +++ b/forge189/build.gradle @@ -59,7 +59,7 @@ shadowJar { dependencies { include(dependency('com.github.luben:zstd-jni:1.1.1')) // include(dependency('org.javassist:javassist:3.22.0-CR1')) - include(dependency('it.unimi.dsi:fastutil:6.5.1')) + include(dependency('co.aikar:fastutil-lite:1.0')) include(dependency(':core')) include(dependency('org.yaml:snakeyaml:1.16')) } diff --git a/forge194/build.gradle b/forge194/build.gradle index d01313a9..01f48520 100644 --- a/forge194/build.gradle +++ b/forge194/build.gradle @@ -58,7 +58,7 @@ shadowJar { dependencies { include(dependency('com.github.luben:zstd-jni:1.1.1')) // include(dependency('org.javassist:javassist:3.22.0-CR1')) - include(dependency('it.unimi.dsi:fastutil:6.5.1')) + include(dependency('co.aikar:fastutil-lite:1.0')) include(dependency(':core')) include(dependency('org.yaml:snakeyaml:1.16')) } diff --git a/heightmap.png b/heightmap.png deleted file mode 100644 index 930f9e91..00000000 Binary files a/heightmap.png and /dev/null differ diff --git a/nukkit/build.gradle b/nukkit/build.gradle index 4afa28ba..50de8775 100644 --- a/nukkit/build.gradle +++ b/nukkit/build.gradle @@ -24,7 +24,7 @@ shadowJar { dependencies { include(dependency('com.github.luben:zstd-jni:1.1.1')) // include(dependency('org.javassist:javassist:3.22.0-CR1')) - include(dependency('it.unimi.dsi:fastutil:6.5.1')) + include(dependency('co.aikar:fastutil-lite:1.0')) include(dependency(name: 'worldedit-core-6.1.4-SNAPSHOT-dist')) include(dependency('com.google.code.gson:gson:2.2.4')) include(dependency('org.yaml:snakeyaml:1.16')) diff --git a/region/r.0.-1.mca b/region/r.0.-1.mca deleted file mode 100644 index 5381555c..00000000 Binary files a/region/r.0.-1.mca and /dev/null differ diff --git a/settings.gradle b/settings.gradle index 09d30257..6e956331 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,3 @@ rootProject.name = 'FastAsyncWorldEdit' -include 'core', 'bukkit'//, 'favs', 'nukkit', 'sponge', 'forge1710', 'forge189', 'forge194', 'forge110', 'forge111' \ No newline at end of file +include 'core', 'bukkit' , 'favs', 'nukkit', 'sponge', 'forge1710', 'forge189', 'forge194', 'forge110', 'forge111' \ No newline at end of file diff --git a/sponge/build.gradle b/sponge/build.gradle index 1a54380d..745aa077 100644 --- a/sponge/build.gradle +++ b/sponge/build.gradle @@ -77,7 +77,7 @@ shadowJar { include(dependency(':core')) include(dependency('com.github.luben:zstd-jni:1.1.1')) // include(dependency('org.javassist:javassist:3.22.0-CR1')) - include(dependency('it.unimi.dsi:fastutil:6.5.1')) + include(dependency('co.aikar:fastutil-lite:1.0')) include(dependency(name: 'worldedit-core-6.1.7-SNAPSHOT-dist')) include(dependency('com.sk89q.worldedit:worldedit-sponge:6.1.7-SNAPSHOT')) include(dependency('org.yaml:snakeyaml:1.16'))