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()) {
|
||||
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.y
|
||||
pos.y,
|
||||
height
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
@ -42,8 +42,8 @@ public class GeneratorOptions {
|
|||
Configs.GENERATOR_CONFIG,
|
||||
300,
|
||||
200,
|
||||
70,
|
||||
10,
|
||||
70f / 128,
|
||||
10f / 128,
|
||||
false
|
||||
);
|
||||
mediumOptions = new LayerOptions(
|
||||
|
@ -51,8 +51,8 @@ public class GeneratorOptions {
|
|||
Configs.GENERATOR_CONFIG,
|
||||
150,
|
||||
100,
|
||||
70,
|
||||
20,
|
||||
70f / 128,
|
||||
20f / 128,
|
||||
true
|
||||
);
|
||||
smallOptions = new LayerOptions(
|
||||
|
@ -60,8 +60,8 @@ public class GeneratorOptions {
|
|||
Configs.GENERATOR_CONFIG,
|
||||
60,
|
||||
50,
|
||||
70,
|
||||
30,
|
||||
70f / 128,
|
||||
30f / 128,
|
||||
false
|
||||
);
|
||||
changeSpawn = Configs.GENERATOR_CONFIG.getBoolean("spawn", "changeSpawn", false);
|
||||
|
|
|
@ -57,7 +57,7 @@ public class IslandLayer {
|
|||
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 iz = MHelper.floor(z / options.distance);
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class IslandLayer {
|
|||
if (px2 * px2 + pz2 * pz2 > options.centerDist) {
|
||||
RANDOM.setSeed(getSeed(px, pz));
|
||||
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;
|
||||
if (density.eval(posX * 0.01, posZ * 0.01) > options.coverage) {
|
||||
positions.add(new BlockPos(posX, posY, posZ));
|
||||
|
|
|
@ -8,10 +8,10 @@ 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 float center;
|
||||
public final float heightVariation;
|
||||
public final float minY;
|
||||
public final float maxY;
|
||||
public final long centerDist;
|
||||
public final boolean hasCentralIsland;
|
||||
|
||||
|
@ -20,14 +20,14 @@ public class LayerOptions {
|
|||
PathConfig config,
|
||||
float distance,
|
||||
float scale,
|
||||
int center,
|
||||
int heightVariation,
|
||||
float center,
|
||||
float heightVariation,
|
||||
boolean hasCentral
|
||||
) {
|
||||
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.center = clampCenter(config.getFloat(name, "averageHeight[0-1]", center));
|
||||
this.heightVariation = clampVariation(config.getFloat(name, "heightVariation[0-1]", heightVariation));
|
||||
this.coverage = clampCoverage(config.getFloat(name, "coverage[0-1]", 0.5F));
|
||||
this.minY = 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;
|
||||
}
|
||||
|
||||
private int clampCenter(int value) {
|
||||
return Mth.clamp(value, 0, 255);
|
||||
private float clampCenter(float value) {
|
||||
return Mth.clamp(value, 0, 1.0f);
|
||||
}
|
||||
|
||||
private int clampVariation(int value) {
|
||||
return Mth.clamp(value, 0, 255);
|
||||
private float clampVariation(float value) {
|
||||
return Mth.clamp(value, 0, 1.0f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
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.biomes.BCLBiome;
|
||||
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) {
|
||||
LOCKER.lock();
|
||||
final float fadeOutDist = 27.0f;
|
||||
final float fadOutStart = maxHeight - fadeOutDist;
|
||||
final float fadOutStart = maxHeight - (fadeOutDist + 1);
|
||||
largeIslands.clearCache();
|
||||
mediumIslands.clearCache();
|
||||
smallIslands.clearCache();
|
||||
|
@ -84,9 +83,9 @@ public class TerrainGenerator {
|
|||
double px = (double) x * scaleXZ + distortion1;
|
||||
double pz = (double) z * scaleXZ + distortion2;
|
||||
|
||||
largeIslands.updatePositions(px, pz);
|
||||
mediumIslands.updatePositions(px, pz);
|
||||
smallIslands.updatePositions(px, pz);
|
||||
largeIslands.updatePositions(px, pz, maxHeight);
|
||||
mediumIslands.updatePositions(px, pz, maxHeight);
|
||||
smallIslands.updatePositions(px, pz, maxHeight);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (py > fadOutStart) {
|
||||
if (py >= maxHeight) dist = -1;
|
||||
else if (py > fadOutStart) {
|
||||
dist = (float) Mth.lerp((py - fadOutStart) / fadeOutDist, dist, -1);
|
||||
}
|
||||
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 sectionZ = TerrainBoolCache.scaleCoordinate(z);
|
||||
|
||||
final int stepY = (int) Math.ceil(maxHeight / SCALE_Y);
|
||||
LOCKER.lock();
|
||||
POS.setLocation(sectionX, sectionZ);
|
||||
|
||||
|
@ -186,12 +186,12 @@ public class TerrainGenerator {
|
|||
px = px * SCALE_XZ + distortion1;
|
||||
pz = pz * SCALE_XZ + distortion2;
|
||||
|
||||
largeIslands.updatePositions(px, pz);
|
||||
mediumIslands.updatePositions(px, pz);
|
||||
smallIslands.updatePositions(px, pz);
|
||||
largeIslands.updatePositions(px, pz, maxHeight);
|
||||
mediumIslands.updatePositions(px, pz, maxHeight);
|
||||
smallIslands.updatePositions(px, pz, maxHeight);
|
||||
|
||||
boolean result = false;
|
||||
for (int y = 0; y < 32; y++) {
|
||||
for (int y = 0; y < stepY; y++) {
|
||||
double py = (double) y * SCALE_Y;
|
||||
float dist = largeIslands.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)
|
||||
.be_getSettings();
|
||||
if (LevelGenUtil.getWorldSettings() instanceof BCLWorldPresetSettings bset) {
|
||||
if (bset.endVersion != BCLibEndBiomeSource.BIOME_SOURCE_VERSION_VANILLA) {
|
||||
BETargetChecker.class.cast(sHolder.value()).be_setTarget(true);
|
||||
}
|
||||
BETargetChecker.class.cast(sHolder.value()).be_setTarget(bset.useEndTerrainGenerator);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue