Fixed caves

This commit is contained in:
paulevsGitch 2021-01-11 13:10:53 +03:00
parent 0dc6a0dd73
commit 9f99a0e99e

View file

@ -41,7 +41,7 @@ public class RoundCaveFeature extends DefaultFeature {
} }
int radius = MHelper.randRange(10, 30, random); int radius = MHelper.randRange(10, 30, random);
int bottom = BlocksHelper.upRay(world, new BlockPos(pos.getX(), 0, pos.getZ()), 32) + radius + 5; /*int bottom = BlocksHelper.upRay(world, new BlockPos(pos.getX(), 0, pos.getZ()), 32) + radius + 5;
int top = world.getTopY(Heightmap.Type.WORLD_SURFACE, pos.getX(), pos.getZ()); int top = world.getTopY(Heightmap.Type.WORLD_SURFACE, pos.getX(), pos.getZ());
Mutable bpos = new Mutable(); Mutable bpos = new Mutable();
@ -53,6 +53,32 @@ public class RoundCaveFeature extends DefaultFeature {
} }
top -= radius * 1.3F + 5; top -= radius * 1.3F + 5;
if (top <= bottom) {
return false;
}*/
int top = world.getTopY(Heightmap.Type.WORLD_SURFACE_WG, pos.getX(), pos.getZ());
Mutable bpos = new Mutable();
bpos.setX(pos.getX());
bpos.setZ(pos.getZ());
bpos.setY(top);
BlockState state = world.getBlockState(bpos);
while (!state.isIn(EndTags.GEN_TERRAIN) && bpos.getY() > 5) {
bpos.setY(bpos.getY() - 1);
state = world.getBlockState(bpos);
}
if (bpos.getY() < 10) {
return false;
}
top = (int) (bpos.getY() - (radius * 1.3F + 5));
while (state.isIn(EndTags.GEN_TERRAIN) || state.isOf(Blocks.WATER) && bpos.getY() > 5) {
bpos.setY(bpos.getY() - 1);
state = world.getBlockState(bpos);
}
int bottom = (int) (bpos.getY() + radius * 1.3F + 5);
if (top <= bottom) { if (top <= bottom) {
return false; return false;
} }
@ -90,7 +116,7 @@ public class RoundCaveFeature extends DefaultFeature {
double r2 = r + 5; double r2 = r + 5;
double dist = xsq + ysq + zsq; double dist = xsq + ysq + zsq;
if (dist < r * r) { if (dist < r * r) {
BlockState state = world.getBlockState(bpos); state = world.getBlockState(bpos);
if (isReplaceable(state)) { if (isReplaceable(state)) {
BlocksHelper.setWithoutUpdate(world, bpos, CAVE_AIR); BlocksHelper.setWithoutUpdate(world, bpos, CAVE_AIR);
@ -113,7 +139,7 @@ public class RoundCaveFeature extends DefaultFeature {
} }
} }
else if (dist < r2 * r2) { else if (dist < r2 * r2) {
BlockState state = world.getBlockState(bpos); state = world.getBlockState(bpos);
if (!state.getFluidState().isEmpty()) { if (!state.getFluidState().isEmpty()) {
BlocksHelper.setWithoutUpdate(world, bpos, Blocks.END_STONE.getDefaultState()); BlocksHelper.setWithoutUpdate(world, bpos, Blocks.END_STONE.getDefaultState());
} }
@ -150,11 +176,11 @@ public class RoundCaveFeature extends DefaultFeature {
float vx = (float) Math.sin(angleY); float vx = (float) Math.sin(angleY);
float vz = (float) Math.sin(angleY); float vz = (float) Math.sin(angleY);
prism = new SDFRotation().setRotation(new Vector3f(vx, 0, vz), random.nextFloat()).setSource(prism); prism = new SDFRotation().setRotation(new Vector3f(vx, 0, vz), random.nextFloat()).setSource(prism);
prism.setReplaceFunction((state) -> { prism.setReplaceFunction((bState) -> {
return state.getMaterial().isReplaceable() return bState.getMaterial().isReplaceable()
|| state.isIn(EndTags.GEN_TERRAIN) || bState.isIn(EndTags.GEN_TERRAIN)
|| state.getMaterial().equals(Material.PLANT) || bState.getMaterial().equals(Material.PLANT)
|| state.getMaterial().equals(Material.LEAVES); || bState.getMaterial().equals(Material.LEAVES);
}); });
prism.fillRecursive(world, pos); prism.fillRecursive(world, pos);
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.AURORA_CRYSTAL); BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.AURORA_CRYSTAL);