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

@@ -3,6 +3,7 @@ package com.dfsek.terra.carving;
import com.dfsek.terra.TerraWorld;
import com.dfsek.terra.biome.UserDefinedBiome;
import com.dfsek.terra.config.base.ConfigPack;
import it.unimi.dsi.util.XoRoShiRo128PlusRandom;
import org.apache.commons.math3.util.FastMath;
import org.bukkit.World;
import org.bukkit.util.Vector;
@@ -40,7 +41,7 @@ public class UserDefinedCarver extends Carver {
@Override
public Worm getWorm(long l, Vector vector) {
Random r = new Random(l + hash);
Random r = new XoRoShiRo128PlusRandom(l + hash);
return new UserDefinedWorm(length.get(r) / 2, r, vector, radius.getMax(), topCut, bottomCut);
}
@@ -59,7 +60,7 @@ public class UserDefinedCarver extends Carver {
@Override
public boolean isChunkCarved(World w, int chunkX, int chunkZ, Random random) {
ConfigPack c = TerraWorld.getWorld(w).getConfig();
return new Random(random.nextLong() + hash).nextInt(100) < c.getBiome((UserDefinedBiome) TerraWorld.getWorld(w).getGrid().getBiome(chunkX << 4, chunkZ << 4, GenerationPhase.POPULATE)).getCarverChance(this);
return new XoRoShiRo128PlusRandom(random.nextLong() + hash).nextInt(100) < c.getBiome((UserDefinedBiome) TerraWorld.getWorld(w).getGrid().getBiome(chunkX << 4, chunkZ << 4, GenerationPhase.POPULATE)).getCarverChance(this);
}
private class UserDefinedWorm extends Worm {