Use Faster XoRoShiRo128PlusRandom

XoRoShiRo128PlusRandom is a Faster Random Class that is many times faster than standard Java Random. It also features better random distribution and the ability to be split and retain the exact same noise output like Splitable random.

http://dsiutils.di.unimi.it/docs/it/unimi/dsi/util/XoRoShiRo128PlusRandom.html
This commit is contained in:
Bud Gidiere
2020-11-19 17:23:08 -06:00
parent 700d1d0a6c
commit 094b421f97
15 changed files with 35 additions and 18 deletions

View File

@@ -4,6 +4,7 @@ import com.dfsek.terra.procgen.GridSpawn;
import com.dfsek.terra.procgen.voxel.DeformedSphere;
import com.dfsek.terra.procgen.voxel.Tube;
import com.dfsek.terra.procgen.voxel.VoxelGeometry;
import it.unimi.dsi.util.XoRoShiRo128PlusRandom;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.util.Vector;
@@ -23,7 +24,7 @@ public class Cavern {
public VoxelGeometry carveChunk(int chunkX, int chunkZ) {
long seedC = MathUtil.getCarverChunkSeed(chunkX, chunkZ, seed);
Random chunk = new Random(seedC);
Random chunk = new XoRoShiRo128PlusRandom(seedC);
Vector org = node.getNodeLocation((chunkX << 4) + 8, (chunkZ << 4) + 8).clone().setY(chunk.nextInt(128));
VoxelGeometry carve = VoxelGeometry.getBlank();
@@ -33,7 +34,7 @@ public class Cavern {
Bukkit.getLogger().info("Cavern: " + org.toString());
carve.merge(new DeformedSphere(org.clone(), chunk.nextInt(4) + 3, 0.75, smpl));
Vector _00 = new Vector(org.getX() + 16, new Random(MathUtil.getCarverChunkSeed(chunkX + 1, chunkZ, seed)).nextInt(128), org.getZ());
Vector _00 = new Vector(org.getX() + 16, new XoRoShiRo128PlusRandom(MathUtil.getCarverChunkSeed(chunkX + 1, chunkZ, seed)).nextInt(128), org.getZ());
carve.merge(new Tube(org, _00, 4));
return carve;