mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-12-28 03:57:38 +01:00
Switch back to to fastutil lite + tweak ore gen
This commit is contained in:
parent
d6ea16f7ef
commit
6ce16714d8
@ -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"
|
||||
|
@ -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')
|
||||
}
|
||||
|
@ -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<Char2CharOpenHashMap> blocks = new Int2ObjectOpenHashMap<>();
|
||||
final Int2ObjectOpenHashMap<char[][][]> 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());
|
||||
|
@ -467,21 +467,12 @@ public class MCAChunk extends FaweChunk<Void> {
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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'))
|
||||
}
|
||||
|
@ -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'))
|
||||
}
|
||||
|
@ -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'))
|
||||
}
|
||||
|
@ -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'))
|
||||
}
|
||||
|
@ -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'))
|
||||
}
|
||||
|
BIN
heightmap.png
BIN
heightmap.png
Binary file not shown.
Before Width: | Height: | Size: 1.2 MiB |
@ -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'))
|
||||
|
Binary file not shown.
@ -1,3 +1,3 @@
|
||||
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'
|
@ -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'))
|
||||
|
Loading…
Reference in New Issue
Block a user