Island layer options
This commit is contained in:
parent
58a2970443
commit
08afd4fd97
6 changed files with 81 additions and 28 deletions
|
@ -50,7 +50,6 @@ public class TripleTerrainBlock extends EndTerrainBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModelPattern(String block) {
|
public String getModelPattern(String block) {
|
||||||
System.out.println(block);
|
|
||||||
String name = Registry.BLOCK.getId(this).getPath();
|
String name = Registry.BLOCK.getId(this).getPath();
|
||||||
if (block.endsWith("_middle")) {
|
if (block.endsWith("_middle")) {
|
||||||
return Patterns.createJson(Patterns.BLOCK_BASE, name + "_top", name + "_top");
|
return Patterns.createJson(Patterns.BLOCK_BASE, name + "_top", name + "_top");
|
||||||
|
|
|
@ -72,7 +72,17 @@ public class BetterEndBiomeSource extends BiomeSource {
|
||||||
boolean hasVoid = !GeneratorOptions.useNewGenerator() || !GeneratorOptions.noRingVoid();
|
boolean hasVoid = !GeneratorOptions.useNewGenerator() || !GeneratorOptions.noRingVoid();
|
||||||
long i = (long) biomeX * (long) biomeX;
|
long i = (long) biomeX * (long) biomeX;
|
||||||
long j = (long) biomeZ * (long) biomeZ;
|
long j = (long) biomeZ * (long) biomeZ;
|
||||||
if (hasVoid && i + j <= 65536L) return this.centerBiome;
|
|
||||||
|
long dist = i + j;
|
||||||
|
if (hasVoid) {
|
||||||
|
if (dist <= 65536L) return this.centerBiome;
|
||||||
|
}
|
||||||
|
else if (dist <= 625L) {
|
||||||
|
dist += noise.sample(i * 0.2, j * 0.2) * 10;
|
||||||
|
if (dist <= 625L) {
|
||||||
|
return this.centerBiome;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (biomeX == 0 && biomeZ == 0) {
|
if (biomeX == 0 && biomeZ == 0) {
|
||||||
mapLand.clearCache();
|
mapLand.clearCache();
|
||||||
|
|
|
@ -16,6 +16,9 @@ public class GeneratorOptions {
|
||||||
private static boolean generateCentralIsland;
|
private static boolean generateCentralIsland;
|
||||||
private static boolean generateObsidianPlatform;
|
private static boolean generateObsidianPlatform;
|
||||||
private static int endCityFailChance;
|
private static int endCityFailChance;
|
||||||
|
public static LayerOptions bigOptions;
|
||||||
|
public static LayerOptions mediumOptions;
|
||||||
|
public static LayerOptions smallOptions;
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
biomeSizeLand = Configs.GENERATOR_CONFIG.getInt("biomeMap", "biomeSizeLand", 256);
|
biomeSizeLand = Configs.GENERATOR_CONFIG.getInt("biomeMap", "biomeSizeLand", 256);
|
||||||
|
@ -26,11 +29,14 @@ public class GeneratorOptions {
|
||||||
swapOverworldToEnd = Configs.GENERATOR_CONFIG.getBooleanRoot("swapOverworldToEnd", false);
|
swapOverworldToEnd = Configs.GENERATOR_CONFIG.getBooleanRoot("swapOverworldToEnd", false);
|
||||||
changeChorusPlant = Configs.GENERATOR_CONFIG.getBoolean("chorusPlant", "changeChorusPlant", true);
|
changeChorusPlant = Configs.GENERATOR_CONFIG.getBoolean("chorusPlant", "changeChorusPlant", true);
|
||||||
removeChorusFromVanillaBiomes = Configs.GENERATOR_CONFIG.getBoolean("chorusPlant", "removeChorusFromVanillaBiomes", true);
|
removeChorusFromVanillaBiomes = Configs.GENERATOR_CONFIG.getBoolean("chorusPlant", "removeChorusFromVanillaBiomes", true);
|
||||||
newGenerator = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "useNewGenerator", false);
|
newGenerator = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "useNewGenerator", true);
|
||||||
noRingVoid = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "noRingVoid", false);
|
noRingVoid = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "noRingVoid", false);
|
||||||
generateCentralIsland = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "generateCentralIsland", false);
|
generateCentralIsland = Configs.GENERATOR_CONFIG.getBoolean("customGenerator", "generateCentralIsland", false);
|
||||||
endCityFailChance = Configs.GENERATOR_CONFIG.getInt("customGenerator", "endCityFailChance", 5);
|
endCityFailChance = Configs.GENERATOR_CONFIG.getInt("customGenerator", "endCityFailChance", 5);
|
||||||
generateObsidianPlatform = Configs.GENERATOR_CONFIG.getBooleanRoot("generateObsidianPlatform", true);
|
generateObsidianPlatform = Configs.GENERATOR_CONFIG.getBooleanRoot("generateObsidianPlatform", true);
|
||||||
|
bigOptions = new LayerOptions("customGenerator.layers.bigIslands", Configs.GENERATOR_CONFIG, 300, 200, 70, 10);
|
||||||
|
mediumOptions = new LayerOptions("customGenerator.layers.mediumIslands", Configs.GENERATOR_CONFIG, 150, 100, 70, 20);
|
||||||
|
smallOptions = new LayerOptions("customGenerator.layers.smallIslands", Configs.GENERATOR_CONFIG, 60, 50, 70, 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getBiomeSizeLand() {
|
public static int getBiomeSizeLand() {
|
||||||
|
|
|
@ -23,25 +23,17 @@ public class IslandLayer {
|
||||||
private final List<BlockPos> positions = new ArrayList<BlockPos>(9);
|
private final List<BlockPos> positions = new ArrayList<BlockPos>(9);
|
||||||
private final Map<BlockPos, SDF> islands = Maps.newHashMap();
|
private final Map<BlockPos, SDF> islands = Maps.newHashMap();
|
||||||
private final OpenSimplexNoise density;
|
private final OpenSimplexNoise density;
|
||||||
private final double distance;
|
|
||||||
private final float scale;
|
|
||||||
private final int seed;
|
private final int seed;
|
||||||
private final int minY;
|
|
||||||
private final int maxY;
|
|
||||||
private final long center;
|
|
||||||
private final boolean hasCentralIsland;
|
private final boolean hasCentralIsland;
|
||||||
private int lastX = Integer.MIN_VALUE;
|
private int lastX = Integer.MIN_VALUE;
|
||||||
private int lastZ = Integer.MIN_VALUE;
|
private int lastZ = Integer.MIN_VALUE;
|
||||||
|
private final LayerOptions options;
|
||||||
|
|
||||||
public IslandLayer(int seed, double distance, float scale, int center, int heightVariation, boolean hasCentralIsland) {
|
public IslandLayer(int seed, LayerOptions options, boolean hasCentralIsland) {
|
||||||
this.distance = distance;
|
|
||||||
this.density = new OpenSimplexNoise(seed);
|
|
||||||
this.scale = scale;
|
|
||||||
this.seed = seed;
|
|
||||||
this.minY = center - heightVariation;
|
|
||||||
this.maxY = center + heightVariation;
|
|
||||||
this.center = MHelper.floor(1000 / distance);
|
|
||||||
this.hasCentralIsland = hasCentralIsland;
|
this.hasCentralIsland = hasCentralIsland;
|
||||||
|
this.density = new OpenSimplexNoise(seed);
|
||||||
|
this.options = options;
|
||||||
|
this.seed = seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getSeed(int x, int z) {
|
private int getSeed(int x, int z) {
|
||||||
|
@ -51,8 +43,8 @@ public class IslandLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updatePositions(double x, double z) {
|
public void updatePositions(double x, double z) {
|
||||||
int ix = MHelper.floor(x / distance);
|
int ix = MHelper.floor(x / options.distance);
|
||||||
int iz = MHelper.floor(z / distance);
|
int iz = MHelper.floor(z / options.distance);
|
||||||
if (lastX != ix || lastZ != iz) {
|
if (lastX != ix || lastZ != iz) {
|
||||||
lastX = ix;
|
lastX = ix;
|
||||||
lastZ = iz;
|
lastZ = iz;
|
||||||
|
@ -61,11 +53,11 @@ public class IslandLayer {
|
||||||
int px = pox + ix;
|
int px = pox + ix;
|
||||||
for (int poz = -1; poz < 2; poz++) {
|
for (int poz = -1; poz < 2; poz++) {
|
||||||
int pz = poz + iz;
|
int pz = poz + iz;
|
||||||
if (GeneratorOptions.noRingVoid() || (long) px + (long) pz > center) {
|
if (GeneratorOptions.noRingVoid() || (long) px + (long) pz > options.centerDist) {
|
||||||
RANDOM.setSeed(getSeed(px, pz));
|
RANDOM.setSeed(getSeed(px, pz));
|
||||||
double posX = (px + RANDOM.nextFloat()) * distance;
|
double posX = (px + RANDOM.nextFloat()) * options.distance;
|
||||||
double posY = MHelper.randRange(minY, maxY, RANDOM);
|
double posY = MHelper.randRange(options.minY, options.maxY, RANDOM);
|
||||||
double posZ = (pz + RANDOM.nextFloat()) * distance;
|
double posZ = (pz + RANDOM.nextFloat()) * options.distance;
|
||||||
if (density.eval(posX * 0.01, posZ * 0.01) > 0) {
|
if (density.eval(posX * 0.01, posZ * 0.01) > 0) {
|
||||||
positions.add(new BlockPos(posX, posY, posZ));
|
positions.add(new BlockPos(posX, posY, posZ));
|
||||||
}
|
}
|
||||||
|
@ -94,9 +86,9 @@ public class IslandLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getRelativeDistance(SDF sdf, BlockPos center, double px, double py, double pz) {
|
private float getRelativeDistance(SDF sdf, BlockPos center, double px, double py, double pz) {
|
||||||
float x = (float) (px - center.getX()) / scale;
|
float x = (float) (px - center.getX()) / options.scale;
|
||||||
float y = (float) (py - center.getY()) / scale;
|
float y = (float) (py - center.getY()) / options.scale;
|
||||||
float z = (float) (pz - center.getZ()) / scale;
|
float z = (float) (pz - center.getZ()) / options.scale;
|
||||||
return sdf.getDistance(x, y, z);
|
return sdf.getDistance(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
46
src/main/java/ru/betterend/world/generator/LayerOptions.java
Normal file
46
src/main/java/ru/betterend/world/generator/LayerOptions.java
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
package ru.betterend.world.generator;
|
||||||
|
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
import ru.betterend.config.PathConfig;
|
||||||
|
|
||||||
|
public class LayerOptions {
|
||||||
|
public final float distance;
|
||||||
|
public final float scale;
|
||||||
|
public final float coverage;
|
||||||
|
public final int center;
|
||||||
|
public final int heightVariation;
|
||||||
|
public final int minY;
|
||||||
|
public final int maxY;
|
||||||
|
public final long centerDist;
|
||||||
|
|
||||||
|
public LayerOptions(String name, PathConfig config, float distance, float scale, int center, int heightVariation) {
|
||||||
|
this.distance = clampDistance(config.getFloat(name, "distance[1-8192]", distance));
|
||||||
|
this.scale = clampScale(config.getFloat(name, "scale[0.1-1024]", scale));
|
||||||
|
this.center = clampCenter(config.getInt(name, "averageHeight[0-255]", center));
|
||||||
|
this.heightVariation = clampVariation(config.getInt(name, "heightVariation[0-255]", heightVariation));
|
||||||
|
this.coverage = clampCoverage(config.getFloat(name, "coverage[0-1]", 0.5F));
|
||||||
|
this.minY = this.center - this.heightVariation;
|
||||||
|
this.maxY = this.center + this.heightVariation;
|
||||||
|
this.centerDist = MathHelper.floor(1000 / this.distance);
|
||||||
|
}
|
||||||
|
|
||||||
|
private float clampDistance(float value) {
|
||||||
|
return MathHelper.clamp(value, 1, 8192);
|
||||||
|
}
|
||||||
|
|
||||||
|
private float clampScale(float value) {
|
||||||
|
return MathHelper.clamp(value, 0.1F, 1024);
|
||||||
|
}
|
||||||
|
|
||||||
|
private float clampCoverage(float value) {
|
||||||
|
return MathHelper.clamp(value, 0, 1) * 2 - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int clampCenter(int value) {
|
||||||
|
return MathHelper.clamp(value, 0, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int clampVariation(int value) {
|
||||||
|
return MathHelper.clamp(value, 0, 255);
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,9 +25,9 @@ public class TerrainGenerator {
|
||||||
|
|
||||||
public static void initNoise(long seed) {
|
public static void initNoise(long seed) {
|
||||||
Random random = new Random(seed);
|
Random random = new Random(seed);
|
||||||
largeIslands = new IslandLayer(random.nextInt(), 300, 200, 70, 10, false);
|
largeIslands = new IslandLayer(random.nextInt(), GeneratorOptions.bigOptions, false);
|
||||||
mediumIslands = new IslandLayer(random.nextInt(), 150, 100, 70, 20, true);
|
mediumIslands = new IslandLayer(random.nextInt(), GeneratorOptions.mediumOptions, true);
|
||||||
smallIslands = new IslandLayer(random.nextInt(), 60, 50, 70, 30, false);
|
smallIslands = new IslandLayer(random.nextInt(), GeneratorOptions.smallOptions, false);
|
||||||
noise1 = new OpenSimplexNoise(random.nextInt());
|
noise1 = new OpenSimplexNoise(random.nextInt());
|
||||||
noise2 = new OpenSimplexNoise(random.nextInt());
|
noise2 = new OpenSimplexNoise(random.nextInt());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue