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

@@ -13,6 +13,7 @@ import com.dfsek.terra.structure.Structure;
import com.dfsek.terra.structure.StructureContainedInventory;
import com.dfsek.terra.structure.features.Feature;
import com.dfsek.terra.util.structure.RotationUtil;
import it.unimi.dsi.util.XoRoShiRo128PlusRandom;
import org.apache.commons.math3.util.FastMath;
import org.bukkit.Chunk;
import org.bukkit.Location;
@@ -41,7 +42,7 @@ public class StructurePopulator extends BlockPopulator {
for(StructureConfig conf : config.getAllStructures()) {
Location spawn = conf.getSpawn().getNearestSpawn(cx + 8, cz + 8, world.getSeed()).toLocation(world);
if(!config.getBiome((UserDefinedBiome) grid.getBiome(spawn)).getStructures().contains(conf)) continue;
Random r2 = new Random(spawn.hashCode());
Random r2 = new XoRoShiRo128PlusRandom(spawn.hashCode());
Structure struc = conf.getStructure(r2);
Rotation rotation = Rotation.fromDegrees(r2.nextInt(4) * 90);
for(int y = conf.getSearchStart().get(r2); y > 0; y--) {