fix GridSpawn salt

This commit is contained in:
dfsek
2021-01-03 13:33:03 -07:00
parent 90cc88f05f
commit bf4a831781
2 changed files with 6 additions and 6 deletions

View File

@@ -12,6 +12,6 @@ public class GridSpawnLoader implements TypeLoader<GridSpawn> {
@Override
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"), map.getOrDefault("seed", 0));
return new GridSpawn(map.get("width"), map.get("padding"), map.getOrDefault("salt", 0));
}
}

View File

@@ -14,12 +14,12 @@ import java.util.Random;
public class GridSpawn {
private final int separation;
private final int width;
private final int seedOffset;
private final int salt;
public GridSpawn(int width, int separation, int seedOffset) {
public GridSpawn(int width, int separation, int salt) {
this.separation = separation;
this.width = width;
this.seedOffset = seedOffset;
this.salt = salt;
}
/**
@@ -36,7 +36,7 @@ public class GridSpawn {
List<Vector3> 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 + seedOffset));
zones.add(getChunkSpawn(xi, zi, seed));
}
}
Vector3 shortest = zones.get(0);
@@ -56,7 +56,7 @@ public class GridSpawn {
* @return Vector representing spawnpoint
*/
public Vector3 getChunkSpawn(int structureChunkX, int structureChunkZ, long seed) {
Random r = new FastRandom(MathUtil.getCarverChunkSeed(structureChunkX, structureChunkZ, seed + seedOffset));
Random r = new FastRandom(MathUtil.getCarverChunkSeed(structureChunkX, structureChunkZ, seed + salt));
int offsetX = r.nextInt(width);
int offsetZ = r.nextInt(width);
int sx = structureChunkX * (width + 2 * separation) + offsetX;