Fixes and splines
This commit is contained in:
parent
c638a20ae6
commit
64614bc487
6 changed files with 99 additions and 14 deletions
|
@ -44,6 +44,11 @@ public class EndFeature {
|
|||
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT).decorate(Decorator.CHANCE.configure(new ChanceDecoratorConfig(100)));
|
||||
return new EndFeature(name, feature, GenerationStep.Feature.RAW_GENERATION, configured);
|
||||
}
|
||||
|
||||
public static EndFeature MakeLakeFeature(String name, Feature<DefaultFeatureConfig> feature, int chance) {
|
||||
ConfiguredFeature<?, ?> configured = feature.configure(FeatureConfig.DEFAULT).decorate(Decorator.CHANCE.configure(new ChanceDecoratorConfig(100)));
|
||||
return new EndFeature(name, feature, GenerationStep.Feature.LAKES, configured);
|
||||
}
|
||||
|
||||
public Feature<DefaultFeatureConfig> getFeature() {
|
||||
return feature;
|
||||
|
|
|
@ -11,6 +11,7 @@ import net.minecraft.world.gen.chunk.ChunkGenerator;
|
|||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
import ru.betterend.registry.BlockRegistry;
|
||||
import ru.betterend.registry.BlockTagRegistry;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
import ru.betterend.util.MHelper;
|
||||
|
||||
|
@ -61,22 +62,23 @@ public class EndLakeFeature extends DefaultFeature {
|
|||
double r = add * 1.8 + radius * (NOISE.eval(x * 0.2, y * 0.2, z * 0.2) * 0.25 + 0.75);
|
||||
r *= r;
|
||||
if (x2 + z2 <= r) {
|
||||
if (world.getBlockState(POS).getBlock() == Blocks.END_STONE)
|
||||
if (world.getBlockState(POS).isIn(BlockTagRegistry.END_GROUND)) {
|
||||
BlocksHelper.setWithoutUpdate(world, POS, AIR);
|
||||
}
|
||||
pos = POS.down();
|
||||
if (world.getBlockState(pos).getBlock() == Blocks.END_STONE)
|
||||
if (world.getBlockState(pos).isIn(BlockTagRegistry.END_GROUND))
|
||||
{
|
||||
BlockState state = world.getBiome(POS).getGenerationSettings().getSurfaceConfig().getTopMaterial();
|
||||
BlockState state = world.getBiome(pos).getGenerationSettings().getSurfaceConfig().getTopMaterial();
|
||||
if (y > waterLevel + 1)
|
||||
BlocksHelper.setWithoutUpdate(world, POS.down(), state);
|
||||
BlocksHelper.setWithoutUpdate(world, pos, state);
|
||||
else if (y > waterLevel)
|
||||
BlocksHelper.setWithoutUpdate(world, POS.down(), random.nextBoolean() ? state : BlockRegistry.ENDSTONE_DUST.getDefaultState());
|
||||
BlocksHelper.setWithoutUpdate(world, pos, random.nextBoolean() ? state : BlockRegistry.ENDSTONE_DUST.getDefaultState());
|
||||
else
|
||||
BlocksHelper.setWithoutUpdate(world, POS.down(), BlockRegistry.ENDSTONE_DUST.getDefaultState());
|
||||
BlocksHelper.setWithoutUpdate(world, pos, BlockRegistry.ENDSTONE_DUST.getDefaultState());
|
||||
}
|
||||
pos = POS.up();
|
||||
if (!world.getBlockState(pos).isAir()) {
|
||||
while (!world.getBlockState(pos).isAir()) {
|
||||
if (world.getBlockState(pos).isIn(BlockTagRegistry.END_GROUND)) {
|
||||
while (world.getBlockState(pos).isIn(BlockTagRegistry.END_GROUND)) {
|
||||
BlocksHelper.setWithoutUpdate(world, pos, AIR);
|
||||
pos = pos.up();
|
||||
}
|
||||
|
@ -106,7 +108,7 @@ public class EndLakeFeature extends DefaultFeature {
|
|||
if (y2 + x2 + z2 <= r) {
|
||||
BlocksHelper.setWithoutUpdate(world, POS, y < waterLevel ? WATER : AIR);
|
||||
pos = POS.down();
|
||||
if (world.getBlockState(pos).getBlock() == Blocks.END_STONE)
|
||||
if (world.getBlockState(pos).getBlock().isIn(BlockTagRegistry.END_GROUND))
|
||||
BlocksHelper.setWithoutUpdate(world, POS.down(), BlockRegistry.ENDSTONE_DUST.getDefaultState());
|
||||
pos = POS.up();
|
||||
if (!world.getBlockState(pos).isAir()) {
|
||||
|
|
|
@ -1,21 +1,26 @@
|
|||
package ru.betterend.world.features;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import ru.betterend.registry.BlockTagRegistry;
|
||||
import ru.betterend.util.MHelper;
|
||||
import ru.betterend.util.SplineHelper;
|
||||
import ru.betterend.util.sdf.ISDF;
|
||||
import ru.betterend.util.sdf.operator.SDFFlatWave;
|
||||
import ru.betterend.util.sdf.operator.SDFScale3D;
|
||||
import ru.betterend.util.sdf.operator.SDFSmoothUnion;
|
||||
import ru.betterend.util.sdf.operator.SDFSubtraction;
|
||||
import ru.betterend.util.sdf.operator.SDFTranslate;
|
||||
import ru.betterend.util.sdf.primitive.SDFCapedCone;
|
||||
import ru.betterend.util.sdf.primitive.SDFLine;
|
||||
import ru.betterend.util.sdf.primitive.SDFSphere;
|
||||
|
||||
|
@ -32,12 +37,22 @@ public class MossyGlowshroomFeature extends DefaultFeature {
|
|||
if (!world.getBlockState(blockPos.down()).isIn(BlockTagRegistry.END_GROUND)) {
|
||||
return false;
|
||||
}
|
||||
FUNCTION.fillRecursive(world, getTopPos(world, blockPos), REPLACE, 20, 50, 20);
|
||||
//FUNCTION.fillRecursive(world, getTopPos(world, blockPos), REPLACE, 20, 50, 20);
|
||||
|
||||
float height = MHelper.randRange(10F, 25F, random);
|
||||
int count = MHelper.floor(height / 4);
|
||||
List<Vector3f> spline = SplineHelper.makeSpline(0, 0, 0, 0, height, 0, count);
|
||||
SplineHelper.offsetParts(spline, random, 1F, 0, 1F);
|
||||
ISDF sdf = SplineHelper.buildSDF(spline, 2.1F, 1.5F, (pos) -> {
|
||||
return Blocks.DIAMOND_BLOCK.getDefaultState();
|
||||
});
|
||||
sdf.fillRecursive(world, blockPos, REPLACE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static {
|
||||
SDFLine stem = new SDFLine(Blocks.GOLD_BLOCK.getDefaultState()).setRadius(2F).setEnd(0, 15, 0);
|
||||
/*SDFLine stem = new SDFLine(Blocks.GOLD_BLOCK.getDefaultState()).setRadius(2F).setEnd(0, 15, 0);
|
||||
|
||||
SDFSphere outerSphere = new SDFSphere(Blocks.REDSTONE_BLOCK.getDefaultState()).setRadius(10);
|
||||
SDFSphere innerSphere = new SDFSphere(Blocks.DIAMOND_BLOCK.getDefaultState()).setRadius(10);
|
||||
|
@ -51,7 +66,9 @@ public class MossyGlowshroomFeature extends DefaultFeature {
|
|||
|
||||
SDFTranslate headOffset = new SDFTranslate().setTranslate(0, 15, 0);
|
||||
|
||||
FUNCTION = new SDFSmoothUnion().setRadius(5).setSourceA(stem).setSourceB(headOffset.setSource(head));
|
||||
FUNCTION = new SDFSmoothUnion().setRadius(5).setSourceA(stem).setSourceB(headOffset.setSource(head));*/
|
||||
|
||||
FUNCTION = new SDFCapedCone(Blocks.GOLD_BLOCK.getDefaultState()).setHeight(10).setRadius1(0).setRadius2(10);
|
||||
|
||||
REPLACE = (state) -> {
|
||||
return state.getMaterial().isReplaceable();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue