Lake fixes

This commit is contained in:
paulevsGitch 2020-11-05 00:18:54 +03:00
parent 0dc7732092
commit 488608d2a0
3 changed files with 37 additions and 17 deletions

View file

@ -32,7 +32,7 @@ public class StructureMegaLake extends StructureFeatureBase {
if (y > 5) {
float radius = MHelper.randRange(50, 100, random);
float depth = MHelper.randRange(10, 16, random);
LakePiece piece = new LakePiece(new BlockPos(x, y, z), radius, depth, random.nextInt(), biome);
LakePiece piece = new LakePiece(new BlockPos(x, y, z), radius, depth, random, biome);
this.children.add(piece);
}
this.setBoundingBoxFromChildren();

View file

@ -33,20 +33,26 @@ import ru.betterend.util.MHelper;
public class LakePiece extends BasePiece {
private static final BlockState WATER = Blocks.WATER.getDefaultState();
private Map<Integer, Integer> heightmap = Maps.newHashMap();
private OpenSimplexNoise noise;
private OpenSimplexNoise noise1;
private OpenSimplexNoise noise2;
private BlockPos center;
private float radius;
private float depth;
private float r2;
private Identifier biomeID;
private int seed1;
private int seed2;
public LakePiece(BlockPos center, float radius, float depth, int id, Biome biome) {
super(EndStructures.LAKE_PIECE, id);
public LakePiece(BlockPos center, float radius, float depth, Random random, Biome biome) {
super(EndStructures.LAKE_PIECE, random.nextInt());
this.center = center;
this.radius = radius;
this.depth = depth;
this.r2 = radius * radius;
this.noise = new OpenSimplexNoise(MHelper.getSeed(534, center.getX(), center.getZ()));
this.seed1 = random.nextInt();
this.seed2 = random.nextInt();
this.noise1 = new OpenSimplexNoise(this.seed1);
this.noise2 = new OpenSimplexNoise(this.seed2);
this.biomeID = EndBiomes.getBiomeID(biome);
makeBoundingBox();
}
@ -62,6 +68,8 @@ public class LakePiece extends BasePiece {
tag.putFloat("radius", radius);
tag.putFloat("depth", depth);
tag.putString("biome", biomeID.toString());
tag.putInt("seed1", seed1);
tag.putInt("seed2", seed2);
}
@Override
@ -70,7 +78,10 @@ public class LakePiece extends BasePiece {
radius = tag.getFloat("radius");
depth = tag.getFloat("depth");
r2 = radius * radius;
noise = new OpenSimplexNoise(MHelper.getSeed(534, center.getX(), center.getZ()));
seed1 = tag.getInt("seed1");
seed2 = tag.getInt("seed2");
noise1 = new OpenSimplexNoise(seed1);
noise2 = new OpenSimplexNoise(seed2);
biomeID = new Identifier(tag.getString("biome"));
}
@ -96,10 +107,10 @@ public class LakePiece extends BasePiece {
dist = 1 - dist / r2;
int maxY = map.get(x, z);
if (maxY > 55) {
float minY = dist * depth * getHeightClamp(world, 4, px, pz);
float minY = dist * depth * getHeightClamp(world, 8, px, pz);
if (minY > 0) {
minY *= (float) noise.eval(px * 0.05, pz * 0.05) * 0.3F + 0.7F;
minY *= (float) noise.eval(px * 0.1, pz * 0.1) * 0.1F + 0.8F;
minY *= (float) noise1.eval(px * 0.05, pz * 0.05) * 0.3F + 0.7F;
minY *= (float) noise1.eval(px * 0.1, pz * 0.1) * 0.1F + 0.8F;
float lerp = minY / 2F;
if (lerp > 1) {
lerp = 1;
@ -171,15 +182,15 @@ public class LakePiece extends BasePiece {
}
if (!EndBiomes.getBiomeID(world.getBiome(pos)).equals(biomeID)) {
heightmap.put(p, -4);
return -4;
heightmap.put(p, -20);
return -20;
}
h = world.getTopY(Type.WORLD_SURFACE_WG, pos.getX(), pos.getZ());
if (h < 57) {
heightmap.put(p, 0);
return 0;
heightmap.put(p, -20);
return -20;
}
h -= 57;
h = MHelper.floor(noise2.eval(pos.getX() * 0.01, pos.getZ() * 0.01) * noise2.eval(pos.getX() * 0.002, pos.getZ() * 0.002) * 8 + 8);
if (h < 0) {
heightmap.put(p, 0);

View file

@ -27,6 +27,7 @@ import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBiomes;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndStructures;
import ru.betterend.registry.EndTags;
import ru.betterend.util.MHelper;
public class MountainPiece extends BasePiece {
@ -92,7 +93,7 @@ public class MountainPiece extends BasePiece {
int sz = chunkPos.getStartZ();
Mutable pos = new Mutable();
Chunk chunk = world.getChunk(chunkPos.x, chunkPos.z);
Heightmap map = chunk.getHeightmap(Type.WORLD_SURFACE_WG);
Heightmap map = chunk.getHeightmap(Type.WORLD_SURFACE);
for (int x = 0; x < 16; x++) {
int px = x + sx;
int px2 = px - center.getX();
@ -107,6 +108,14 @@ public class MountainPiece extends BasePiece {
pos.setZ(z);
dist = 1 - (float) Math.pow(dist / r2, 0.3);
int minY = map.get(x, z);
if (minY < 56) {
continue;
}
pos.setY(minY);
while (!chunk.getBlockState(pos).isIn(EndTags.GEN_TERRAIN) && pos.getY() > 56) {
pos.setY(pos.getY() - 1);
}
minY = pos.getY();
if (minY > 56) {
float maxY = dist * height * getHeightClamp(world, 8, px, pz);
if (maxY > 0) {
@ -175,8 +184,8 @@ public class MountainPiece extends BasePiece {
}
if (!EndBiomes.getBiomeID(world.getBiome(pos)).equals(biomeID)) {
heightmap.put(p, -4);
return -4;
heightmap.put(p, -10);
return -10;
}
h = world.getTopY(Type.WORLD_SURFACE_WG, pos.getX(), pos.getZ());
if (h < 57) {