Inflexia (WIP)
This commit is contained in:
parent
e32c6c76cb
commit
6c24a2022b
7 changed files with 121 additions and 69 deletions
|
@ -8,14 +8,14 @@ import ru.betterend.world.surface.SurfaceBuilders;
|
|||
|
||||
public class UmbraValleyBiome extends EndBiome {
|
||||
public UmbraValleyBiome() {
|
||||
super(
|
||||
new BCLBiomeDef(BetterEnd.makeID("umbra_valley"))
|
||||
.setFogColor(100, 100, 100)
|
||||
.setPlantsColor(200, 200, 200)
|
||||
.setWaterAndFogColor(69, 104, 134)
|
||||
.setSurface(SurfaceBuilders.UMBRA_SURFACE.configured(SurfaceBuilders.DEFAULT_END_CONFIG))
|
||||
.addFeature(EndFeatures.UMBRALITH_ARCH)
|
||||
.addFeature(EndFeatures.THIN_UMBRALITH_ARCH)
|
||||
super(new BCLBiomeDef(BetterEnd.makeID("umbra_valley"))
|
||||
.setFogColor(100, 100, 100)
|
||||
.setPlantsColor(200, 200, 200)
|
||||
.setWaterAndFogColor(69, 104, 134)
|
||||
.setSurface(SurfaceBuilders.UMBRA_SURFACE.configured(SurfaceBuilders.DEFAULT_END_CONFIG))
|
||||
.addFeature(EndFeatures.UMBRALITH_ARCH)
|
||||
.addFeature(EndFeatures.THIN_UMBRALITH_ARCH)
|
||||
.addFeature(EndFeatures.INFLEXIA)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
package ru.betterend.world.features.terrain;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
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.levelgen.feature.FeaturePlaceContext;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
|
||||
import net.minecraft.world.level.levelgen.surfacebuilders.ConfiguredSurfaceBuilder;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import ru.bclib.api.TagAPI;
|
||||
|
@ -17,49 +21,69 @@ import ru.bclib.util.MHelper;
|
|||
import ru.bclib.world.features.DefaultFeature;
|
||||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ArchFeature extends DefaultFeature {
|
||||
private Block block;
|
||||
|
||||
public ArchFeature(Block block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featurePlaceContext) {
|
||||
final WorldGenLevel world = featurePlaceContext.level();
|
||||
BlockPos origin = featurePlaceContext.origin();
|
||||
Random random = featurePlaceContext.random();
|
||||
|
||||
BlockPos pos = getPosOnSurfaceWG(world, new BlockPos((origin.getX() & 0xFFFFFFF0) | 7, 0, (origin.getZ() & 0xFFFFFFF0) | 7));
|
||||
if (!world.getBlockState(pos.below(5)).is(TagAPI.BLOCK_GEN_TERRAIN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
float bigRadius = MHelper.randRange(10F, 20F, random);
|
||||
float smallRadius = MHelper.randRange(3F, 7F, random);
|
||||
if (smallRadius + bigRadius > 23) {
|
||||
smallRadius = 23 - bigRadius;
|
||||
}
|
||||
SDF arch = new SDFTorus().setBigRadius(bigRadius).setSmallRadius(smallRadius).setBlock(block);
|
||||
arch = new SDFRotation().setRotation(MHelper.randomHorizontal(random), (float) Math.PI * 0.5F).setSource(arch);
|
||||
|
||||
final float smallRadiusF = smallRadius;
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
|
||||
arch = 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) - smallRadiusF * Math.abs(1 - vec.y() / bigRadius);
|
||||
}).setSource(arch);
|
||||
|
||||
float side = (bigRadius + smallRadius + 3F) * 2;
|
||||
if (side > 47) {
|
||||
side = 47;
|
||||
}
|
||||
arch.fillArea(world, pos, AABB.ofSize(Vec3.atCenterOf(pos), side, side, side));
|
||||
return true;
|
||||
}
|
||||
private Function<BlockPos, BlockState> surfaceFunction;
|
||||
private Block block;
|
||||
|
||||
public ArchFeature(Block block, Function<BlockPos, BlockState> surfaceFunction) {
|
||||
this.surfaceFunction = surfaceFunction;
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featurePlaceContext) {
|
||||
final WorldGenLevel world = featurePlaceContext.level();
|
||||
BlockPos origin = featurePlaceContext.origin();
|
||||
Random random = featurePlaceContext.random();
|
||||
|
||||
BlockPos pos = getPosOnSurfaceWG(
|
||||
world,
|
||||
new BlockPos((origin.getX() & 0xFFFFFFF0) | 7, 0, (origin.getZ() & 0xFFFFFFF0) | 7)
|
||||
);
|
||||
if (!world.getBlockState(pos.below(5)).is(TagAPI.BLOCK_GEN_TERRAIN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
float bigRadius = MHelper.randRange(10F, 20F, random);
|
||||
float smallRadius = MHelper.randRange(3F, 7F, random);
|
||||
if (smallRadius + bigRadius > 23) {
|
||||
smallRadius = 23 - bigRadius;
|
||||
}
|
||||
SDF arch = new SDFTorus().setBigRadius(bigRadius).setSmallRadius(smallRadius).setBlock(block);
|
||||
arch = new SDFRotation().setRotation(MHelper.randomHorizontal(random), (float) Math.PI * 0.5F).setSource(arch);
|
||||
|
||||
final float smallRadiusF = smallRadius;
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong());
|
||||
arch = 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) - smallRadiusF * Math.abs(1 - vec.y() / bigRadius);
|
||||
}).setSource(arch);
|
||||
|
||||
List<BlockPos> surface = Lists.newArrayList();
|
||||
arch.addPostProcess((info) -> {
|
||||
if (info.getStateUp().isAir()) {
|
||||
return surfaceFunction.apply(info.getPos());
|
||||
}
|
||||
return info.getState();
|
||||
});
|
||||
|
||||
float side = (bigRadius + smallRadius + 3F) * 2;
|
||||
if (side > 47) {
|
||||
side = 47;
|
||||
}
|
||||
arch.fillArea(world, pos, AABB.ofSize(Vec3.atCenterOf(pos), side, side, side));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package ru.betterend.world.surface;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilder;
|
||||
import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilderBaseConfiguration;
|
||||
import ru.bclib.util.MHelper;
|
||||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
|
||||
import java.util.Random;
|
||||
|
@ -19,23 +21,30 @@ public class UmbraSurfaceBuilder extends SurfaceBuilder<SurfaceBuilderBaseConfig
|
|||
@Override
|
||||
public void apply(Random random, ChunkAccess chunk, Biome biome, int x, int z, int height, double noise, BlockState defaultBlock, BlockState defaultFluid, int seaLevel, int seed, long n, SurfaceBuilderBaseConfiguration surfaceBlocks) {
|
||||
int depth = (int) (NOISE.eval(x * 0.1, z * 0.1) * 20 + NOISE.eval(x * 0.5, z * 0.5) * 10 + 60);
|
||||
float grass = ((float) NOISE.eval(x * 0.03, z * 0.03) + (float) NOISE.eval(x * 0.1, z * 0.1) * 0.6F + random.nextFloat() * 0.2F) - 0.05F;
|
||||
SurfaceBuilderBaseConfiguration config = null;
|
||||
if (grass > 0.3F) {
|
||||
config = SurfaceBuilders.PALLIDIUM_SURFACE_CONFIG;
|
||||
}
|
||||
else if (grass > 0.1F) {
|
||||
config = SurfaceBuilders.PALLIDIUM_T1_SURFACE_CONFIG;
|
||||
}
|
||||
else if (grass > -0.1) {
|
||||
config = SurfaceBuilders.PALLIDIUM_T2_SURFACE_CONFIG;
|
||||
}
|
||||
else if (grass > -0.3F) {
|
||||
config = SurfaceBuilders.PALLIDIUM_T3_SURFACE_CONFIG;
|
||||
}
|
||||
else {
|
||||
config = SurfaceBuilders.UMBRA_SURFACE_CONFIG;
|
||||
}
|
||||
SurfaceBuilderBaseConfiguration config = getConfig(x, z, random);
|
||||
SurfaceBuilder.DEFAULT.apply(random, chunk, biome, x, z, height, noise + depth, defaultBlock, defaultFluid, seaLevel, seed, n, config);
|
||||
}
|
||||
|
||||
public static BlockState getSurfaceState(BlockPos pos) {
|
||||
return getConfig(pos.getX(), pos.getZ(), MHelper.RANDOM).getTopMaterial();
|
||||
}
|
||||
|
||||
private static SurfaceBuilderBaseConfiguration getConfig(int x, int z, Random random) {
|
||||
float grass = ((float) NOISE.eval(x * 0.03, z * 0.03) + (float) NOISE.eval(x * 0.1, z * 0.1) * 0.6F + random.nextFloat() * 0.2F) - 0.05F;
|
||||
if (grass > 0.3F) {
|
||||
return SurfaceBuilders.PALLIDIUM_SURFACE_CONFIG;
|
||||
}
|
||||
else if (grass > 0.1F) {
|
||||
return SurfaceBuilders.PALLIDIUM_T1_SURFACE_CONFIG;
|
||||
}
|
||||
else if (grass > -0.1) {
|
||||
return SurfaceBuilders.PALLIDIUM_T2_SURFACE_CONFIG;
|
||||
}
|
||||
else if (grass > -0.3F) {
|
||||
return SurfaceBuilders.PALLIDIUM_T3_SURFACE_CONFIG;
|
||||
}
|
||||
else {
|
||||
return SurfaceBuilders.UMBRA_SURFACE_CONFIG;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue