Parallel cave generation & block fixing

This commit is contained in:
paulevsGitch 2021-06-21 21:38:56 +03:00
parent 4dce2d5d7e
commit 37394eba11
4 changed files with 243 additions and 235 deletions

View file

@ -1,6 +1,7 @@
package ru.betterend.util; package ru.betterend.util;
import java.util.Set; import java.util.Set;
import java.util.stream.IntStream;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@ -20,182 +21,183 @@ import ru.betterend.blocks.basis.FurBlock;
import ru.betterend.registry.EndBlocks; import ru.betterend.registry.EndBlocks;
public class BlockFixer { public class BlockFixer {
private static final MutableBlockPos POS = new MutableBlockPos();
private static final BlockState AIR = Blocks.AIR.defaultBlockState(); private static final BlockState AIR = Blocks.AIR.defaultBlockState();
private static final BlockState WATER = Blocks.WATER.defaultBlockState(); private static final BlockState WATER = Blocks.WATER.defaultBlockState();
public static void fixBlocks(LevelAccessor world, BlockPos start, BlockPos end) { public static void fixBlocks(LevelAccessor world, BlockPos start, BlockPos end) {
BlockState state; Set<BlockPos> doubleCheck = Sets.newConcurrentHashSet();
Set<BlockPos> doubleCheck = Sets.newHashSet(); int dx = end.getX() - start.getX() + 1;
for (int x = start.getX(); x <= end.getX(); x++) { int dz = end.getZ() - start.getZ() + 1;
POS.setX(x); int count = dx * dz;
for (int z = start.getZ(); z <= end.getZ(); z++) { IntStream.range(0, count).parallel().forEach(index -> {
POS.setZ(z); MutableBlockPos POS = new MutableBlockPos();
for (int y = start.getY(); y <= end.getY(); y++) { POS.setX((index % dx) + start.getX());
POS.setY(y); POS.setZ((index / dx) + start.getZ());
state = world.getBlockState(POS); BlockState state;
for (int y = start.getY(); y <= end.getY(); y++) {
POS.setY(y);
state = world.getBlockState(POS);
if (state.getBlock() instanceof FurBlock) { if (state.getBlock() instanceof FurBlock) {
doubleCheck.add(POS.immutable()); doubleCheck.add(POS.immutable());
} }
// Liquids // Liquids
else if (!state.getFluidState().isEmpty()) { else if (!state.getFluidState().isEmpty()) {
if (!state.canSurvive(world, POS)) { if (!state.canSurvive(world, POS)) {
BlocksHelper.setWithoutUpdate(world, POS, WATER); setWithoutUpdate(world, POS, WATER);
POS.setY(POS.getY() - 1);
state = world.getBlockState(POS);
while (!state.canSurvive(world, POS)) {
state = state.getFluidState().isEmpty() ? AIR : WATER;
BlocksHelper.setWithoutUpdate(world, POS, state);
POS.setY(POS.getY() - 1);
state = world.getBlockState(POS);
}
}
POS.setY(y - 1);
if (world.isEmptyBlock(POS)) {
POS.setY(y);
while (!world.getFluidState(POS).isEmpty()) {
BlocksHelper.setWithoutUpdate(world, POS, AIR);
POS.setY(POS.getY() + 1);
}
continue;
}
for (Direction dir : BlocksHelper.HORIZONTAL) {
if (world.isEmptyBlock(POS.relative(dir))) {
world.getLiquidTicks().scheduleTick(POS, state.getFluidState().getType(), 0);
break;
}
}
}
else if (state.is(EndBlocks.SMARAGDANT_CRYSTAL)) {
POS.setY(POS.getY() - 1); POS.setY(POS.getY() - 1);
if (world.isEmptyBlock(POS)) { state = world.getBlockState(POS);
while (!state.canSurvive(world, POS)) {
state = state.getFluidState().isEmpty() ? AIR : WATER;
setWithoutUpdate(world, POS, state);
POS.setY(POS.getY() - 1);
state = world.getBlockState(POS);
}
}
POS.setY(y - 1);
if (world.isEmptyBlock(POS)) {
POS.setY(y);
while (!world.getFluidState(POS).isEmpty()) {
setWithoutUpdate(world, POS, AIR);
POS.setY(POS.getY() + 1); POS.setY(POS.getY() + 1);
while (state.is(EndBlocks.SMARAGDANT_CRYSTAL)) { }
BlocksHelper.setWithoutUpdate(world, POS, AIR); continue;
}
for (Direction dir : BlocksHelper.HORIZONTAL) {
if (world.isEmptyBlock(POS.relative(dir))) {
world.getLiquidTicks().scheduleTick(POS, state.getFluidState().getType(), 0);
break;
}
}
}
else if (state.is(EndBlocks.SMARAGDANT_CRYSTAL)) {
POS.setY(POS.getY() - 1);
if (world.isEmptyBlock(POS)) {
POS.setY(POS.getY() + 1);
while (state.is(EndBlocks.SMARAGDANT_CRYSTAL)) {
setWithoutUpdate(world, POS, AIR);
POS.setY(POS.getY() + 1);
state = world.getBlockState(POS);
}
}
}
else if (state.getBlock() instanceof StalactiteBlock) {
if (!state.canSurvive(world, POS)) {
if (world.getBlockState(POS.above()).getBlock() instanceof StalactiteBlock) {
while (state.getBlock() instanceof StalactiteBlock) {
setWithoutUpdate(world, POS, AIR);
POS.setY(POS.getY() + 1); POS.setY(POS.getY() + 1);
state = world.getBlockState(POS); state = world.getBlockState(POS);
} }
} }
}
else if (state.getBlock() instanceof StalactiteBlock) {
if (!state.canSurvive(world, POS)) {
if (world.getBlockState(POS.above()).getBlock() instanceof StalactiteBlock) {
while (state.getBlock() instanceof StalactiteBlock) {
BlocksHelper.setWithoutUpdate(world, POS, AIR);
POS.setY(POS.getY() + 1);
state = world.getBlockState(POS);
}
}
else {
while (state.getBlock() instanceof StalactiteBlock) {
BlocksHelper.setWithoutUpdate(world, POS, AIR);
POS.setY(POS.getY() - 1);
state = world.getBlockState(POS);
}
}
}
}
else if (state.is(EndBlocks.CAVE_PUMPKIN)) {
if (!world.getBlockState(POS.above()).is(EndBlocks.CAVE_PUMPKIN_SEED)) {
BlocksHelper.setWithoutUpdate(world, POS, AIR);
}
}
else if (!state.canSurvive(world, POS)) {
// Chorus
if (state.is(Blocks.CHORUS_PLANT)) {
Set<BlockPos> ends = Sets.newHashSet();
Set<BlockPos> add = Sets.newHashSet();
ends.add(POS.immutable());
for (int i = 0; i < 64 && !ends.isEmpty(); i++) {
ends.forEach((pos) -> {
BlocksHelper.setWithoutUpdate(world, pos, AIR);
for (Direction dir : BlocksHelper.HORIZONTAL) {
BlockPos p = pos.relative(dir);
BlockState st = world.getBlockState(p);
if ((st.is(Blocks.CHORUS_PLANT) || st.is(Blocks.CHORUS_FLOWER)) && !st.canSurvive(world, p)) {
add.add(p);
}
}
BlockPos p = pos.above();
BlockState st = world.getBlockState(p);
if ((st.is(Blocks.CHORUS_PLANT) || st.is(Blocks.CHORUS_FLOWER)) && !st.canSurvive(world, p)) {
add.add(p);
}
});
ends.clear();
ends.addAll(add);
add.clear();
}
}
// Vines
else if (state.getBlock() instanceof BaseVineBlock) {
while (world.getBlockState(POS).getBlock() instanceof BaseVineBlock) {
BlocksHelper.setWithoutUpdate(world, POS, AIR);
POS.setY(POS.getY() - 1);
}
}
// Falling blocks
else if (state.getBlock() instanceof FallingBlock) {
BlockState falling = state;
POS.setY(POS.getY() - 1);
state = world.getBlockState(POS);
int ray = BlocksHelper.downRayRep(world, POS.immutable(), 64);
if (ray > 32) {
BlocksHelper.setWithoutUpdate(world, POS, Blocks.END_STONE.defaultBlockState());
if (world.getRandom().nextBoolean()) {
POS.setY(POS.getY() - 1);
state = world.getBlockState(POS);
BlocksHelper.setWithoutUpdate(world, POS, Blocks.END_STONE.defaultBlockState());
}
}
else {
POS.setY(y);
BlockState replacement = AIR;
for (Direction dir : BlocksHelper.HORIZONTAL) {
state = world.getBlockState(POS.relative(dir));
if (!state.getFluidState().isEmpty()) {
replacement = state;
break;
}
}
BlocksHelper.setWithoutUpdate(world, POS, replacement);
POS.setY(y - ray);
BlocksHelper.setWithoutUpdate(world, POS, falling);
}
}
// Blocks without support
else { else {
// Blue Vine while (state.getBlock() instanceof StalactiteBlock) {
if (state.getBlock() instanceof BlueVineBlock) { setWithoutUpdate(world, POS, AIR);
while (state.is(EndBlocks.BLUE_VINE) || state.is(EndBlocks.BLUE_VINE_LANTERN) || state.is(EndBlocks.BLUE_VINE_FUR)) { POS.setY(POS.getY() - 1);
BlocksHelper.setWithoutUpdate(world, POS, AIR); state = world.getBlockState(POS);
POS.setY(POS.getY() + 1);
state = world.getBlockState(POS);
}
}
// Double plants
if (state.getBlock() instanceof BaseDoublePlantBlock) {
BlocksHelper.setWithoutUpdate(world, POS, AIR);
POS.setY(POS.getY() + 1);
BlocksHelper.setWithoutUpdate(world, POS, AIR);
}
// Other blocks
else {
BlocksHelper.setWithoutUpdate(world, POS, getAirOrFluid(state));
} }
} }
} }
} }
else if (state.is(EndBlocks.CAVE_PUMPKIN)) {
if (!world.getBlockState(POS.above()).is(EndBlocks.CAVE_PUMPKIN_SEED)) {
setWithoutUpdate(world, POS, AIR);
}
}
else if (!state.canSurvive(world, POS)) {
// Chorus
if (state.is(Blocks.CHORUS_PLANT)) {
Set<BlockPos> ends = Sets.newHashSet();
Set<BlockPos> add = Sets.newHashSet();
ends.add(POS.immutable());
for (int i = 0; i < 64 && !ends.isEmpty(); i++) {
ends.forEach((pos) -> {
setWithoutUpdate(world, pos, AIR);
for (Direction dir : BlocksHelper.HORIZONTAL) {
BlockPos p = pos.relative(dir);
BlockState st = world.getBlockState(p);
if ((st.is(Blocks.CHORUS_PLANT) || st.is(Blocks.CHORUS_FLOWER)) && !st.canSurvive(world, p)) {
add.add(p);
}
}
BlockPos p = pos.above();
BlockState st = world.getBlockState(p);
if ((st.is(Blocks.CHORUS_PLANT) || st.is(Blocks.CHORUS_FLOWER)) && !st.canSurvive(world, p)) {
add.add(p);
}
});
ends.clear();
ends.addAll(add);
add.clear();
}
}
// Vines
else if (state.getBlock() instanceof BaseVineBlock) {
while (world.getBlockState(POS).getBlock() instanceof BaseVineBlock) {
setWithoutUpdate(world, POS, AIR);
POS.setY(POS.getY() - 1);
}
}
// Falling blocks
else if (state.getBlock() instanceof FallingBlock) {
BlockState falling = state;
POS.setY(POS.getY() - 1);
state = world.getBlockState(POS);
int ray = BlocksHelper.downRayRep(world, POS.immutable(), 64);
if (ray > 32) {
setWithoutUpdate(world, POS, Blocks.END_STONE.defaultBlockState());
if (world.getRandom().nextBoolean()) {
POS.setY(POS.getY() - 1);
state = world.getBlockState(POS);
setWithoutUpdate(world, POS, Blocks.END_STONE.defaultBlockState());
}
}
else {
POS.setY(y);
BlockState replacement = AIR;
for (Direction dir : BlocksHelper.HORIZONTAL) {
state = world.getBlockState(POS.relative(dir));
if (!state.getFluidState().isEmpty()) {
replacement = state;
break;
}
}
setWithoutUpdate(world, POS, replacement);
POS.setY(y - ray);
setWithoutUpdate(world, POS, falling);
}
}
// Blocks without support
else {
// Blue Vine
if (state.getBlock() instanceof BlueVineBlock) {
while (state.is(EndBlocks.BLUE_VINE) || state.is(EndBlocks.BLUE_VINE_LANTERN) || state.is(EndBlocks.BLUE_VINE_FUR)) {
setWithoutUpdate(world, POS, AIR);
POS.setY(POS.getY() + 1);
state = world.getBlockState(POS);
}
}
// Double plants
if (state.getBlock() instanceof BaseDoublePlantBlock) {
setWithoutUpdate(world, POS, AIR);
POS.setY(POS.getY() + 1);
setWithoutUpdate(world, POS, AIR);
}
// Other blocks
else {
setWithoutUpdate(world, POS, getAirOrFluid(state));
}
}
}
} }
} });
doubleCheck.forEach((pos) -> { doubleCheck.forEach((pos) -> {
if (!world.getBlockState(pos).canSurvive(world, pos)) { if (!world.getBlockState(pos).canSurvive(world, pos)) {
BlocksHelper.setWithoutUpdate(world, pos, AIR); setWithoutUpdate(world, pos, AIR);
} }
}); });
} }
@ -203,4 +205,10 @@ public class BlockFixer {
private static BlockState getAirOrFluid(BlockState state) { private static BlockState getAirOrFluid(BlockState state) {
return state.getFluidState().isEmpty() ? AIR : state.getFluidState().createLegacyBlock(); return state.getFluidState().isEmpty() ? AIR : state.getFluidState().createLegacyBlock();
} }
private static void setWithoutUpdate(LevelAccessor world, BlockPos pos, BlockState state) {
synchronized (world) {
BlocksHelper.setWithoutUpdate(world, pos, state);
}
}
} }

View file

@ -58,19 +58,17 @@ public abstract class EndCaveFeature extends DefaultFeature {
if (!caveBlocks.isEmpty()) { if (!caveBlocks.isEmpty()) {
if (biome != null) { if (biome != null) {
setBiomes(world, biome, caveBlocks); setBiomes(world, biome, caveBlocks);
Set<BlockPos> floorPositions = Sets.newHashSet(); Set<BlockPos> floorPositions = Sets.newConcurrentHashSet();
Set<BlockPos> ceilPositions = Sets.newHashSet(); Set<BlockPos> ceilPositions = Sets.newConcurrentHashSet();
MutableBlockPos mut = new MutableBlockPos(); caveBlocks.parallelStream().forEach((bpos) -> {
caveBlocks.forEach((bpos) -> { if (world.getBlockState(bpos).getMaterial().isReplaceable()) {
mut.set(bpos); BlockPos side = bpos.below();
if (world.getBlockState(mut).getMaterial().isReplaceable()) { if (world.getBlockState(side).is(TagAPI.GEN_TERRAIN)) {
mut.setY(bpos.getY() - 1); floorPositions.add(side);
if (world.getBlockState(mut).is(TagAPI.GEN_TERRAIN)) {
floorPositions.add(mut.immutable());
} }
mut.setY(bpos.getY() + 1); side = bpos.above();
if (world.getBlockState(mut).is(TagAPI.GEN_TERRAIN)) { if (world.getBlockState(side).is(TagAPI.GEN_TERRAIN)) {
ceilPositions.add(mut.immutable()); ceilPositions.add(side);
} }
} }
}); });

View file

@ -2,6 +2,7 @@ package ru.betterend.world.features.terrain.caves;
import java.util.Random; import java.util.Random;
import java.util.Set; import java.util.Set;
import java.util.stream.IntStream;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@ -30,47 +31,45 @@ public class RoundCaveFeature extends EndCaveFeature {
double hr = radius * 0.75; double hr = radius * 0.75;
double nr = radius * 0.25; double nr = radius * 0.25;
BlockState state; int dx = x2 - x1 + 1;
MutableBlockPos bpos = new MutableBlockPos(); int dz = z2 - z1 + 1;
Set<BlockPos> blocks = Sets.newHashSet(); int count = dx * dz;
for (int x = x1; x <= x2; x++) { Set<BlockPos> blocks = Sets.newConcurrentHashSet();
int xsq = x - center.getX(); IntStream.range(0, count).parallel().forEach(index -> {
xsq *= xsq; MutableBlockPos bpos = new MutableBlockPos();
int x = (index % dx) + x1;
int z = (index / dx) + z1;
bpos.setX(x); bpos.setX(x);
for (int z = z1; z <= z2; z++) { bpos.setZ(z);
int zsq = z - center.getZ(); int xsq = MHelper.sqr(x - center.getX());
zsq *= zsq; int zsq = MHelper.sqr(z - center.getZ());
bpos.setZ(z); int dxz = xsq + zsq;
for (int y = y1; y <= y2; y++) { BlockState state;
int ysq = y - center.getY(); for (int y = y1; y <= y2; y++) {
ysq *= 1.6; int ysq = (int) MHelper.sqr((y - center.getY()) * 1.6);
ysq *= ysq; double r = noise.eval(x * 0.1, y * 0.1, z * 0.1) * nr + hr;
double dist = dxz + ysq;
if (dist < r * r) {
bpos.setY(y); bpos.setY(y);
double r = noise.eval(x * 0.1, y * 0.1, z * 0.1) * nr + hr; state = world.getBlockState(bpos);
double dist = xsq + ysq + zsq; if (isReplaceable(state) && !isWaterNear(world, bpos)) {
if (dist < r * r) { blocks.add(bpos.immutable());
state = world.getBlockState(bpos);
if (isReplaceable(state) && !isWaterNear(world, bpos)) {
BlocksHelper.setWithoutUpdate(world, bpos, CAVE_AIR);
blocks.add(bpos.immutable());
while (state.getMaterial().equals(Material.LEAVES)) { while (state.getMaterial().equals(Material.LEAVES)) {
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, CAVE_AIR); bpos.setY(bpos.getY() - 1);
bpos.setY(bpos.getY() - 1); state = world.getBlockState(bpos);
state = world.getBlockState(bpos);
}
} }
} }
} }
} }
} });
blocks.forEach(bpos -> BlocksHelper.setWithoutUpdate(world, bpos, CAVE_AIR));
return blocks; return blocks;
} }

View file

@ -3,6 +3,7 @@ package ru.betterend.world.features.terrain.caves;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
import java.util.Set; import java.util.Set;
import java.util.stream.IntStream;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@ -15,6 +16,7 @@ import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap.Types; import net.minecraft.world.level.levelgen.Heightmap.Types;
import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.Feature;
@ -34,55 +36,56 @@ public class TunelCaveFeature extends EndCaveFeature {
if ((long) cx * (long) cx + (long) cz + (long) cz < 256) { if ((long) cx * (long) cx + (long) cz + (long) cz < 256) {
return Sets.newHashSet(); return Sets.newHashSet();
} }
int x1 = cx << 4; int x1 = cx << 4;
int z1 = cz << 4; int z1 = cz << 4;
int x2 = x1 + 16; int x2 = x1 + 16;
int z2 = z1 + 16; int z2 = z1 + 16;
int y2 = world.getHeight();
Random rand = new Random(world.getSeed()); Random rand = new Random(world.getSeed());
OpenSimplexNoise noiseH = new OpenSimplexNoise(rand.nextInt()); OpenSimplexNoise noiseH = new OpenSimplexNoise(rand.nextInt());
OpenSimplexNoise noiseV = new OpenSimplexNoise(rand.nextInt()); OpenSimplexNoise noiseV = new OpenSimplexNoise(rand.nextInt());
OpenSimplexNoise noiseD = new OpenSimplexNoise(rand.nextInt()); OpenSimplexNoise noiseD = new OpenSimplexNoise(rand.nextInt());
Set<BlockPos> positions = Sets.newHashSet(); Set<BlockPos> positions = Sets.newConcurrentHashSet();
MutableBlockPos pos = new MutableBlockPos();
float a = hasCaves(world, pos.set(x1, 0, z1)) ? 1F : 0F; float a = hasCaves(world, new BlockPos(x1, 0, z1)) ? 1F : 0F;
float b = hasCaves(world, pos.set(x2, 0, z1)) ? 1F : 0F; float b = hasCaves(world, new BlockPos(x2, 0, z1)) ? 1F : 0F;
float c = hasCaves(world, pos.set(x1, 0, z2)) ? 1F : 0F; float c = hasCaves(world, new BlockPos(x1, 0, z2)) ? 1F : 0F;
float d = hasCaves(world, pos.set(x2, 0, z2)) ? 1F : 0F; float d = hasCaves(world, new BlockPos(x2, 0, z2)) ? 1F : 0F;
for (int x = x1; x < x2; x++) { ChunkAccess chunk = world.getChunk(cx, cz);
pos.setX(x); IntStream.range(0, 256).parallel().forEach(index -> {
float dx = (float) (x - x1) / 16F; MutableBlockPos pos = new MutableBlockPos();
int x = index & 15;
int z = index >> 4;
int wheight = chunk.getHeight(Types.WORLD_SURFACE_WG, x, z);
float dx = x / 16F;
float dz = z / 16F;
pos.setX(x + x1);
pos.setZ(z + z1);
float da = Mth.lerp(dx, a, b); float da = Mth.lerp(dx, a, b);
float db = Mth.lerp(dx, c, d); float db = Mth.lerp(dx, c, d);
for (int z = z1; z < z2; z++) { float density = 1 - Mth.lerp(dz, da, db);
pos.setZ(z); if (density < 0.5) {
float dz = (float) (z - z1) / 16F; for (int y = 0; y < wheight; y++) {
float density = 1 - Mth.lerp(dz, da, db);
int wheight = world.getHeight(Types.WORLD_SURFACE_WG, x, z);
for (int y = 0; y < y2; y++) {
pos.setY(y); pos.setY(y);
float gradient = 1 - Mth.clamp((wheight - y) * 0.1F, 0F, 1F); float gradient = 1 - Mth.clamp((wheight - y) * 0.1F, 0F, 1F);
float val = Mth.abs((float) noiseH.eval(x * 0.02, y * 0.01, z * 0.02)); if (gradient > 0.5) {
float vert = Mth.sin((y + (float) noiseV.eval(x * 0.01, z * 0.01) * 20) * 0.1F) * 0.9F; break;
float dist = (float) noiseD.eval(x * 0.1, y * 0.1, z * 0.1) * 0.12F; }
float val = Mth.abs((float) noiseH.eval(pos.getX() * 0.02, y * 0.01, pos.getZ() * 0.02));
float vert = Mth.sin((y + (float) noiseV.eval(pos.getX() * 0.01, pos.getZ() * 0.01) * 20) * 0.1F) * 0.9F;
float dist = (float) noiseD.eval(pos.getX() * 0.1, y * 0.1, pos.getZ() * 0.1) * 0.12F;
val = (val + vert * vert + dist) + density + gradient; val = (val + vert * vert + dist) + density + gradient;
if (val < 0.15 && world.getBlockState(pos).is(TagAPI.GEN_TERRAIN) && noWaterNear(world, pos)) { if (val < 0.15 && world.getBlockState(pos).is(TagAPI.GEN_TERRAIN) && noWaterNear(world, pos)) {
BlocksHelper.setWithoutUpdate(world, pos, AIR);
positions.add(pos.immutable()); positions.add(pos.immutable());
int height = world.getHeight(Types.WORLD_SURFACE_WG, pos.getX(), pos.getZ());
if (height < pos.getY() + 4) {
while (pos.getY() < height && noWaterNear(world, pos)) {
pos.setY(pos.getY() + 1);
BlocksHelper.setWithoutUpdate(world, pos, AIR);
}
}
} }
} }
} }
} });
positions.forEach(bpos -> BlocksHelper.setWithoutUpdate(world, bpos, CAVE_AIR));
return positions; return positions;
} }