Lakes changes

This commit is contained in:
paulevsGitch 2021-01-12 00:42:44 +03:00
parent 6e71d8785e
commit 25c798b27d
4 changed files with 53 additions and 31 deletions

View file

@ -33,7 +33,7 @@ public class EndStructures {
public static final StructurePieceType NBT_PIECE = register("nbt_piece", NBTPiece::new); public static final StructurePieceType NBT_PIECE = register("nbt_piece", NBTPiece::new);
public static final EndStructureFeature GIANT_MOSSY_GLOWSHROOM = new EndStructureFeature("giant_mossy_glowshroom", new StructureGiantMossyGlowshroom(), Feature.SURFACE_STRUCTURES, 16, 8); public static final EndStructureFeature GIANT_MOSSY_GLOWSHROOM = new EndStructureFeature("giant_mossy_glowshroom", new StructureGiantMossyGlowshroom(), Feature.SURFACE_STRUCTURES, 16, 8);
public static final EndStructureFeature MEGALAKE = new EndStructureFeature("megalake", new StructureMegaLake(), Feature.RAW_GENERATION, 4, 1); public static final EndStructureFeature MEGALAKE = new EndStructureFeature("megalake", new StructureMegaLake(), Feature.RAW_GENERATION, 8, 2);
public static final EndStructureFeature MOUNTAIN = new EndStructureFeature("mountain", new StructureMountain(), Feature.RAW_GENERATION, 3, 2); public static final EndStructureFeature MOUNTAIN = new EndStructureFeature("mountain", new StructureMountain(), Feature.RAW_GENERATION, 3, 2);
public static final EndStructureFeature PAINTED_MOUNTAIN = new EndStructureFeature("painted_mountain", new StructurePaintedMountain(), Feature.RAW_GENERATION, 3, 2); public static final EndStructureFeature PAINTED_MOUNTAIN = new EndStructureFeature("painted_mountain", new StructurePaintedMountain(), Feature.RAW_GENERATION, 3, 2);
public static final EndStructureFeature ETERNAL_PORTAL = new EndStructureFeature("eternal_portal", new StructureEternalPortal(), Feature.SURFACE_STRUCTURES, 16, 6); public static final EndStructureFeature ETERNAL_PORTAL = new EndStructureFeature("eternal_portal", new StructureEternalPortal(), Feature.SURFACE_STRUCTURES, 16, 6);

View file

@ -22,7 +22,7 @@ public abstract class StructureFeatureBase extends StructureFeature<DefaultFeatu
} }
protected boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, ChunkRandom chunkRandom, int chunkX, int chunkZ, Biome biome, ChunkPos chunkPos, DefaultFeatureConfig featureConfig) { protected boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, ChunkRandom chunkRandom, int chunkX, int chunkZ, Biome biome, ChunkPos chunkPos, DefaultFeatureConfig featureConfig) {
return getGenerationHeight(chunkX, chunkZ, chunkGenerator) >= 50; return getGenerationHeight(chunkX, chunkZ, chunkGenerator) >= 20;
} }
private static int getGenerationHeight(int chunkX, int chunkZ, ChunkGenerator chunkGenerator) { private static int getGenerationHeight(int chunkX, int chunkZ, ChunkGenerator chunkGenerator) {

View file

@ -30,8 +30,8 @@ public class StructureMegaLake extends StructureFeatureBase {
int z = (chunkZ << 4) | MHelper.randRange(4, 12, random); int z = (chunkZ << 4) | MHelper.randRange(4, 12, random);
int y = chunkGenerator.getHeight(x, z, Type.WORLD_SURFACE_WG); int y = chunkGenerator.getHeight(x, z, Type.WORLD_SURFACE_WG);
if (y > 5) { if (y > 5) {
float radius = MHelper.randRange(50, 100, random); float radius = MHelper.randRange(50, 150, random);
float depth = MHelper.randRange(10, 16, random); float depth = MHelper.randRange(6, 10, random);
LakePiece piece = new LakePiece(new BlockPos(x, y - 3, z), radius, depth, random, biome); LakePiece piece = new LakePiece(new BlockPos(x, y - 3, z), radius, depth, random, biome);
this.children.add(piece); this.children.add(piece);
} }

View file

@ -107,7 +107,7 @@ public class LakePiece extends BasePiece {
dist = 1 - dist / r2; dist = 1 - dist / r2;
int maxY = map.get(x, z); int maxY = map.get(x, z);
if (MathHelper.abs(maxY - center.getY()) < 8) { if (MathHelper.abs(maxY - center.getY()) < 8) {
float minY = dist * depth * getHeightClamp(world, 8, px, pz); float minY = (float) Math.sqrt(dist) * depth * getHeightClamp(world, 8, px, pz);
if (minY > 0) { if (minY > 0) {
minY *= (float) noise1.eval(px * 0.05, pz * 0.05) * 0.3F + 0.7F; 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; minY *= (float) noise1.eval(px * 0.1, pz * 0.1) * 0.1F + 0.8F;
@ -121,33 +121,35 @@ public class LakePiece extends BasePiece {
pos.setY(maxY ++); pos.setY(maxY ++);
} }
if (maxY <= center.getY() + 1) { if (!waterIsNear(world, pos.getX() + sx, center.getY(), pos.getZ() + sz, 2)) {
maxY = MathHelper.clamp(maxY + 4, 0, center.getY()); if (maxY <= center.getY() + 1) {
BlockState surf = random.nextBoolean() ? EndBlocks.ENDSTONE_DUST.getDefaultState() : world.getBiome(pos.add(sx, 0, sz)).getGenerationSettings().getSurfaceConfig().getTopMaterial(); maxY = MathHelper.clamp(maxY + 4, 0, center.getY());
BlockState under = world.getBiome(pos.add(sx, 0, sz)).getGenerationSettings().getSurfaceConfig().getUnderMaterial(); BlockState surf = random.nextBoolean() ? EndBlocks.ENDSTONE_DUST.getDefaultState() : world.getBiome(pos.add(sx, 0, sz)).getGenerationSettings().getSurfaceConfig().getTopMaterial();
for (int y = maxY; y >= minY; y--) { BlockState under = world.getBiome(pos.add(sx, 0, sz)).getGenerationSettings().getSurfaceConfig().getUnderMaterial();
pos.setY(y); for (int y = maxY; y >= minY; y--) {
BlockState state = chunk.getBlockState(pos); pos.setY(y);
if (state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN)) { BlockState state = chunk.getBlockState(pos);
chunk.setBlockState(pos, y > center.getY() ? AIR : y == maxY ? surf : under, false); if (state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN)) {
} chunk.setBlockState(pos, y > center.getY() ? AIR : y == maxY ? surf : under, false);
else { }
break; else {
break;
}
} }
} }
} else {
else { for (int y = maxY; y >= minY; y--) {
for (int y = maxY; y >= minY; y--) { pos.setY(y);
pos.setY(y); BlockState state = chunk.getBlockState(pos);
BlockState state = chunk.getBlockState(pos); if (state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN)) {
if (state.getMaterial().isReplaceable() || state.isIn(EndTags.GEN_TERRAIN)) { if (maxY <= center.getY() + 1)
if (maxY <= center.getY() + 1) chunk.setBlockState(pos, Blocks.REDSTONE_BLOCK.getDefaultState(), false);
chunk.setBlockState(pos, Blocks.REDSTONE_BLOCK.getDefaultState(), false); else
else chunk.setBlockState(pos, y > center.getY() ? AIR : WATER, false);
chunk.setBlockState(pos, y > center.getY() ? AIR : WATER, false); }
} else {
else { break;
break; }
} }
} }
} }
@ -181,6 +183,26 @@ public class LakePiece extends BasePiece {
return true; return true;
} }
private boolean waterIsNear(StructureWorldAccess world, int x, int y, int z, int r) {
int py = world.getChunk(x >> 4, z >> 4).sampleHeightmap(Type.WORLD_SURFACE, x & 15, z & 15) - 1;
if (py > y) {
Mutable m = new Mutable();
m.setY(py);
for (int i = -r; i <= r; i++) {
int px = x + i;
m.setX(px);
for (int j = -r; j <= r; j++) {
int pz = z + j;
m.setZ(pz);
if (!world.getFluidState(m).isEmpty()) {
return true;
}
}
}
}
return false;
}
private int getHeight(StructureWorldAccess world, BlockPos pos) { private int getHeight(StructureWorldAccess world, BlockPos pos) {
int p = ((pos.getX() & 2047) << 11) | (pos.getZ() & 2047); int p = ((pos.getX() & 2047) << 11) | (pos.getZ() & 2047);
int h = heightmap.getOrDefault(p, Integer.MIN_VALUE); int h = heightmap.getOrDefault(p, Integer.MIN_VALUE);