mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-04 23:06:05 +00:00
Add GridSpawn seed option
This commit is contained in:
@@ -42,7 +42,7 @@ public class Cavern {
|
||||
|
||||
public static class Node {
|
||||
private final long seed;
|
||||
private final GridSpawn spawn = new GridSpawn(16, 0);
|
||||
private final GridSpawn spawn = new GridSpawn(16, 0, 0);
|
||||
|
||||
public Node(World w) {
|
||||
this.seed = w.getSeed();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.dfsek.terra.config.loaders.config;
|
||||
|
||||
import com.dfsek.tectonic.exception.LoadException;
|
||||
import com.dfsek.tectonic.loading.ConfigLoader;
|
||||
import com.dfsek.tectonic.loading.TypeLoader;
|
||||
import com.dfsek.terra.procgen.GridSpawn;
|
||||
@@ -11,8 +10,8 @@ import java.util.Map;
|
||||
@SuppressWarnings("unchecked")
|
||||
public class GridSpawnLoader implements TypeLoader<GridSpawn> {
|
||||
@Override
|
||||
public GridSpawn load(Type type, Object o, ConfigLoader configLoader) throws LoadException {
|
||||
public GridSpawn load(Type type, Object o, ConfigLoader configLoader) {
|
||||
Map<String, Integer> map = (Map<String, Integer>) o;
|
||||
return new GridSpawn(map.get("width"), map.get("padding"));
|
||||
return new GridSpawn(map.get("width"), map.get("padding"), map.getOrDefault("seed", 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ public class StructureTemplate extends AbstractableTemplate {
|
||||
@Abstractable
|
||||
private Range bound;
|
||||
|
||||
|
||||
@Value("spawn")
|
||||
@Abstractable
|
||||
private GridSpawn spawn;
|
||||
|
||||
@@ -14,10 +14,12 @@ import java.util.Random;
|
||||
public class GridSpawn {
|
||||
private final int separation;
|
||||
private final int width;
|
||||
private final int seedOffset;
|
||||
|
||||
public GridSpawn(int width, int separation) {
|
||||
public GridSpawn(int width, int separation, int seedOffset) {
|
||||
this.separation = separation;
|
||||
this.width = width;
|
||||
this.seedOffset = seedOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,7 +36,7 @@ public class GridSpawn {
|
||||
List<Vector> zones = new GlueList<>();
|
||||
for(int xi = structureChunkX - 1; xi <= structureChunkX + 1; xi++) {
|
||||
for(int zi = structureChunkZ - 1; zi <= structureChunkZ + 1; zi++) {
|
||||
zones.add(getChunkSpawn(xi, zi, seed));
|
||||
zones.add(getChunkSpawn(xi, zi, seed + seedOffset));
|
||||
}
|
||||
}
|
||||
Vector shortest = zones.get(0);
|
||||
@@ -54,7 +56,7 @@ public class GridSpawn {
|
||||
* @return Vector representing spawnpoint
|
||||
*/
|
||||
public Vector getChunkSpawn(int structureChunkX, int structureChunkZ, long seed) {
|
||||
Random r = new FastRandom(MathUtil.getCarverChunkSeed(structureChunkX, structureChunkZ, seed));
|
||||
Random r = new FastRandom(MathUtil.getCarverChunkSeed(structureChunkX, structureChunkZ, seed + seedOffset));
|
||||
int offsetX = r.nextInt(width);
|
||||
int offsetZ = r.nextInt(width);
|
||||
int sx = structureChunkX * (width + 2 * separation) + offsetX;
|
||||
|
||||
Reference in New Issue
Block a user