mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-10-26 05:50:08 +00:00
Add GridSpawn seed option
This commit is contained in:
1 parent
554628c486
commit
a0f0206ed8
4 files changed
+8
-8
No files matched your search
@@ -42,7 +42,7 @@ public class Cavern {
|
|||||||
|
|
||||||
public static class Node {
|
public static class Node {
|
||||||
private final long seed;
|
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) {
|
public Node(World w) {
|
||||||
this.seed = w.getSeed();
|
this.seed = w.getSeed();
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.dfsek.terra.config.loaders.config;
|
package com.dfsek.terra.config.loaders.config;
|
||||||
|
|
||||||
import com.dfsek.tectonic.exception.LoadException;
|
|
||||||
import com.dfsek.tectonic.loading.ConfigLoader;
|
import com.dfsek.tectonic.loading.ConfigLoader;
|
||||||
import com.dfsek.tectonic.loading.TypeLoader;
|
import com.dfsek.tectonic.loading.TypeLoader;
|
||||||
import com.dfsek.terra.procgen.GridSpawn;
|
import com.dfsek.terra.procgen.GridSpawn;
|
||||||
@@ -11,8 +10,8 @@ import java.util.Map;
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public class GridSpawnLoader implements TypeLoader<GridSpawn> {
|
public class GridSpawnLoader implements TypeLoader<GridSpawn> {
|
||||||
@Override
|
@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;
|
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
|
@Abstractable
|
||||||
private Range bound;
|
private Range bound;
|
||||||
|
|
||||||
|
|
||||||
@Value("spawn")
|
@Value("spawn")
|
||||||
@Abstractable
|
@Abstractable
|
||||||
private GridSpawn spawn;
|
private GridSpawn spawn;
|
||||||
|
|||||||
@@ -14,10 +14,12 @@ import java.util.Random;
|
|||||||
public class GridSpawn {
|
public class GridSpawn {
|
||||||
private final int separation;
|
private final int separation;
|
||||||
private final int width;
|
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.separation = separation;
|
||||||
this.width = width;
|
this.width = width;
|
||||||
|
this.seedOffset = seedOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,7 +36,7 @@ public class GridSpawn {
|
|||||||
List<Vector> zones = new GlueList<>();
|
List<Vector> zones = new GlueList<>();
|
||||||
for(int xi = structureChunkX - 1; xi <= structureChunkX + 1; xi++) {
|
for(int xi = structureChunkX - 1; xi <= structureChunkX + 1; xi++) {
|
||||||
for(int zi = structureChunkZ - 1; zi <= structureChunkZ + 1; zi++) {
|
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);
|
Vector shortest = zones.get(0);
|
||||||
@@ -54,7 +56,7 @@ public class GridSpawn {
|
|||||||
* @return Vector representing spawnpoint
|
* @return Vector representing spawnpoint
|
||||||
*/
|
*/
|
||||||
public Vector getChunkSpawn(int structureChunkX, int structureChunkZ, long seed) {
|
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 offsetX = r.nextInt(width);
|
||||||
int offsetZ = r.nextInt(width);
|
int offsetZ = r.nextInt(width);
|
||||||
int sx = structureChunkX * (width + 2 * separation) + offsetX;
|
int sx = structureChunkX * (width + 2 * separation) + offsetX;
|
||||||
|
|||||||
Reference in new issue
Block a user