Update to BCLib 0.3.0

This commit is contained in:
paulevsGitch 2021-07-20 00:39:58 +03:00
parent 1a52251af0
commit b2431153dc
294 changed files with 7484 additions and 1440 deletions

View file

@ -34,11 +34,16 @@ public class BigAuroraCrystalFeature extends DefaultFeature {
pos = new BlockPos(pos.getX(), y, pos.getZ());
int height = MHelper.randRange(5, 25, random);
SDF prism = new SDFHexPrism().setHeight(height).setRadius(MHelper.randRange(1.7F, 3F, random)).setBlock(EndBlocks.AURORA_CRYSTAL);
SDF prism = new SDFHexPrism().setHeight(height)
.setRadius(MHelper.randRange(1.7F, 3F, random))
.setBlock(EndBlocks.AURORA_CRYSTAL);
Vector3f vec = MHelper.randomHorizontal(random);
prism = new SDFRotation().setRotation(vec, random.nextFloat()).setSource(prism);
prism.setReplaceFunction((bState) -> {
return bState.getMaterial().isReplaceable() || bState.is(TagAPI.GEN_TERRAIN) || bState.getMaterial().equals(Material.PLANT) || bState.getMaterial().equals(Material.LEAVES);
return bState.getMaterial().isReplaceable() || bState.is(TagAPI.GEN_TERRAIN) || bState.getMaterial()
.equals(Material.PLANT) || bState
.getMaterial()
.equals(Material.LEAVES);
});
prism.fillRecursive(world, pos);
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.AURORA_CRYSTAL);

View file

@ -109,7 +109,11 @@ public class DesertLakeFeature extends DefaultFeature {
size *= 0.8;
add = 5;
}
double r = (add * 1.8 + radius * (NOISE.eval(x * 0.2, y * 0.2, z * 0.2) * 0.25 + 0.75)) - 1.0 / size;
double r = (add * 1.8 + radius * (NOISE.eval(
x * 0.2,
y * 0.2,
z * 0.2
) * 0.25 + 0.75)) - 1.0 / size;
if (r > 0) {
r *= r;
if (x2 + z2 <= r) {
@ -119,12 +123,23 @@ public class DesertLakeFeature extends DefaultFeature {
}
pos = POS.below();
if (world.getBlockState(pos).is(TagAPI.GEN_TERRAIN)) {
state = world.getBiome(pos).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
state = world.getBiome(pos)
.getGenerationSettings()
.getSurfaceBuilderConfig()
.getTopMaterial();
if (y > waterLevel + 1) BlocksHelper.setWithoutUpdate(world, pos, state);
else if (y > waterLevel)
BlocksHelper.setWithoutUpdate(world, pos, random.nextBoolean() ? state : EndBlocks.ENDSTONE_DUST.defaultBlockState());
BlocksHelper.setWithoutUpdate(
world,
pos,
random.nextBoolean() ? state : EndBlocks.ENDSTONE_DUST.defaultBlockState()
);
else
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.ENDSTONE_DUST.defaultBlockState());
BlocksHelper.setWithoutUpdate(
world,
pos,
EndBlocks.ENDSTONE_DUST.defaultBlockState()
);
}
}
}
@ -169,7 +184,8 @@ public class DesertLakeFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.ENDSTONE_DUST.defaultBlockState());
}
pos = POS.above();
while (canReplace(state = world.getBlockState(pos)) && !state.isAir() && state.getFluidState().isEmpty()) {
while (canReplace(state = world.getBlockState(pos)) && !state.isAir() && state.getFluidState()
.isEmpty()) {
BlocksHelper.setWithoutUpdate(world, pos, pos.getY() < waterLevel ? WATER : AIR);
pos = pos.above();
}
@ -182,12 +198,23 @@ public class DesertLakeFeature extends DefaultFeature {
}
else if (y < waterLevel) {
if (world.isEmptyBlock(POS.above())) {
state = world.getBiome(POS).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
BlocksHelper.setWithoutUpdate(world, POS, random.nextBoolean() ? state : EndBlocks.ENDSTONE_DUST.defaultBlockState());
state = world.getBiome(POS)
.getGenerationSettings()
.getSurfaceBuilderConfig()
.getTopMaterial();
BlocksHelper.setWithoutUpdate(
world,
POS,
random.nextBoolean() ? state : EndBlocks.ENDSTONE_DUST.defaultBlockState()
);
BlocksHelper.setWithoutUpdate(world, POS.below(), END_STONE);
}
else {
BlocksHelper.setWithoutUpdate(world, POS, EndBlocks.ENDSTONE_DUST.defaultBlockState());
BlocksHelper.setWithoutUpdate(
world,
POS,
EndBlocks.ENDSTONE_DUST.defaultBlockState()
);
BlocksHelper.setWithoutUpdate(world, POS.below(), END_STONE);
}
}
@ -197,12 +224,21 @@ public class DesertLakeFeature extends DefaultFeature {
}
}
BlockFixer.fixBlocks(world, new BlockPos(minX - 2, waterLevel - 2, minZ - 2), new BlockPos(maxX + 2, blockPos.getY() + 20, maxZ + 2));
BlockFixer.fixBlocks(
world,
new BlockPos(minX - 2, waterLevel - 2, minZ - 2),
new BlockPos(maxX + 2, blockPos.getY() + 20, maxZ + 2)
);
return true;
}
private boolean canReplace(BlockState state) {
return state.getMaterial().isReplaceable() || state.is(TagAPI.GEN_TERRAIN) || state.is(EndBlocks.ENDSTONE_DUST) || state.getMaterial().equals(Material.PLANT) || state.getMaterial().equals(Material.WATER_PLANT);
return state.getMaterial()
.isReplaceable() || state.is(TagAPI.GEN_TERRAIN) || state.is(EndBlocks.ENDSTONE_DUST) || state.getMaterial()
.equals(
Material.PLANT) || state
.getMaterial()
.equals(Material.WATER_PLANT);
}
}

View file

@ -109,7 +109,11 @@ public class EndLakeFeature extends DefaultFeature {
size *= 0.8;
add = 5;
}
double r = (add * 1.8 + radius * (NOISE.eval(x * 0.2, y * 0.2, z * 0.2) * 0.25 + 0.75)) - 1.0 / size;
double r = (add * 1.8 + radius * (NOISE.eval(
x * 0.2,
y * 0.2,
z * 0.2
) * 0.25 + 0.75)) - 1.0 / size;
if (r > 0) {
r *= r;
if (x2 + z2 <= r) {
@ -119,12 +123,23 @@ public class EndLakeFeature extends DefaultFeature {
}
pos = POS.below();
if (world.getBlockState(pos).is(TagAPI.GEN_TERRAIN)) {
state = world.getBiome(pos).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
state = world.getBiome(pos)
.getGenerationSettings()
.getSurfaceBuilderConfig()
.getTopMaterial();
if (y > waterLevel + 1) BlocksHelper.setWithoutUpdate(world, pos, state);
else if (y > waterLevel)
BlocksHelper.setWithoutUpdate(world, pos, random.nextBoolean() ? state : EndBlocks.ENDSTONE_DUST.defaultBlockState());
BlocksHelper.setWithoutUpdate(
world,
pos,
random.nextBoolean() ? state : EndBlocks.ENDSTONE_DUST.defaultBlockState()
);
else
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.ENDSTONE_DUST.defaultBlockState());
BlocksHelper.setWithoutUpdate(
world,
pos,
EndBlocks.ENDSTONE_DUST.defaultBlockState()
);
}
}
}
@ -169,7 +184,8 @@ public class EndLakeFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.ENDSTONE_DUST.defaultBlockState());
}
pos = POS.above();
while (canReplace(state = world.getBlockState(pos)) && !state.isAir() && state.getFluidState().isEmpty()) {
while (canReplace(state = world.getBlockState(pos)) && !state.isAir() && state.getFluidState()
.isEmpty()) {
BlocksHelper.setWithoutUpdate(world, pos, pos.getY() < waterLevel ? WATER : AIR);
pos = pos.above();
}
@ -177,8 +193,15 @@ public class EndLakeFeature extends DefaultFeature {
// Make border
else if (y < waterLevel && y2 + x2 + z2 <= rb) {
if (world.isEmptyBlock(POS.above())) {
state = world.getBiome(POS).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
BlocksHelper.setWithoutUpdate(world, POS, random.nextBoolean() ? state : EndBlocks.ENDSTONE_DUST.defaultBlockState());
state = world.getBiome(POS)
.getGenerationSettings()
.getSurfaceBuilderConfig()
.getTopMaterial();
BlocksHelper.setWithoutUpdate(
world,
POS,
random.nextBoolean() ? state : EndBlocks.ENDSTONE_DUST.defaultBlockState()
);
BlocksHelper.setWithoutUpdate(world, POS.below(), END_STONE);
}
else {
@ -191,12 +214,21 @@ public class EndLakeFeature extends DefaultFeature {
}
}
BlockFixer.fixBlocks(world, new BlockPos(minX - 2, waterLevel - 2, minZ - 2), new BlockPos(maxX + 2, blockPos.getY() + 20, maxZ + 2));
BlockFixer.fixBlocks(
world,
new BlockPos(minX - 2, waterLevel - 2, minZ - 2),
new BlockPos(maxX + 2, blockPos.getY() + 20, maxZ + 2)
);
return true;
}
private boolean canReplace(BlockState state) {
return state.getMaterial().isReplaceable() || state.is(TagAPI.GEN_TERRAIN) || state.is(EndBlocks.ENDSTONE_DUST) || state.getMaterial().equals(Material.PLANT) || state.getMaterial().equals(Material.WATER_PLANT);
return state.getMaterial()
.isReplaceable() || state.is(TagAPI.GEN_TERRAIN) || state.is(EndBlocks.ENDSTONE_DUST) || state.getMaterial()
.equals(
Material.PLANT) || state
.getMaterial()
.equals(Material.WATER_PLANT);
}
}

View file

@ -27,14 +27,20 @@ public class FallenPillarFeature extends DefaultFeature {
final Random random = featureConfig.random();
BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
pos = getPosOnSurface(world, new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16)));
pos = getPosOnSurface(
world,
new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16))
);
if (!world.getBlockState(pos.below(5)).is(TagAPI.GEN_TERRAIN)) {
return false;
}
float height = MHelper.randRange(20F, 40F, random);
float radius = MHelper.randRange(2F, 4F, random);
SDF pillar = new SDFCappedCone().setRadius1(radius).setRadius2(radius).setHeight(height * 0.5F).setBlock(Blocks.OBSIDIAN);
SDF pillar = new SDFCappedCone().setRadius1(radius)
.setRadius2(radius)
.setHeight(height * 0.5F)
.setBlock(Blocks.OBSIDIAN);
pillar = new SDFTranslate().setTranslate(0, radius * 0.5F - 2, 0).setSource(pillar);
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
pillar = new SDFDisplacement().setFunction((vec) -> {
@ -51,7 +57,8 @@ public class FallenPillarFeature extends DefaultFeature {
}
return info.getState();
}).setReplaceFunction((state) -> {
return state.getMaterial().isReplaceable() || state.is(TagAPI.GEN_TERRAIN) || state.getMaterial().equals(Material.PLANT);
return state.getMaterial().isReplaceable() || state.is(TagAPI.GEN_TERRAIN) || state.getMaterial()
.equals(Material.PLANT);
}).fillRecursive(world, pos);
return true;

View file

@ -28,7 +28,11 @@ public class FloatingSpireFeature extends SpireFeature {
final WorldGenLevel world = featureConfig.level();
final ChunkGenerator chunkGenerator = featureConfig.chunkGenerator();
int minY = getYOnSurface(world, pos.getX(), pos.getZ());
int y = minY > 57 ? MHelper.floor(MHelper.randRange(minY, minY * 2, random) * 0.5F + 32) : MHelper.randRange(64, 192, random);
int y = minY > 57 ? MHelper.floor(MHelper.randRange(minY, minY * 2, random) * 0.5F + 32) : MHelper.randRange(
64,
192,
random
);
pos = new BlockPos(pos.getX(), y, pos.getZ());
SDF sdf = new SDFSphere().setRadius(MHelper.randRange(2, 3, random)).setBlock(Blocks.END_STONE);
@ -45,7 +49,11 @@ public class FloatingSpireFeature extends SpireFeature {
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
sdf = new SDFDisplacement().setFunction((vec) -> {
return (float) (Math.abs(noise.eval(vec.x() * 0.1, vec.y() * 0.1, vec.z() * 0.1)) * 3F + Math.abs(noise.eval(vec.x() * 0.3, vec.y() * 0.3 + 100, vec.z() * 0.3)) * 1.3F);
return (float) (Math.abs(noise.eval(
vec.x() * 0.1,
vec.y() * 0.1,
vec.z() * 0.1
)) * 3F + Math.abs(noise.eval(vec.x() * 0.3, vec.y() * 0.3 + 100, vec.z() * 0.3)) * 1.3F);
}).setSource(sdf);
final BlockPos center = pos;
List<BlockPos> support = Lists.newArrayList();
@ -57,7 +65,10 @@ public class FloatingSpireFeature extends SpireFeature {
return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
}
else if (info.getState(Direction.UP, 3).isAir()) {
return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceBuilderConfig().getUnderMaterial();
return world.getBiome(info.getPos())
.getGenerationSettings()
.getSurfaceBuilderConfig()
.getUnderMaterial();
}
return info.getState();
});
@ -65,7 +76,8 @@ public class FloatingSpireFeature extends SpireFeature {
support.forEach((bpos) -> {
if (BiomeAPI.getFromBiome(world.getBiome(bpos)) == EndBiomes.BLOSSOMING_SPIRES) {
EndFeatures.TENANEA_BUSH.getFeature().place(new FeaturePlaceContext<>(world, chunkGenerator, random, bpos, null));
EndFeatures.TENANEA_BUSH.getFeature()
.place(new FeaturePlaceContext<>(world, chunkGenerator, random, bpos, null));
}
});

View file

@ -72,7 +72,10 @@ public class GeyserFeature extends DefaultFeature {
int halfHeight = MHelper.randRange(10, 20, random);
float radius1 = halfHeight * 0.5F;
float radius2 = halfHeight * 0.1F + 0.5F;
SDF sdf = new SDFCappedCone().setHeight(halfHeight).setRadius1(radius1).setRadius2(radius2).setBlock(EndBlocks.SULPHURIC_ROCK.stone);
SDF sdf = new SDFCappedCone().setHeight(halfHeight)
.setRadius1(radius1)
.setRadius2(radius2)
.setBlock(EndBlocks.SULPHURIC_ROCK.stone);
sdf = new SDFTranslate().setTranslate(0, halfHeight - 3, 0).setSource(sdf);
int count = halfHeight;
@ -81,9 +84,15 @@ public class GeyserFeature extends DefaultFeature {
float delta = (float) i / (float) (count - 1);
float radius = Mth.lerp(delta, radius1, radius2) * 1.3F;
SDF bowl = new SDFCappedCone().setHeight(radius).setRadius1(0).setRadius2(radius).setBlock(EndBlocks.SULPHURIC_ROCK.stone);
SDF bowl = new SDFCappedCone().setHeight(radius)
.setRadius1(0)
.setRadius2(radius)
.setBlock(EndBlocks.SULPHURIC_ROCK.stone);
SDF brimstone = new SDFCappedCone().setHeight(radius).setRadius1(0).setRadius2(radius).setBlock(EndBlocks.BRIMSTONE);
SDF brimstone = new SDFCappedCone().setHeight(radius)
.setRadius1(0)
.setRadius2(radius)
.setBlock(EndBlocks.BRIMSTONE);
brimstone = new SDFTranslate().setTranslate(0, 2F, 0).setSource(brimstone);
bowl = new SDFSubtraction().setSourceA(bowl).setSourceB(brimstone);
bowl = new SDFUnion().setSourceA(brimstone).setSourceB(bowl);
@ -172,7 +181,11 @@ public class GeyserFeature extends DefaultFeature {
}
for (int i = 0; i < 150; i++) {
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 4 + 0.5), -halfHeight - 10, MHelper.floor(random.nextGaussian() * 4 + 0.5));
mut.set(pos)
.move(MHelper.floor(random.nextGaussian() * 4 + 0.5),
-halfHeight - 10,
MHelper.floor(random.nextGaussian() * 4 + 0.5)
);
float distRaw = MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ());
int dist = MHelper.floor(6 - distRaw) + random.nextInt(2);
if (dist >= 0) {
@ -188,12 +201,18 @@ public class GeyserFeature extends DefaultFeature {
for (Direction dir : HORIZONTAL) {
BlockPos p = mut.relative(dir);
if (random.nextBoolean() && world.getBlockState(p).is(Blocks.WATER)) {
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TUBE_WORM.defaultBlockState().setValue(HorizontalDirectionalBlock.FACING, dir));
BlocksHelper.setWithoutUpdate(
world,
p,
EndBlocks.TUBE_WORM.defaultBlockState()
.setValue(HorizontalDirectionalBlock.FACING, dir)
);
}
}
mut.setY(mut.getY() + 1);
}
state = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState().setValue(HydrothermalVentBlock.ACTIVATED, distRaw < 2);
state = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState()
.setValue(HydrothermalVentBlock.ACTIVATED, distRaw < 2);
BlocksHelper.setWithoutUpdate(world, mut, state);
mut.setY(mut.getY() + 1);
state = world.getBlockState(mut);
@ -207,7 +226,11 @@ public class GeyserFeature extends DefaultFeature {
}
for (int i = 0; i < 10; i++) {
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 0.7 + 0.5), -halfHeight - 10, MHelper.floor(random.nextGaussian() * 0.7 + 0.5));
mut.set(pos)
.move(MHelper.floor(random.nextGaussian() * 0.7 + 0.5),
-halfHeight - 10,
MHelper.floor(random.nextGaussian() * 0.7 + 0.5)
);
float distRaw = MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ());
int dist = MHelper.floor(6 - distRaw) + random.nextInt(2);
if (dist >= 0) {
@ -221,7 +244,8 @@ public class GeyserFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone);
mut.setY(mut.getY() + 1);
}
state = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState().setValue(HydrothermalVentBlock.ACTIVATED, distRaw < 2);
state = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState()
.setValue(HydrothermalVentBlock.ACTIVATED, distRaw < 2);
BlocksHelper.setWithoutUpdate(world, mut, state);
mut.setY(mut.getY() + 1);
state = world.getBlockState(mut);
@ -234,7 +258,8 @@ public class GeyserFeature extends DefaultFeature {
}
}
EndFeatures.SULPHURIC_LAKE.getFeature().place(new FeaturePlaceContext<>(world, chunkGenerator, random, pos, null));
EndFeatures.SULPHURIC_LAKE.getFeature()
.place(new FeaturePlaceContext<>(world, chunkGenerator, random, pos, null));
double distance = radius1 * 1.7;
BlockPos start = pos.offset(-distance, -halfHeight - 15 - distance, -distance);
@ -260,7 +285,8 @@ public class GeyserFeature extends DefaultFeature {
};
IGNORE = (state) -> {
return state.is(Blocks.WATER) || state.is(Blocks.CAVE_AIR) || state.is(EndBlocks.SULPHURIC_ROCK.stone) || state.is(EndBlocks.BRIMSTONE);
return state.is(Blocks.WATER) || state.is(Blocks.CAVE_AIR) || state.is(EndBlocks.SULPHURIC_ROCK.stone) || state
.is(EndBlocks.BRIMSTONE);
};
}
}

View file

@ -41,7 +41,10 @@ public class IceStarFeature extends DefaultFeature {
int count = MHelper.randRange(minCount, maxCount, random);
List<Vector3f> points = getFibonacciPoints(count);
SDF sdf = null;
SDF spike = new SDFCappedCone().setRadius1(3 + (size - 5) * 0.2F).setRadius2(0).setHeight(size).setBlock(EndBlocks.DENSE_SNOW);
SDF spike = new SDFCappedCone().setRadius1(3 + (size - 5) * 0.2F)
.setRadius2(0)
.setHeight(size)
.setBlock(EndBlocks.DENSE_SNOW);
spike = new SDFTranslate().setTranslate(0, size - 0.5F, 0).setSource(spike);
for (Vector3f point : points) {
SDF rotated = spike;
@ -77,7 +80,11 @@ public class IceStarFeature extends DefaultFeature {
float px = bpos.getX() - center.getX();
float py = bpos.getY() - center.getY();
float pz = bpos.getZ() - center.getZ();
float distance = MHelper.length(px, py, pz) + sdfCopy.getDistance(px, py, pz) * 0.4F + random.nextFloat() * randScale;
float distance = MHelper.length(px, py, pz) + sdfCopy.getDistance(
px,
py,
pz
) * 0.4F + random.nextFloat() * randScale;
if (distance < ancientRadius) {
return ancient;
}

View file

@ -25,14 +25,20 @@ public class ObsidianBoulderFeature extends DefaultFeature {
final Random random = featureConfig.random();
BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
pos = getPosOnSurface(world, new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16)));
pos = getPosOnSurface(
world,
new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16))
);
if (!world.getBlockState(pos.below()).is(TagAPI.END_GROUND)) {
return false;
}
int count = MHelper.randRange(1, 5, random);
for (int i = 0; i < count; i++) {
BlockPos p = getPosOnSurface(world, new BlockPos(pos.getX() + random.nextInt(16) - 8, pos.getY(), pos.getZ() + random.nextInt(16) - 8));
BlockPos p = getPosOnSurface(
world,
new BlockPos(pos.getX() + random.nextInt(16) - 8, pos.getY(), pos.getZ() + random.nextInt(16) - 8)
);
makeBoulder(world, p, random);
}
@ -62,7 +68,8 @@ public class ObsidianBoulderFeature extends DefaultFeature {
}
return info.getState();
}).setReplaceFunction((state) -> {
return state.getMaterial().isReplaceable() || state.is(TagAPI.GEN_TERRAIN) || state.getMaterial().equals(Material.PLANT);
return state.getMaterial().isReplaceable() || state.is(TagAPI.GEN_TERRAIN) || state.getMaterial()
.equals(Material.PLANT);
}).fillRecursive(world, pos);
}
}

View file

@ -29,14 +29,20 @@ public class ObsidianPillarBasementFeature extends DefaultFeature {
final Random random = featureConfig.random();
BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
pos = getPosOnSurface(world, new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16)));
pos = getPosOnSurface(
world,
new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16))
);
if (!world.getBlockState(pos.below(5)).is(TagAPI.GEN_TERRAIN)) {
return false;
}
float height = MHelper.randRange(10F, 35F, random);
float radius = MHelper.randRange(2F, 5F, random);
SDF pillar = new SDFCappedCone().setRadius1(radius).setRadius2(radius).setHeight(height * 0.5F).setBlock(Blocks.OBSIDIAN);
SDF pillar = new SDFCappedCone().setRadius1(radius)
.setRadius2(radius)
.setHeight(height * 0.5F)
.setBlock(Blocks.OBSIDIAN);
pillar = new SDFTranslate().setTranslate(0, height * 0.5F - 3, 0).setSource(pillar);
SDF cut = new SDFFlatland().setBlock(Blocks.OBSIDIAN);
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
@ -58,7 +64,8 @@ public class ObsidianPillarBasementFeature extends DefaultFeature {
}
return info.getState();
}).setReplaceFunction((state) -> {
return state.getMaterial().isReplaceable() || state.is(TagAPI.GEN_TERRAIN) || state.getMaterial().equals(Material.PLANT);
return state.getMaterial().isReplaceable() || state.is(TagAPI.GEN_TERRAIN) || state.getMaterial()
.equals(Material.PLANT);
}).fillRecursive(world, pos);
return true;

View file

@ -30,8 +30,12 @@ public class SmaragdantCrystalFeature extends DefaultFeature {
BlockState crystal = EndBlocks.SMARAGDANT_CRYSTAL.defaultBlockState();
BlockState shard = EndBlocks.SMARAGDANT_CRYSTAL_SHARD.defaultBlockState();
for (int i = 0; i < count; i++) {
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 2 + 0.5), 5, MHelper.floor(random.nextGaussian() * 2 + 0.5));
int dist = MHelper.floor(1.5F - MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ())) + random.nextInt(3);
mut.set(pos)
.move(MHelper.floor(random.nextGaussian() * 2 + 0.5), 5, MHelper.floor(random.nextGaussian() * 2 + 0.5));
int dist = MHelper.floor(1.5F - MHelper.length(
mut.getX() - pos.getX(),
mut.getZ() - pos.getZ()
)) + random.nextInt(3);
if (dist > 0) {
BlockState state = world.getBlockState(mut);
for (int n = 0; n < 10 && state.isAir(); n++) {
@ -44,7 +48,11 @@ public class SmaragdantCrystalFeature extends DefaultFeature {
mut.setY(mut.getY() + 1);
}
boolean waterlogged = !world.getFluidState(mut).isEmpty();
BlocksHelper.setWithoutUpdate(world, mut, shard.setValue(BlockStateProperties.WATERLOGGED, waterlogged));
BlocksHelper.setWithoutUpdate(
world,
mut,
shard.setValue(BlockStateProperties.WATERLOGGED, waterlogged)
);
}
}
}

View file

@ -38,7 +38,9 @@ public class SpireFeature extends DefaultFeature {
final WorldGenLevel world = featureConfig.level();
final ChunkGenerator chunkGenerator = featureConfig.chunkGenerator();
pos = getPosOnSurfaceWG(world, pos);
if (pos.getY() < 10 || !world.getBlockState(pos.below(3)).is(TagAPI.GEN_TERRAIN) || !world.getBlockState(pos.below(6)).is(TagAPI.GEN_TERRAIN)) {
if (pos.getY() < 10 || !world.getBlockState(pos.below(3))
.is(TagAPI.GEN_TERRAIN) || !world.getBlockState(pos.below(6))
.is(TagAPI.GEN_TERRAIN)) {
return false;
}
@ -50,7 +52,11 @@ public class SpireFeature extends DefaultFeature {
}
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
sdf = new SDFDisplacement().setFunction((vec) -> {
return (float) (Math.abs(noise.eval(vec.x() * 0.1, vec.y() * 0.1, vec.z() * 0.1)) * 3F + Math.abs(noise.eval(vec.x() * 0.3, vec.y() * 0.3 + 100, vec.z() * 0.3)) * 1.3F);
return (float) (Math.abs(noise.eval(
vec.x() * 0.1,
vec.y() * 0.1,
vec.z() * 0.1
)) * 3F + Math.abs(noise.eval(vec.x() * 0.3, vec.y() * 0.3 + 100, vec.z() * 0.3)) * 1.3F);
}).setSource(sdf);
final BlockPos center = pos;
List<BlockPos> support = Lists.newArrayList();
@ -62,14 +68,18 @@ public class SpireFeature extends DefaultFeature {
return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
}
else if (info.getState(Direction.UP, 3).isAir()) {
return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceBuilderConfig().getUnderMaterial();
return world.getBiome(info.getPos())
.getGenerationSettings()
.getSurfaceBuilderConfig()
.getUnderMaterial();
}
return info.getState();
}).fillRecursive(world, center);
support.forEach((bpos) -> {
if (BiomeAPI.getFromBiome(world.getBiome(bpos)) == EndBiomes.BLOSSOMING_SPIRES) {
EndFeatures.TENANEA_BUSH.getFeature().place(new FeaturePlaceContext<>(world, chunkGenerator, random, bpos, null));
EndFeatures.TENANEA_BUSH.getFeature()
.place(new FeaturePlaceContext<>(world, chunkGenerator, random, bpos, null));
}
});
@ -78,7 +88,8 @@ public class SpireFeature extends DefaultFeature {
protected SDF addSegment(SDF sdf, float radius, Random random) {
SDF sphere = new SDFSphere().setRadius(radius).setBlock(Blocks.END_STONE);
SDF offseted = new SDFTranslate().setTranslate(0, radius + random.nextFloat() * 0.25F * radius, 0).setSource(sdf);
SDF offseted = new SDFTranslate().setTranslate(0, radius + random.nextFloat() * 0.25F * radius, 0)
.setSource(sdf);
return new SDFSmoothUnion().setRadius(radius * 0.5F).setSourceA(sphere).setSourceB(offseted);
}

View file

@ -60,8 +60,13 @@ public class StalactiteFeature extends DefaultFeature {
mut.setY(pos.getY() + i * dir);
int size = stalagnate ? Mth.clamp((int) (Mth.abs(i - center) + 1), 1, 7) : height - i - 1;
boolean waterlogged = !world.getFluidState(mut).isEmpty();
BlockState base = block.defaultBlockState().setValue(StalactiteBlock.SIZE, size).setValue(BlockStateProperties.WATERLOGGED, waterlogged);
BlockState state = stalagnate ? base.setValue(StalactiteBlock.IS_FLOOR, dir > 0 ? i < center : i > center) : base.setValue(StalactiteBlock.IS_FLOOR, dir > 0);
BlockState base = block.defaultBlockState()
.setValue(StalactiteBlock.SIZE, size)
.setValue(BlockStateProperties.WATERLOGGED, waterlogged);
BlockState state = stalagnate ? base.setValue(
StalactiteBlock.IS_FLOOR,
dir > 0 ? i < center : i > center
) : base.setValue(StalactiteBlock.IS_FLOOR, dir > 0);
BlocksHelper.setWithoutUpdate(world, mut, state);
}

View file

@ -106,7 +106,11 @@ public class SulphuricCaveFeature extends DefaultFeature {
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;
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());
}
@ -125,22 +129,35 @@ public class SulphuricCaveFeature extends DefaultFeature {
if (random.nextInt(4) == 0) {
int count = MHelper.randRange(5, 20, random);
for (int i = 0; i < count; i++) {
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 2 + 0.5), 0, MHelper.floor(random.nextGaussian() * 2 + 0.5));
int dist = MHelper.floor(3 - MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ())) + random.nextInt(2);
mut.set(pos)
.move(MHelper.floor(random.nextGaussian() * 2 + 0.5),
0,
MHelper.floor(random.nextGaussian() * 2 + 0.5)
);
int dist = MHelper.floor(3 - MHelper.length(
mut.getX() - pos.getX(),
mut.getZ() - pos.getZ()
)) + random.nextInt(2);
if (dist > 0) {
state = world.getBlockState(mut);
while (!state.getFluidState().isEmpty() || state.getMaterial().equals(Material.WATER_PLANT)) {
mut.setY(mut.getY() - 1);
state = world.getBlockState(mut);
}
if (state.is(TagAPI.GEN_TERRAIN) && !world.getBlockState(mut.above()).is(EndBlocks.HYDROTHERMAL_VENT)) {
if (state.is(TagAPI.GEN_TERRAIN) && !world.getBlockState(mut.above())
.is(EndBlocks.HYDROTHERMAL_VENT)) {
for (int j = 0; j <= dist; j++) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.SULPHURIC_ROCK.stone);
MHelper.shuffle(HORIZONTAL, random);
for (Direction dir : HORIZONTAL) {
BlockPos p = mut.relative(dir);
if (random.nextBoolean() && world.getBlockState(p).is(Blocks.WATER)) {
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.TUBE_WORM.defaultBlockState().setValue(HorizontalDirectionalBlock.FACING, dir));
BlocksHelper.setWithoutUpdate(
world,
p,
EndBlocks.TUBE_WORM.defaultBlockState()
.setValue(HorizontalDirectionalBlock.FACING, dir)
);
}
}
mut.setY(mut.getY() + 1);
@ -150,7 +167,8 @@ public class SulphuricCaveFeature extends DefaultFeature {
state = world.getBlockState(mut);
while (state.is(Blocks.WATER)) {
BlocksHelper.setWithoutUpdate(world, mut, EndBlocks.VENT_BUBBLE_COLUMN.defaultBlockState());
world.getBlockTicks().scheduleTick(mut, EndBlocks.VENT_BUBBLE_COLUMN, MHelper.randRange(8, 32, random));
world.getBlockTicks()
.scheduleTick(mut, EndBlocks.VENT_BUBBLE_COLUMN, MHelper.randRange(8, 32, random));
mut.setY(mut.getY() + 1);
state = world.getBlockState(mut);
}
@ -165,7 +183,11 @@ public class SulphuricCaveFeature extends DefaultFeature {
}
private boolean isReplaceable(BlockState state) {
return state.is(TagAPI.GEN_TERRAIN) || state.is(EndBlocks.HYDROTHERMAL_VENT) || state.is(EndBlocks.VENT_BUBBLE_COLUMN) || state.is(EndBlocks.SULPHUR_CRYSTAL) || state.getMaterial().isReplaceable() || state.getMaterial().equals(Material.PLANT) || state.getMaterial().equals(Material.WATER_PLANT) || state.getMaterial().equals(Material.LEAVES);
return state.is(TagAPI.GEN_TERRAIN) || state.is(EndBlocks.HYDROTHERMAL_VENT) || state.is(EndBlocks.VENT_BUBBLE_COLUMN) || state
.is(EndBlocks.SULPHUR_CRYSTAL) || state.getMaterial().isReplaceable() || state.getMaterial()
.equals(Material.PLANT) || state
.getMaterial()
.equals(Material.WATER_PLANT) || state.getMaterial().equals(Material.LEAVES);
}
private void placeBrimstone(WorldGenLevel world, BlockPos pos, Random random) {
@ -189,7 +211,10 @@ public class SulphuricCaveFeature extends DefaultFeature {
for (Direction dir : BlocksHelper.DIRECTIONS) {
BlockPos side;
if (random.nextInt(16) == 0 && world.getBlockState((side = pos.relative(dir))).is(Blocks.WATER)) {
BlockState state = EndBlocks.SULPHUR_CRYSTAL.defaultBlockState().setValue(SulphurCrystalBlock.WATERLOGGED, true).setValue(SulphurCrystalBlock.FACING, dir).setValue(SulphurCrystalBlock.AGE, random.nextInt(3));
BlockState state = EndBlocks.SULPHUR_CRYSTAL.defaultBlockState()
.setValue(SulphurCrystalBlock.WATERLOGGED, true)
.setValue(SulphurCrystalBlock.FACING, dir)
.setValue(SulphurCrystalBlock.AGE, random.nextInt(3));
BlocksHelper.setWithoutUpdate(world, side, state);
}
}

View file

@ -166,7 +166,11 @@ public class SulphuricLakeFeature extends DefaultFeature {
private boolean isDeepWater(WorldGenLevel world, BlockPos pos) {
int y = pos.getY() + 1;
for (Direction dir : BlocksHelper.DIRECTIONS) {
if (getYOnSurface(world, pos.getX() + dir.getStepX(), pos.getZ() + dir.getStepZ()) < y || getYOnSurface(world, pos.getX() + dir.getStepX() * 2, pos.getZ() + dir.getStepZ() * 2) < y || getYOnSurface(world, pos.getX() + dir.getStepX() * 3, pos.getZ() + dir.getStepZ() * 3) < y) {
if (getYOnSurface(world, pos.getX() + dir.getStepX(), pos.getZ() + dir.getStepZ()) < y || getYOnSurface(
world,
pos.getX() + dir.getStepX() * 2,
pos.getZ() + dir.getStepZ() * 2
) < y || getYOnSurface(world, pos.getX() + dir.getStepX() * 3, pos.getZ() + dir.getStepZ() * 3) < y) {
return false;
}
}
@ -194,7 +198,10 @@ public class SulphuricLakeFeature extends DefaultFeature {
for (Direction dir : BlocksHelper.DIRECTIONS) {
BlockPos side;
if (random.nextInt(16) == 0 && world.getBlockState((side = pos.relative(dir))).is(Blocks.WATER)) {
BlockState state = EndBlocks.SULPHUR_CRYSTAL.defaultBlockState().setValue(SulphurCrystalBlock.WATERLOGGED, true).setValue(SulphurCrystalBlock.FACING, dir).setValue(SulphurCrystalBlock.AGE, random.nextInt(3));
BlockState state = EndBlocks.SULPHUR_CRYSTAL.defaultBlockState()
.setValue(SulphurCrystalBlock.WATERLOGGED, true)
.setValue(SulphurCrystalBlock.FACING, dir)
.setValue(SulphurCrystalBlock.AGE, random.nextInt(3));
BlocksHelper.setWithoutUpdate(world, side, state);
}
}

View file

@ -21,17 +21,25 @@ public class SurfaceVentFeature extends DefaultFeature {
final Random random = featureConfig.random();
BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
pos = getPosOnSurface(world, new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16)));
pos = getPosOnSurface(
world,
new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16))
);
if (!world.getBlockState(pos.below(3)).is(TagAPI.GEN_TERRAIN)) {
return false;
}
MutableBlockPos mut = new MutableBlockPos();
int count = MHelper.randRange(15, 30, random);
BlockState vent = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState().setValue(HydrothermalVentBlock.WATERLOGGED, false);
BlockState vent = EndBlocks.HYDROTHERMAL_VENT.defaultBlockState()
.setValue(HydrothermalVentBlock.WATERLOGGED, false);
for (int i = 0; i < count; i++) {
mut.set(pos).move(MHelper.floor(random.nextGaussian() * 2 + 0.5), 5, MHelper.floor(random.nextGaussian() * 2 + 0.5));
int dist = MHelper.floor(2 - MHelper.length(mut.getX() - pos.getX(), mut.getZ() - pos.getZ())) + random.nextInt(2);
mut.set(pos)
.move(MHelper.floor(random.nextGaussian() * 2 + 0.5), 5, MHelper.floor(random.nextGaussian() * 2 + 0.5));
int dist = MHelper.floor(2 - MHelper.length(
mut.getX() - pos.getX(),
mut.getZ() - pos.getZ()
)) + random.nextInt(2);
if (dist > 0) {
BlockState state = world.getBlockState(mut);
for (int n = 0; n < 10 && state.isAir(); n++) {

View file

@ -74,7 +74,10 @@ public abstract class EndCaveFeature extends DefaultFeature {
}
}
});
BlockState surfaceBlock = biome.getBiome().getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
BlockState surfaceBlock = biome.getBiome()
.getGenerationSettings()
.getSurfaceBuilderConfig()
.getTopMaterial();
placeFloor(world, biome, floorPositions, random, surfaceBlock);
placeCeil(world, biome, ceilPositions, random);
placeWalls(world, biome, caveBlocks, random);
@ -126,7 +129,8 @@ public abstract class EndCaveFeature extends DefaultFeature {
if (wallBlock != null) {
for (Vec3i offset : SPHERE) {
BlockPos wallPos = pos.offset(offset);
if (!positions.contains(wallPos) && !placed.contains(wallPos) && world.getBlockState(wallPos).is(TagAPI.GEN_TERRAIN)) {
if (!positions.contains(wallPos) && !placed.contains(wallPos) && world.getBlockState(wallPos)
.is(TagAPI.GEN_TERRAIN)) {
wallBlock = biome.getWall(wallPos);
BlocksHelper.setWithoutUpdate(world, wallPos, wallBlock);
placed.add(wallPos);
@ -256,6 +260,6 @@ public abstract class EndCaveFeature extends DefaultFeature {
}
}
}
SPHERE = prePos.toArray(new Vec3i[]{});
SPHERE = prePos.toArray(new Vec3i[] {});
}
}

View file

@ -74,6 +74,9 @@ public class RoundCaveFeature extends EndCaveFeature {
}
private boolean isReplaceable(BlockState state) {
return state.is(TagAPI.GEN_TERRAIN) || state.getMaterial().isReplaceable() || state.getMaterial().equals(Material.PLANT) || state.getMaterial().equals(Material.LEAVES);
return state.is(TagAPI.GEN_TERRAIN) || state.getMaterial().isReplaceable() || state.getMaterial()
.equals(Material.PLANT) || state
.getMaterial()
.equals(Material.LEAVES);
}
}

View file

@ -74,7 +74,10 @@ public class TunelCaveFeature extends EndCaveFeature {
break;
}
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 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;
if (val < 0.15 && world.getBlockState(pos).is(TagAPI.GEN_TERRAIN) && noWaterNear(world, pos)) {
@ -163,7 +166,10 @@ public class TunelCaveFeature extends EndCaveFeature {
}
floorSets.forEach((biome, floorPositions) -> {
BlockState surfaceBlock = biome.getBiome().getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
BlockState surfaceBlock = biome.getBiome()
.getGenerationSettings()
.getSurfaceBuilderConfig()
.getTopMaterial();
placeFloor(world, biome, floorPositions, random, surfaceBlock);
});
ceilSets.forEach((biome, ceilPositions) -> {
@ -215,7 +221,10 @@ 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));
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) {