Code style changes, entities fixes

This commit is contained in:
paulevsGitch 2021-07-08 00:21:47 +03:00
parent 9d604b2d25
commit 44962e18b6
377 changed files with 5038 additions and 4914 deletions

View file

@ -1,12 +1,8 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
@ -19,6 +15,8 @@ import ru.bclib.util.MHelper;
import ru.bclib.world.features.DefaultFeature;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class BigAuroraCrystalFeature extends DefaultFeature {
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {

View file

@ -1,13 +1,10 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.FluidState;
@ -20,6 +17,8 @@ import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.BlockFixer;
import java.util.Random;
public class DesertLakeFeature extends DefaultFeature {
private static final BlockState END_STONE = Blocks.END_STONE.defaultBlockState();
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(15152);

View file

@ -1,14 +1,10 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
@ -23,6 +19,8 @@ import ru.bclib.world.features.DefaultFeature;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class FallenPillarFeature extends DefaultFeature {
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {

View file

@ -1,10 +1,6 @@
package ru.betterend.world.features.terrain;
import java.util.List;
import java.util.Random;
import com.google.common.collect.Lists;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
@ -21,6 +17,9 @@ import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBiomes;
import ru.betterend.registry.EndFeatures;
import java.util.List;
import java.util.Random;
public class FloatingSpireFeature extends SpireFeature {
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
@ -58,7 +57,8 @@ public class FloatingSpireFeature extends SpireFeature {
support.add(info.getPos().above());
}
return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
} else if (info.getState(Direction.UP, 3).isAir()) {
}
else if (info.getState(Direction.UP, 3).isAir()) {
return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceBuilderConfig()
.getUnderMaterial();
}

View file

@ -1,10 +1,6 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import java.util.function.Function;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
@ -41,6 +37,9 @@ import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndFeatures;
import ru.betterend.util.BlockFixer;
import java.util.Random;
import java.util.function.Function;
public class GeyserFeature extends DefaultFeature {
protected static final Function<BlockState, Boolean> REPLACE1;
protected static final Function<BlockState, Boolean> REPLACE2;

View file

@ -1,15 +1,9 @@
package ru.betterend.world.features.terrain;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.bclib.sdf.SDF;
@ -21,6 +15,10 @@ import ru.bclib.util.MHelper;
import ru.bclib.world.features.DefaultFeature;
import ru.betterend.registry.EndBlocks;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class IceStarFeature extends DefaultFeature {
private final float minSize;
private final float maxSize;
@ -53,7 +51,8 @@ public class IceStarFeature extends DefaultFeature {
if (angle > 0.01F && angle < 3.14F) {
Vector3f axis = MHelper.normalize(MHelper.cross(Vector3f.YP, point));
rotated = new SDFRotation().setRotation(axis, angle).setSource(spike);
} else if (angle > 1) {
}
else if (angle > 1) {
rotated = new SDFRotation().setRotation(Vector3f.YP, (float) Math.PI).setSource(spike);
}
sdf = (sdf == null) ? rotated : new SDFUnion().setSourceA(sdf).setSourceB(rotated);
@ -83,9 +82,11 @@ public class IceStarFeature extends DefaultFeature {
+ random.nextFloat() * randScale;
if (distance < ancientRadius) {
return ancient;
} else if (distance < denseRadius) {
}
else if (distance < denseRadius) {
return dense;
} else if (distance < iceRadius) {
}
else if (distance < iceRadius) {
return ice;
}
return info.getState();

View file

@ -1,12 +1,9 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.material.Material;
@ -20,6 +17,8 @@ import ru.bclib.world.features.DefaultFeature;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class ObsidianBoulderFeature extends DefaultFeature {
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {

View file

@ -1,12 +1,9 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.bclib.sdf.SDF;
@ -17,6 +14,8 @@ import ru.bclib.util.MHelper;
import ru.bclib.world.features.DefaultFeature;
import ru.betterend.noise.OpenSimplexNoise;
import java.util.Random;
public class OreLayerFeature extends DefaultFeature {
private static final SDFSphere SPHERE;
private static final SDFCoordModify NOISE;

View file

@ -1,19 +1,18 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.bclib.api.TagAPI;
import ru.bclib.util.BlocksHelper;
import ru.bclib.world.features.DefaultFeature;
import java.util.Random;
public class SingleBlockFeature extends DefaultFeature {
private final Block block;

View file

@ -1,13 +1,10 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.bclib.api.TagAPI;
@ -16,6 +13,8 @@ import ru.bclib.util.MHelper;
import ru.bclib.world.features.DefaultFeature;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class SmaragdantCrystalFeature extends DefaultFeature {
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {

View file

@ -1,11 +1,6 @@
package ru.betterend.world.features.terrain;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import com.google.common.collect.Lists;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
@ -29,6 +24,10 @@ import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBiomes;
import ru.betterend.registry.EndFeatures;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
public class SpireFeature extends DefaultFeature {
protected static final Function<BlockState, Boolean> REPLACE;
@ -63,7 +62,8 @@ public class SpireFeature extends DefaultFeature {
support.add(info.getPos().above());
}
return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
} else if (info.getState(Direction.UP, 3).isAir()) {
}
else if (info.getState(Direction.UP, 3).isAir()) {
return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceBuilderConfig()
.getUnderMaterial();
}

View file

@ -1,7 +1,5 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.util.Mth;
@ -9,7 +7,6 @@ import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.bclib.api.TagAPI;
@ -17,6 +14,8 @@ import ru.bclib.blocks.StalactiteBlock;
import ru.bclib.util.BlocksHelper;
import ru.bclib.world.features.DefaultFeature;
import java.util.Random;
public class StalactiteFeature extends DefaultFeature {
private final boolean ceiling;
private final Block[] ground;

View file

@ -1,14 +1,11 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import ru.bclib.blocks.BlockProperties;
@ -18,6 +15,8 @@ import ru.bclib.world.features.DefaultFeature;
import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import java.util.Random;
public class SulphurHillFeature extends DefaultFeature {
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
@ -80,7 +79,8 @@ public class SulphurHillFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, mut, rock);
mut.move(Direction.DOWN);
}
} else if (d < r1 * r1) {
}
else if (d < r1 * r1) {
BlocksHelper.setWithoutUpdate(world, mut, brimstone);
mut.move(Direction.DOWN);
state = world.getBlockState(mut);

View file

@ -1,10 +1,6 @@
package ru.betterend.world.features.terrain;
import java.util.Random;
import java.util.Set;
import com.google.common.collect.Sets;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Direction;
@ -12,7 +8,6 @@ import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
@ -27,6 +22,9 @@ import ru.betterend.noise.OpenSimplexNoise;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.BlockFixer;
import java.util.Random;
import java.util.Set;
public class SulphuricCaveFeature extends DefaultFeature {
private static final BlockState CAVE_AIR = Blocks.CAVE_AIR.defaultBlockState();
private static final BlockState WATER = Blocks.WATER.defaultBlockState();
@ -104,14 +102,16 @@ public class SulphuricCaveFeature extends DefaultFeature {
if (isReplaceable(state)) {
BlocksHelper.setWithoutUpdate(world, mut, y < waterLevel ? WATER : CAVE_AIR);
}
} else if (dist < r2 * r2) {
}
else if (dist < r2 * r2) {
state = world.getBlockState(mut);
if (state.is(TagAPI.GEN_TERRAIN) || state.is(Blocks.AIR)) {
double v = noise.eval(x * 0.1, y * 0.1, z * 0.1)
+ noise.eval(x * 0.03, y * 0.03, z * 0.03) * 0.5;
if (v > 0.4) {
brimstone.add(mut.immutable());
} else {
}
else {
BlocksHelper.setWithoutUpdate(world, mut, rock);
}
}

View file

@ -71,7 +71,8 @@ public class SulphuricLakeFeature extends DefaultFeature {
brimstone.add(POS.below(2));
}
}
} else {
}
else {
if (!isAbsoluteBorder(world, POS)) {
BlocksHelper.setWithoutUpdate(world, POS, Blocks.WATER);
world.getLiquidTicks().scheduleTick(POS, Fluids.WATER, 0);
@ -82,14 +83,16 @@ public class SulphuricLakeFeature extends DefaultFeature {
brimstone.add(POS.below(3));
}
}
} else {
}
else {
brimstone.add(POS.immutable());
if (random.nextBoolean()) {
brimstone.add(POS.below());
}
}
}
} else {
}
else {
BlocksHelper.setWithoutUpdate(world, POS, Blocks.WATER);
brimstone.remove(POS);
for (Direction dir : BlocksHelper.HORIZONTAL) {
@ -117,7 +120,8 @@ public class SulphuricLakeFeature extends DefaultFeature {
}
}
}
} else if (dist < r2) {
}
else if (dist < r2) {
POS.setY(getYOnSurface(world, x, z) - 1);
if (world.getBlockState(POS).is(TagAPI.GEN_TERRAIN)) {
brimstone.add(POS.immutable());

View file

@ -1,18 +1,12 @@
package ru.betterend.world.features.terrain.caves;
import java.util.Random;
import java.util.Set;
import java.util.function.Supplier;
import com.google.common.collect.Sets;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
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.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
@ -22,6 +16,10 @@ import ru.bclib.world.features.DefaultFeature;
import ru.betterend.util.BlockFixer;
import ru.betterend.world.biome.cave.EndCaveBiome;
import java.util.Random;
import java.util.Set;
import java.util.function.Supplier;
public class CaveChunkPopulatorFeature extends DefaultFeature {
private Supplier<EndCaveBiome> supplier;
@ -50,7 +48,7 @@ public class CaveChunkPopulatorFeature extends DefaultFeature {
}
protected void fillSets(int sx, int sz, ChunkAccess chunk, Set<BlockPos> floorPositions,
Set<BlockPos> ceilPositions, MutableBlockPos min, MutableBlockPos max) {
Set<BlockPos> ceilPositions, MutableBlockPos min, MutableBlockPos max) {
MutableBlockPos mut = new MutableBlockPos();
MutableBlockPos mut2 = new MutableBlockPos();
MutableBlockPos mut3 = new MutableBlockPos();
@ -108,7 +106,7 @@ public class CaveChunkPopulatorFeature extends DefaultFeature {
}
protected void placeFloor(WorldGenLevel world, EndCaveBiome biome, Set<BlockPos> floorPositions, Random random,
BlockState surfaceBlock) {
BlockState surfaceBlock) {
float density = biome.getFloorDensity();
floorPositions.forEach((pos) -> {
BlocksHelper.setWithoutUpdate(world, pos, surfaceBlock);

View file

@ -117,14 +117,14 @@ public abstract class EndCaveFeature extends DefaultFeature {
}
});
}
protected void placeWalls(WorldGenLevel world, EndCaveBiome biome, Set<BlockPos> positions, Random random) {
Set<BlockPos> placed = Sets.newHashSet();
positions.forEach(pos -> {
if (random.nextInt(4) == 0 && hasOpenSide(pos, positions)) {
BlockState wallBlock = biome.getWall(pos);
if (wallBlock != null) {
for (Vec3i offset: SPHERE) {
for (Vec3i offset : SPHERE) {
BlockPos wallPos = pos.offset(offset);
if (!positions.contains(wallPos) && !placed.contains(wallPos) && world.getBlockState(wallPos).is(TagAPI.GEN_TERRAIN)) {
wallBlock = biome.getWall(wallPos);
@ -136,9 +136,9 @@ public abstract class EndCaveFeature extends DefaultFeature {
}
});
}
private boolean hasOpenSide(BlockPos pos, Set<BlockPos> positions) {
for (Direction dir: BlocksHelper.DIRECTIONS) {
for (Direction dir : BlocksHelper.DIRECTIONS) {
if (!positions.contains(pos.relative(dir))) {
return true;
}
@ -225,7 +225,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
}
return false;
}
protected boolean biomeMissingCaves(WorldGenLevel world, BlockPos pos) {
for (int x = -2; x < 3; x++) {
for (int z = -2; z < 3; z++) {
@ -239,7 +239,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
}
return false;
}
static {
List<Vec3i> prePos = Lists.newArrayList();
int radius = 5;
@ -256,6 +256,6 @@ public abstract class EndCaveFeature extends DefaultFeature {
}
}
}
SPHERE = prePos.toArray(new Vec3i[] {});
SPHERE = prePos.toArray(new Vec3i[]{});
}
}

View file

@ -1,11 +1,6 @@
package ru.betterend.world.features.terrain.caves;
import java.util.Random;
import java.util.Set;
import java.util.stream.IntStream;
import com.google.common.collect.Sets;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.world.level.WorldGenLevel;
@ -16,21 +11,25 @@ import ru.bclib.util.BlocksHelper;
import ru.bclib.util.MHelper;
import ru.betterend.noise.OpenSimplexNoise;
import java.util.Random;
import java.util.Set;
import java.util.stream.IntStream;
public class RoundCaveFeature extends EndCaveFeature {
@Override
protected Set<BlockPos> generate(WorldGenLevel world, BlockPos center, int radius, Random random) {
OpenSimplexNoise noise = new OpenSimplexNoise(MHelper.getSeed(534, center.getX(), center.getZ()));
int x1 = center.getX() - radius - 5;
int z1 = center.getZ() - radius - 5;
int x2 = center.getX() + radius + 5;
int z2 = center.getZ() + radius + 5;
int y1 = MHelper.floor(center.getY() - (radius + 5) / 1.6);
int y2 = MHelper.floor(center.getY() + (radius + 5) / 1.6);
double hr = radius * 0.75;
double nr = radius * 0.25;
int dx = x2 - x1 + 1;
int dz = z2 - z1 + 1;
int count = dx * dz;
@ -54,12 +53,12 @@ public class RoundCaveFeature extends EndCaveFeature {
state = world.getBlockState(bpos);
if (isReplaceable(state) && !isWaterNear(world, bpos)) {
blocks.add(bpos.immutable());
while (state.getMaterial().equals(Material.LEAVES)) {
bpos.setY(bpos.getY() + 1);
state = world.getBlockState(bpos);
}
bpos.setY(y - 1);
while (state.getMaterial().equals(Material.LEAVES)) {
bpos.setY(bpos.getY() - 1);
@ -70,10 +69,10 @@ public class RoundCaveFeature extends EndCaveFeature {
}
});
blocks.forEach(bpos -> BlocksHelper.setWithoutUpdate(world, bpos, CAVE_AIR));
return blocks;
}
private boolean isReplaceable(BlockState state) {
return state.is(TagAPI.GEN_TERRAIN)
|| state.getMaterial().isReplaceable()

View file

@ -35,24 +35,24 @@ public class TunelCaveFeature extends EndCaveFeature {
if ((long) cx * (long) cx + (long) cz + (long) cz < 256) {
return Sets.newHashSet();
}
int x1 = cx << 4;
int z1 = cz << 4;
int x2 = x1 + 16;
int z2 = z1 + 16;
Random rand = new Random(world.getSeed());
OpenSimplexNoise noiseH = new OpenSimplexNoise(rand.nextInt());
OpenSimplexNoise noiseV = new OpenSimplexNoise(rand.nextInt());
OpenSimplexNoise noiseD = new OpenSimplexNoise(rand.nextInt());
Set<BlockPos> positions = Sets.newConcurrentHashSet();
float a = hasCaves(world, new BlockPos(x1, 0, z1)) ? 1F : 0F;
float b = hasCaves(world, new BlockPos(x2, 0, z1)) ? 1F : 0F;
float c = hasCaves(world, new BlockPos(x1, 0, z2)) ? 1F : 0F;
float d = hasCaves(world, new BlockPos(x2, 0, z2)) ? 1F : 0F;
ChunkAccess chunk = world.getChunk(cx, cz);
IntStream.range(0, 256).parallel().forEach(index -> {
MutableBlockPos pos = new MutableBlockPos();
@ -84,17 +84,17 @@ public class TunelCaveFeature extends EndCaveFeature {
}
});
positions.forEach(bpos -> BlocksHelper.setWithoutUpdate(world, bpos, CAVE_AIR));
return positions;
}
private boolean noWaterNear(WorldGenLevel world, BlockPos pos) {
BlockPos above1 = pos.above();
BlockPos above2 = pos.above(2);
if (!world.getFluidState(above1).isEmpty() || !world.getFluidState(above2).isEmpty()) {
return false;
}
for (Direction dir: BlocksHelper.HORIZONTAL) {
for (Direction dir : BlocksHelper.HORIZONTAL) {
if (!world.getFluidState(above1.relative(dir)).isEmpty()) {
return false;
}
@ -104,7 +104,7 @@ public class TunelCaveFeature extends EndCaveFeature {
}
return true;
}
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
final Random random = featureConfig.random();
@ -117,12 +117,12 @@ public class TunelCaveFeature extends EndCaveFeature {
if (biomeMissingCaves(world, pos)) {
return false;
}
Set<BlockPos> caveBlocks = generate(world, pos, random);
if (caveBlocks.isEmpty()) {
return false;
}
Map<EndCaveBiome, Set<BlockPos>> floorSets = Maps.newHashMap();
Map<EndCaveBiome, Set<BlockPos>> ceilSets = Maps.newHashMap();
MutableBlockPos mut = new MutableBlockPos();
@ -157,11 +157,11 @@ public class TunelCaveFeature extends EndCaveFeature {
}
});
caveBlocks.removeAll(remove);
if (caveBlocks.isEmpty()) {
return true;
}
floorSets.forEach((biome, floorPositions) -> {
BlockState surfaceBlock = biome.getBiome().getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
placeFloor(world, biome, floorPositions, random, surfaceBlock);
@ -180,7 +180,7 @@ public class TunelCaveFeature extends EndCaveFeature {
protected Set<BlockPos> generate(WorldGenLevel world, BlockPos center, int radius, Random random) {
return null;
}
@Override
protected void placeFloor(WorldGenLevel world, EndCaveBiome biome, Set<BlockPos> floorPositions, Random random, BlockState surfaceBlock) {
float density = biome.getFloorDensity() * 0.2F;
@ -213,14 +213,14 @@ public class TunelCaveFeature extends EndCaveFeature {
}
});
}
protected boolean hasCaves(WorldGenLevel world, BlockPos pos) {
return hasCavesInBiome(world, pos.offset(-8, 0, -8)) &&
hasCavesInBiome(world, pos.offset(8, 0, -8)) &&
hasCavesInBiome(world, pos.offset(-8, 0, 8)) &&
hasCavesInBiome(world, pos.offset(8, 0, 8));
}
protected boolean hasCavesInBiome(WorldGenLevel world, BlockPos pos) {
Biome biome = world.getBiome(pos);
BCLBiome endBiome = BiomeAPI.getFromBiome(biome);