More generation fixes

This commit is contained in:
paulevsGitch 2020-11-05 17:14:05 +03:00
parent 3efdfcb575
commit c6a9e52019
2 changed files with 9 additions and 5 deletions

View file

@ -31,6 +31,8 @@ import ru.betterend.util.sdf.primitive.SDFHexPrism;
import ru.betterend.util.sdf.primitive.SDFSphere; import ru.betterend.util.sdf.primitive.SDFSphere;
public class RoundCaveFeature extends DefaultFeature { public class RoundCaveFeature extends DefaultFeature {
private static final BlockState CAVE_AIR = Blocks.CAVE_AIR.getDefaultState();
@Override @Override
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) { public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
if (pos.getX() * pos.getX() + pos.getZ() * pos.getZ() <= 22500) { if (pos.getX() * pos.getX() + pos.getZ() * pos.getZ() <= 22500) {
@ -48,7 +50,7 @@ public class RoundCaveFeature extends DefaultFeature {
while (top > bottom && !world.getBlockState(bpos).isIn(EndTags.GEN_TERRAIN)) { while (top > bottom && !world.getBlockState(bpos).isIn(EndTags.GEN_TERRAIN)) {
bpos.setY(--top); bpos.setY(--top);
} }
top -= radius + 5; top -= radius * 1.3F + 5;
if (top <= bottom) { if (top <= bottom) {
return false; return false;
@ -89,17 +91,17 @@ public class RoundCaveFeature extends DefaultFeature {
if (dist < r * r) { if (dist < r * r) {
BlockState state = world.getBlockState(bpos); BlockState state = world.getBlockState(bpos);
if (isReplaceable(state)) { if (isReplaceable(state)) {
BlocksHelper.setWithoutUpdate(world, bpos, AIR); BlocksHelper.setWithoutUpdate(world, bpos, CAVE_AIR);
while (state.getMaterial().equals(Material.LEAVES)) { while (state.getMaterial().equals(Material.LEAVES)) {
BlocksHelper.setWithoutUpdate(world, bpos, AIR); BlocksHelper.setWithoutUpdate(world, bpos, CAVE_AIR);
bpos.setY(bpos.getY() + 1); bpos.setY(bpos.getY() + 1);
state = world.getBlockState(bpos); state = world.getBlockState(bpos);
} }
bpos.setY(y - 1); bpos.setY(y - 1);
while (state.getMaterial().equals(Material.LEAVES)) { while (state.getMaterial().equals(Material.LEAVES)) {
BlocksHelper.setWithoutUpdate(world, bpos, AIR); BlocksHelper.setWithoutUpdate(world, bpos, CAVE_AIR);
bpos.setY(bpos.getY() - 1); bpos.setY(bpos.getY() - 1);
state = world.getBlockState(bpos); state = world.getBlockState(bpos);
} }

View file

@ -94,6 +94,7 @@ public class MountainPiece extends BasePiece {
Mutable pos = new Mutable(); Mutable pos = new Mutable();
Chunk chunk = world.getChunk(chunkPos.x, chunkPos.z); Chunk chunk = world.getChunk(chunkPos.x, chunkPos.z);
Heightmap map = chunk.getHeightmap(Type.WORLD_SURFACE); Heightmap map = chunk.getHeightmap(Type.WORLD_SURFACE);
Heightmap map2 = chunk.getHeightmap(Type.WORLD_SURFACE_WG);
for (int x = 0; x < 16; x++) { for (int x = 0; x < 16; x++) {
int px = x + sx; int px = x + sx;
int px2 = px - center.getX(); int px2 = px - center.getX();
@ -112,10 +113,11 @@ public class MountainPiece extends BasePiece {
continue; continue;
} }
pos.setY(minY); pos.setY(minY);
while (!chunk.getBlockState(pos).isIn(EndTags.GEN_TERRAIN) && pos.getY() > 56) { while (!chunk.getBlockState(pos).isIn(EndTags.GEN_TERRAIN) && pos.getY() > 56 && !chunk.getBlockState(pos.down()).isOf(Blocks.CAVE_AIR)) {
pos.setY(pos.getY() - 1); pos.setY(pos.getY() - 1);
} }
minY = pos.getY(); minY = pos.getY();
minY = Math.max(minY, map2.get(x, z));
if (minY > 10) { if (minY > 10) {
float maxY = dist * height * getHeightClamp(world, 8, px, pz); float maxY = dist * height * getHeightClamp(world, 8, px, pz);
if (maxY > 0) { if (maxY > 0) {