Switch back to to fastutil lite + tweak ore gen

This commit is contained in:
Jesse Boyd 2017-03-27 06:16:27 +11:00
parent d6ea16f7ef
commit 6ce16714d8
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
15 changed files with 79 additions and 63 deletions

View File

@ -41,7 +41,7 @@ shadowJar {
dependencies { dependencies {
include(dependency('com.github.luben:zstd-jni:1.1.1')) include(dependency('com.github.luben:zstd-jni:1.1.1'))
// include(dependency('org.javassist:javassist:3.22.0-CR1')) // 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(':core'))
} }
archiveName = "${parent.name}-${project.name}-${parent.version}.jar" archiveName = "${parent.name}-${project.name}-${parent.version}.jar"

View File

@ -11,7 +11,7 @@ dependencies {
compile 'org.primesoft:BlocksHub:2.0' compile 'org.primesoft:BlocksHub:2.0'
compile 'com.github.luben:zstd-jni:1.1.1' compile 'com.github.luben:zstd-jni:1.1.1'
// compile 'org.javassist:javassist:3.22.0-CR1' // 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') { compile(group: 'com.sk89q.worldedit', name: 'worldedit-core', version:'6.1.3-SNAPSHOT') {
exclude(module: 'bukkit-classloader-check') exclude(module: 'bukkit-classloader-check')
} }

View File

@ -19,8 +19,6 @@ import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.biome.BaseBiome;
import com.sk89q.worldedit.world.registry.WorldData; 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 it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
@ -34,7 +32,7 @@ public class HeightMapMCAGenerator implements Extent {
private final MutableBlockVector mutable = new MutableBlockVector(); private final MutableBlockVector mutable = new MutableBlockVector();
private final ForkJoinPool pool = new ForkJoinPool(); private final ForkJoinPool pool = new ForkJoinPool();
final Int2ObjectOpenHashMap<Char2CharOpenHashMap> blocks = new Int2ObjectOpenHashMap<>(); final Int2ObjectOpenHashMap<char[][][]> blocks = new Int2ObjectOpenHashMap<>();
private final byte[] heights; private final byte[] heights;
private final byte[] biomes; private final byte[] biomes;
@ -139,16 +137,36 @@ public class HeightMapMCAGenerator implements Extent {
short chunkX = (short) (x >> 4); short chunkX = (short) (x >> 4);
short chunkZ = (short) (z >> 4); short chunkZ = (short) (z >> 4);
int pair = MathMan.pair(chunkX, chunkZ); int pair = MathMan.pair(chunkX, chunkZ);
Char2CharOpenHashMap map = blocks.get(pair); char[][][] map = blocks.get(pair);
if (map == null) { if (map == null) {
map = new Char2CharOpenHashMap(); map = new char[256][][];
blocks.put(pair, map); blocks.put(pair, map);
} }
char blockPair = (char) (((y >> 4) << 12) + (x & 15) + ((z & 15) << 4) + ((y & 15) << 8)); char[][] yMap = map[y];
map.put(blockPair, combined != 0 ? combined : 1); 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; 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 @Override
public BaseBiome getBiome(Vector2D position) { public BaseBiome getBiome(Vector2D position) {
int index = position.getBlockZ() * width + position.getBlockX(); int index = position.getBlockZ() * width + position.getBlockX();
@ -179,10 +197,9 @@ public class HeightMapMCAGenerator implements Extent {
short chunkX = (short) (x >> 4); short chunkX = (short) (x >> 4);
short chunkZ = (short) (z >> 4); short chunkZ = (short) (z >> 4);
int pair = MathMan.pair(chunkX, chunkZ); int pair = MathMan.pair(chunkX, chunkZ);
Char2CharOpenHashMap map = blocks.get(pair); char[][][] map = blocks.get(pair);
if (map != null) { if (map != null) {
char blockPair = (char)(((y >> 4) << 12) + (x & 15) + ((z & 15) << 4) + ((y & 15) << 8)); char combined = get(map, x, y, z);
char combined = map.get(blockPair);
if (combined != 0) { if (combined != 0) {
return FaweCache.CACHE_BLOCK[combined]; return FaweCache.CACHE_BLOCK[combined];
} }
@ -196,10 +213,9 @@ public class HeightMapMCAGenerator implements Extent {
short chunkX = (short) (x >> 4); short chunkX = (short) (x >> 4);
short chunkZ = (short) (z >> 4); short chunkZ = (short) (z >> 4);
int pair = MathMan.pair(chunkX, chunkZ); int pair = MathMan.pair(chunkX, chunkZ);
Char2CharOpenHashMap map = blocks.get(pair); char[][][] map = blocks.get(pair);
if (map != null) { if (map != null) {
char blockPair = (char)(((y >> 4) << 12) + (x & 15) + ((z & 15) << 4) + ((y & 15) << 8)); char combined = get(map, x, y, z);
char combined = map.get(blockPair);
if (combined != 0) { if (combined != 0) {
return FaweCache.CACHE_BLOCK[combined]; return FaweCache.CACHE_BLOCK[combined];
} }
@ -702,7 +718,7 @@ public class HeightMapMCAGenerator implements Extent {
final int fcx = cx; final int fcx = cx;
final int fcz = cz; final int fcz = cz;
int chunkPair = MathMan.pair((short) cx, (short) 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() { pool.submit(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -845,32 +861,41 @@ public class HeightMapMCAGenerator implements Extent {
} }
} }
} }
if (localBlocks != null && !localBlocks.isEmpty()) { if (localBlocks != null) {
for (Char2CharMap.Entry entry : localBlocks.char2CharEntrySet()) { for (int layer = 0; layer < 16; layer++) {
char key = entry.getCharKey(); int by = layer << 4;
char combined = entry.getCharValue(); int ty = by + 15;
byte id = (byte) FaweCache.getId(combined); index = 0;
for (int y = by; y <= ty; y++, index += 256) {
int and = key & 4095; char[][] yBlocks = localBlocks[y];
int y = ((key >> 12) << 4) + (and >> 8); if (yBlocks != null) {
int x = and & 0xF; if (chunk.ids[layer] == null) {
int z = (and >> 4) & 0xF; chunk.ids[layer] = new byte[4096];
int layer = key >> 12; chunk.data[layer] = new byte[2048];
int localIndex = key & 4095; chunk.skyLight[layer] = new byte[2048];
if (!FaweCache.hasData(id)) { chunk.blockLight[layer] = new byte[2048];
if (chunk.ids[layer] == null) { }
chunk.ids[layer] = new byte[4096]; byte[] idsLayer = chunk.ids[layer];
chunk.data[layer] = new byte[2048]; byte[] dataLayer = chunk.data[layer];
chunk.skyLight[layer] = new byte[2048]; for (int z = 0; z < yBlocks.length; z++) {
chunk.blockLight[layer] = new byte[2048]; 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); chunk.setLoc(null, fcx, fcz);
byte[] bytes = chunk.toBytes(byteStore1.get()); byte[] bytes = chunk.toBytes(byteStore1.get());

View File

@ -467,21 +467,12 @@ public class MCAChunk extends FaweChunk<Void> {
} }
} }
public void setIdUnsafe(int layer, int index, byte id) { public void setIdUnsafe(byte[] idsLayer, int index, byte id) {
byte[] idsLayer = ids[layer];
idsLayer[index] = id; idsLayer[index] = id;
} }
public void setBlockUnsafe(int layer, int index, byte id, int data) { public void setBlockUnsafe(byte[] idsLayer, byte[] dataLayer, 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];
}
idsLayer[index] = id; idsLayer[index] = id;
byte[] dataLayer = this.data[layer];
setNibble(index, dataLayer, data); setNibble(index, dataLayer, data);
} }

View File

@ -175,11 +175,11 @@ public interface Extent extends InputExtent, OutputExtent {
} }
default public void addOres(Region region, Mask mask) throws WorldEditException { 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.DIRT), 20, 4, 100, 0, 255);
addOre(region, mask, new BlockPattern(BlockID.GRAVEL), 20, 1, 100, 0, 255); addOre(region, mask, new BlockPattern(BlockID.GRAVEL), 20, 2, 100, 0, 255);
addOre(region, mask, new BlockPattern(BlockID.STONE, 1), 20, 2, 100, 0, 79); addOre(region, mask, new BlockPattern(BlockID.STONE, 1), 20, 4, 100, 0, 79);
addOre(region, mask, new BlockPattern(BlockID.STONE, 3), 20, 2, 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, 2, 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.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.IRON_ORE), 9, 20, 100, 0, 63);
addOre(region, mask, new BlockPattern(BlockID.GOLD_ORE), 9, 2, 100, 0, 31); addOre(region, mask, new BlockPattern(BlockID.GOLD_ORE), 9, 2, 100, 0, 31);

View File

@ -59,7 +59,7 @@ shadowJar {
dependencies { dependencies {
include(dependency('com.github.luben:zstd-jni:1.1.1')) include(dependency('com.github.luben:zstd-jni:1.1.1'))
// include(dependency('org.javassist:javassist:3.22.0-CR1')) // 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(':core'))
include(dependency('org.yaml:snakeyaml:1.16')) include(dependency('org.yaml:snakeyaml:1.16'))
} }

View File

@ -59,7 +59,7 @@ shadowJar {
dependencies { dependencies {
include(dependency('com.github.luben:zstd-jni:1.1.1')) include(dependency('com.github.luben:zstd-jni:1.1.1'))
// include(dependency('org.javassist:javassist:3.22.0-CR1')) // 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(':core'))
include(dependency('org.yaml:snakeyaml:1.16')) include(dependency('org.yaml:snakeyaml:1.16'))
} }

View File

@ -50,7 +50,7 @@ shadowJar {
dependencies { dependencies {
include(dependency('com.github.luben:zstd-jni:1.1.1')) include(dependency('com.github.luben:zstd-jni:1.1.1'))
// include(dependency('org.javassist:javassist:3.22.0-CR1')) // 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(':core'))
include(dependency('org.yaml:snakeyaml:1.16')) include(dependency('org.yaml:snakeyaml:1.16'))
} }

View File

@ -59,7 +59,7 @@ shadowJar {
dependencies { dependencies {
include(dependency('com.github.luben:zstd-jni:1.1.1')) include(dependency('com.github.luben:zstd-jni:1.1.1'))
// include(dependency('org.javassist:javassist:3.22.0-CR1')) // 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(':core'))
include(dependency('org.yaml:snakeyaml:1.16')) include(dependency('org.yaml:snakeyaml:1.16'))
} }

View File

@ -58,7 +58,7 @@ shadowJar {
dependencies { dependencies {
include(dependency('com.github.luben:zstd-jni:1.1.1')) include(dependency('com.github.luben:zstd-jni:1.1.1'))
// include(dependency('org.javassist:javassist:3.22.0-CR1')) // 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(':core'))
include(dependency('org.yaml:snakeyaml:1.16')) include(dependency('org.yaml:snakeyaml:1.16'))
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

View File

@ -24,7 +24,7 @@ shadowJar {
dependencies { dependencies {
include(dependency('com.github.luben:zstd-jni:1.1.1')) include(dependency('com.github.luben:zstd-jni:1.1.1'))
// include(dependency('org.javassist:javassist:3.22.0-CR1')) // 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(name: 'worldedit-core-6.1.4-SNAPSHOT-dist'))
include(dependency('com.google.code.gson:gson:2.2.4')) include(dependency('com.google.code.gson:gson:2.2.4'))
include(dependency('org.yaml:snakeyaml:1.16')) include(dependency('org.yaml:snakeyaml:1.16'))

Binary file not shown.

View File

@ -1,3 +1,3 @@
rootProject.name = 'FastAsyncWorldEdit' rootProject.name = 'FastAsyncWorldEdit'
include 'core', 'bukkit'//, 'favs', 'nukkit', 'sponge', 'forge1710', 'forge189', 'forge194', 'forge110', 'forge111' include 'core', 'bukkit' , 'favs', 'nukkit', 'sponge', 'forge1710', 'forge189', 'forge194', 'forge110', 'forge111'

View File

@ -77,7 +77,7 @@ shadowJar {
include(dependency(':core')) include(dependency(':core'))
include(dependency('com.github.luben:zstd-jni:1.1.1')) include(dependency('com.github.luben:zstd-jni:1.1.1'))
// include(dependency('org.javassist:javassist:3.22.0-CR1')) // 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(name: 'worldedit-core-6.1.7-SNAPSHOT-dist'))
include(dependency('com.sk89q.worldedit:worldedit-sponge:6.1.7-SNAPSHOT')) include(dependency('com.sk89q.worldedit:worldedit-sponge:6.1.7-SNAPSHOT'))
include(dependency('org.yaml:snakeyaml:1.16')) include(dependency('org.yaml:snakeyaml:1.16'))