Non default Terrain Heights for EndBiomeSource
This commit is contained in:
parent
a57db4c84e
commit
6c79046ef7
5 changed files with 36 additions and 37 deletions
|
@ -61,9 +61,10 @@ public class BetterEnd implements ModInitializer {
|
||||||
|
|
||||||
if (GeneratorOptions.useNewGenerator()) {
|
if (GeneratorOptions.useNewGenerator()) {
|
||||||
org.betterx.bclib.api.v2.generator.GeneratorOptions.setFarEndBiomes(GeneratorOptions.getIslandDistBlock());
|
org.betterx.bclib.api.v2.generator.GeneratorOptions.setFarEndBiomes(GeneratorOptions.getIslandDistBlock());
|
||||||
org.betterx.bclib.api.v2.generator.GeneratorOptions.setEndLandFunction((pos) -> TerrainGenerator.isLand(
|
org.betterx.bclib.api.v2.generator.GeneratorOptions.setEndLandFunction((pos, height) -> TerrainGenerator.isLand(
|
||||||
pos.x,
|
pos.x,
|
||||||
pos.y
|
pos.y,
|
||||||
|
height
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,8 @@ public class GeneratorOptions {
|
||||||
Configs.GENERATOR_CONFIG,
|
Configs.GENERATOR_CONFIG,
|
||||||
300,
|
300,
|
||||||
200,
|
200,
|
||||||
70,
|
70f / 128,
|
||||||
10,
|
10f / 128,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
mediumOptions = new LayerOptions(
|
mediumOptions = new LayerOptions(
|
||||||
|
@ -51,8 +51,8 @@ public class GeneratorOptions {
|
||||||
Configs.GENERATOR_CONFIG,
|
Configs.GENERATOR_CONFIG,
|
||||||
150,
|
150,
|
||||||
100,
|
100,
|
||||||
70,
|
70f / 128,
|
||||||
20,
|
20f / 128,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
smallOptions = new LayerOptions(
|
smallOptions = new LayerOptions(
|
||||||
|
@ -60,8 +60,8 @@ public class GeneratorOptions {
|
||||||
Configs.GENERATOR_CONFIG,
|
Configs.GENERATOR_CONFIG,
|
||||||
60,
|
60,
|
||||||
50,
|
50,
|
||||||
70,
|
70f / 128,
|
||||||
30,
|
30f / 128,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
changeSpawn = Configs.GENERATOR_CONFIG.getBoolean("spawn", "changeSpawn", false);
|
changeSpawn = Configs.GENERATOR_CONFIG.getBoolean("spawn", "changeSpawn", false);
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class IslandLayer {
|
||||||
return h ^ (h >> 16);
|
return h ^ (h >> 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updatePositions(double x, double z) {
|
public void updatePositions(double x, double z, int maxHeight) {
|
||||||
int ix = MHelper.floor(x / options.distance);
|
int ix = MHelper.floor(x / options.distance);
|
||||||
int iz = MHelper.floor(z / options.distance);
|
int iz = MHelper.floor(z / options.distance);
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ public class IslandLayer {
|
||||||
if (px2 * px2 + pz2 * pz2 > options.centerDist) {
|
if (px2 * px2 + pz2 * pz2 > options.centerDist) {
|
||||||
RANDOM.setSeed(getSeed(px, pz));
|
RANDOM.setSeed(getSeed(px, pz));
|
||||||
double posX = (px + RANDOM.nextFloat()) * options.distance;
|
double posX = (px + RANDOM.nextFloat()) * options.distance;
|
||||||
double posY = MHelper.randRange(options.minY, options.maxY, RANDOM);
|
double posY = MHelper.randRange(options.minY, options.maxY, RANDOM) * maxHeight;
|
||||||
double posZ = (pz + RANDOM.nextFloat()) * options.distance;
|
double posZ = (pz + RANDOM.nextFloat()) * options.distance;
|
||||||
if (density.eval(posX * 0.01, posZ * 0.01) > options.coverage) {
|
if (density.eval(posX * 0.01, posZ * 0.01) > options.coverage) {
|
||||||
positions.add(new BlockPos(posX, posY, posZ));
|
positions.add(new BlockPos(posX, posY, posZ));
|
||||||
|
|
|
@ -8,10 +8,10 @@ public class LayerOptions {
|
||||||
public final float distance;
|
public final float distance;
|
||||||
public final float scale;
|
public final float scale;
|
||||||
public final float coverage;
|
public final float coverage;
|
||||||
public final int center;
|
public final float center;
|
||||||
public final int heightVariation;
|
public final float heightVariation;
|
||||||
public final int minY;
|
public final float minY;
|
||||||
public final int maxY;
|
public final float maxY;
|
||||||
public final long centerDist;
|
public final long centerDist;
|
||||||
public final boolean hasCentralIsland;
|
public final boolean hasCentralIsland;
|
||||||
|
|
||||||
|
@ -20,14 +20,14 @@ public class LayerOptions {
|
||||||
PathConfig config,
|
PathConfig config,
|
||||||
float distance,
|
float distance,
|
||||||
float scale,
|
float scale,
|
||||||
int center,
|
float center,
|
||||||
int heightVariation,
|
float heightVariation,
|
||||||
boolean hasCentral
|
boolean hasCentral
|
||||||
) {
|
) {
|
||||||
this.distance = clampDistance(config.getFloat(name, "distance[1-8192]", distance));
|
this.distance = clampDistance(config.getFloat(name, "distance[1-8192]", distance));
|
||||||
this.scale = clampScale(config.getFloat(name, "scale[0.1-1024]", scale));
|
this.scale = clampScale(config.getFloat(name, "scale[0.1-1024]", scale));
|
||||||
this.center = clampCenter(config.getInt(name, "averageHeight[0-255]", center));
|
this.center = clampCenter(config.getFloat(name, "averageHeight[0-1]", center));
|
||||||
this.heightVariation = clampVariation(config.getInt(name, "heightVariation[0-255]", heightVariation));
|
this.heightVariation = clampVariation(config.getFloat(name, "heightVariation[0-1]", heightVariation));
|
||||||
this.coverage = clampCoverage(config.getFloat(name, "coverage[0-1]", 0.5F));
|
this.coverage = clampCoverage(config.getFloat(name, "coverage[0-1]", 0.5F));
|
||||||
this.minY = this.center - this.heightVariation;
|
this.minY = this.center - this.heightVariation;
|
||||||
this.maxY = this.center + this.heightVariation;
|
this.maxY = this.center + this.heightVariation;
|
||||||
|
@ -47,11 +47,11 @@ public class LayerOptions {
|
||||||
return 0.9999F - Mth.clamp(value, 0, 1) * 2;
|
return 0.9999F - Mth.clamp(value, 0, 1) * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int clampCenter(int value) {
|
private float clampCenter(float value) {
|
||||||
return Mth.clamp(value, 0, 255);
|
return Mth.clamp(value, 0, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int clampVariation(int value) {
|
private float clampVariation(float value) {
|
||||||
return Mth.clamp(value, 0, 255);
|
return Mth.clamp(value, 0, 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package org.betterx.betterend.world.generator;
|
package org.betterx.betterend.world.generator;
|
||||||
|
|
||||||
import org.betterx.bclib.api.v2.generator.BCLibEndBiomeSource;
|
|
||||||
import org.betterx.bclib.api.v2.levelgen.LevelGenUtil;
|
import org.betterx.bclib.api.v2.levelgen.LevelGenUtil;
|
||||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
|
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
|
||||||
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI;
|
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI;
|
||||||
|
@ -66,7 +65,7 @@ public class TerrainGenerator {
|
||||||
public static void fillTerrainDensity(double[] buffer, int posX, int posZ, int scaleXZ, int scaleY, int maxHeight) {
|
public static void fillTerrainDensity(double[] buffer, int posX, int posZ, int scaleXZ, int scaleY, int maxHeight) {
|
||||||
LOCKER.lock();
|
LOCKER.lock();
|
||||||
final float fadeOutDist = 27.0f;
|
final float fadeOutDist = 27.0f;
|
||||||
final float fadOutStart = maxHeight - fadeOutDist;
|
final float fadOutStart = maxHeight - (fadeOutDist + 1);
|
||||||
largeIslands.clearCache();
|
largeIslands.clearCache();
|
||||||
mediumIslands.clearCache();
|
mediumIslands.clearCache();
|
||||||
smallIslands.clearCache();
|
smallIslands.clearCache();
|
||||||
|
@ -84,9 +83,9 @@ public class TerrainGenerator {
|
||||||
double px = (double) x * scaleXZ + distortion1;
|
double px = (double) x * scaleXZ + distortion1;
|
||||||
double pz = (double) z * scaleXZ + distortion2;
|
double pz = (double) z * scaleXZ + distortion2;
|
||||||
|
|
||||||
largeIslands.updatePositions(px, pz);
|
largeIslands.updatePositions(px, pz, maxHeight);
|
||||||
mediumIslands.updatePositions(px, pz);
|
mediumIslands.updatePositions(px, pz, maxHeight);
|
||||||
smallIslands.updatePositions(px, pz);
|
smallIslands.updatePositions(px, pz, maxHeight);
|
||||||
|
|
||||||
float height = getAverageDepth(x << 1, z << 1) * 0.5F;
|
float height = getAverageDepth(x << 1, z << 1) * 0.5F;
|
||||||
|
|
||||||
|
@ -101,7 +100,8 @@ public class TerrainGenerator {
|
||||||
dist += noise1.eval(px * 0.1, py * 0.1, pz * 0.1) * 0.005 + 0.005;
|
dist += noise1.eval(px * 0.1, py * 0.1, pz * 0.1) * 0.005 + 0.005;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (py > fadOutStart) {
|
if (py >= maxHeight) dist = -1;
|
||||||
|
else if (py > fadOutStart) {
|
||||||
dist = (float) Mth.lerp((py - fadOutStart) / fadeOutDist, dist, -1);
|
dist = (float) Mth.lerp((py - fadOutStart) / fadeOutDist, dist, -1);
|
||||||
}
|
}
|
||||||
buffer[y] = dist;
|
buffer[y] = dist;
|
||||||
|
@ -151,10 +151,10 @@ public class TerrainGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Boolean isLand(int x, int z) {
|
public static Boolean isLand(int x, int z, int maxHeight) {
|
||||||
int sectionX = TerrainBoolCache.scaleCoordinate(x);
|
int sectionX = TerrainBoolCache.scaleCoordinate(x);
|
||||||
int sectionZ = TerrainBoolCache.scaleCoordinate(z);
|
int sectionZ = TerrainBoolCache.scaleCoordinate(z);
|
||||||
|
final int stepY = (int) Math.ceil(maxHeight / SCALE_Y);
|
||||||
LOCKER.lock();
|
LOCKER.lock();
|
||||||
POS.setLocation(sectionX, sectionZ);
|
POS.setLocation(sectionX, sectionZ);
|
||||||
|
|
||||||
|
@ -186,12 +186,12 @@ public class TerrainGenerator {
|
||||||
px = px * SCALE_XZ + distortion1;
|
px = px * SCALE_XZ + distortion1;
|
||||||
pz = pz * SCALE_XZ + distortion2;
|
pz = pz * SCALE_XZ + distortion2;
|
||||||
|
|
||||||
largeIslands.updatePositions(px, pz);
|
largeIslands.updatePositions(px, pz, maxHeight);
|
||||||
mediumIslands.updatePositions(px, pz);
|
mediumIslands.updatePositions(px, pz, maxHeight);
|
||||||
smallIslands.updatePositions(px, pz);
|
smallIslands.updatePositions(px, pz, maxHeight);
|
||||||
|
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
for (int y = 0; y < 32; y++) {
|
for (int y = 0; y < stepY; y++) {
|
||||||
double py = (double) y * SCALE_Y;
|
double py = (double) y * SCALE_Y;
|
||||||
float dist = largeIslands.getDensity(px, py, pz);
|
float dist = largeIslands.getDensity(px, py, pz);
|
||||||
dist = dist > 1 ? dist : MHelper.max(dist, mediumIslands.getDensity(px, py, pz));
|
dist = dist > 1 ? dist : MHelper.max(dist, mediumIslands.getDensity(px, py, pz));
|
||||||
|
@ -220,9 +220,7 @@ public class TerrainGenerator {
|
||||||
Holder<NoiseGeneratorSettings> sHolder = ((NoiseBasedChunkGeneratorAccessor) chunkGenerator)
|
Holder<NoiseGeneratorSettings> sHolder = ((NoiseBasedChunkGeneratorAccessor) chunkGenerator)
|
||||||
.be_getSettings();
|
.be_getSettings();
|
||||||
if (LevelGenUtil.getWorldSettings() instanceof BCLWorldPresetSettings bset) {
|
if (LevelGenUtil.getWorldSettings() instanceof BCLWorldPresetSettings bset) {
|
||||||
if (bset.endVersion != BCLibEndBiomeSource.BIOME_SOURCE_VERSION_VANILLA) {
|
BETargetChecker.class.cast(sHolder.value()).be_setTarget(bset.useEndTerrainGenerator);
|
||||||
BETargetChecker.class.cast(sHolder.value()).be_setTarget(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue