remove more random

This commit is contained in:
Zoë
2022-08-21 14:29:57 -05:00
parent b044b2c48e
commit b5d081fde4
25 changed files with 236 additions and 318 deletions

View File

@@ -22,9 +22,8 @@ public interface LootTable {
* Fills an Inventory with loot.
*
* @param i The Inventory to fill.
* @param r The The RandomGenerator instance to use.
*/
void fillInventory(Inventory i, RandomGenerator r);
void fillInventory(Inventory i);
/**
* Fetches a list of ItemStacks from the loot table using the given RandomGenerator instance.

View File

@@ -16,5 +16,5 @@ import com.dfsek.terra.api.world.WritableWorld;
public interface Structure {
boolean generate(Vector3Int location, WritableWorld world, Rotation rotation, Long Seed);
boolean generate(Vector3Int location, WritableWorld world, Rotation rotation);
}

View File

@@ -1,39 +0,0 @@
/*
* Copyright (c) 2020-2021 Polyhedral Development
*
* The Terra API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the common/api directory.
*/
package com.dfsek.terra.api.util;
import java.util.random.RandomGenerator;
import java.util.random.RandomGeneratorFactory;
import com.dfsek.terra.api.world.chunk.Chunk;
public final class PopulationUtil {
public static RandomGenerator getRandom(Chunk c) {
return getRandom(c, 0);
}
public static RandomGenerator getRandom(Chunk c, long salt) {
return RandomGeneratorFactory.<RandomGenerator.SplittableGenerator>of("Xoroshiro128PlusPlus").create(
getCarverChunkSeed(c.getX(), c.getZ(), c.getWorld().getSeed() + salt));
}
/**
* Gets the carver seed for a chunk.
*
* @param chunkX Chunk's X coordinate
* @param chunkZ Chunk's Z coordinate
* @param seed World seed
*
* @return long - The carver seed.
*/
public static long getCarverChunkSeed(int chunkX, int chunkZ, long seed) {
RandomGenerator r = RandomGeneratorFactory.<RandomGenerator.SplittableGenerator>of("Xoroshiro128PlusPlus").create(seed);
return chunkX * r.nextLong() ^ chunkZ * r.nextLong() ^ seed;
}
}