build ore addon

This commit is contained in:
dfsek
2021-07-05 00:13:23 -07:00
parent 25339ca4ef
commit 3ea6724e6c
13 changed files with 51 additions and 43 deletions

View File

@@ -0,0 +1,8 @@
package com.dfsek.terra.api.util;
import com.dfsek.terra.api.block.BlockType;
import java.util.Set;
public interface MaterialSet extends Set<BlockType> {
}

View File

@@ -0,0 +1,28 @@
package com.dfsek.terra.api.util;
import com.dfsek.terra.api.world.Chunk;
import java.util.Random;
public final class PopulationUtil {
public static Random getRandom(Chunk c) {
return getRandom(c, 0);
}
public static Random getRandom(Chunk c, long salt) {
return new Random(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) {
Random r = new Random(seed);
return chunkX * r.nextLong() ^ chunkZ * r.nextLong() ^ seed;
}
}