Spires enhancements, pink moss
This commit is contained in:
parent
e08d33e577
commit
1f697db60b
18 changed files with 220 additions and 13 deletions
|
@ -23,9 +23,9 @@ import ru.betterend.blocks.complex.StoneMaterial;
|
|||
import ru.betterend.world.features.terrain.OreLayerFeature;
|
||||
|
||||
public class EndFeature {
|
||||
protected Feature<?> feature;
|
||||
protected ConfiguredFeature<?, ?> featureConfigured;
|
||||
protected GenerationStep.Feature featureStep;
|
||||
private Feature<?> feature;
|
||||
private ConfiguredFeature<?, ?> featureConfigured;
|
||||
private GenerationStep.Feature featureStep;
|
||||
|
||||
protected EndFeature() {}
|
||||
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
package ru.betterend.world.features.bushes;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.LeavesBlock;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos.Mutable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.StructureWorldAccess;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import ru.betterend.blocks.BlockProperties;
|
||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndTags;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
import ru.betterend.util.MHelper;
|
||||
import ru.betterend.util.sdf.SDF;
|
||||
import ru.betterend.util.sdf.operator.SDFDisplacement;
|
||||
import ru.betterend.util.sdf.operator.SDFScale3D;
|
||||
import ru.betterend.util.sdf.operator.SDFSubtraction;
|
||||
import ru.betterend.util.sdf.operator.SDFTranslate;
|
||||
import ru.betterend.util.sdf.primitive.SDFSphere;
|
||||
import ru.betterend.world.features.DefaultFeature;
|
||||
|
||||
public class TenaneaBushFeature extends DefaultFeature {
|
||||
private static final Function<BlockState, Boolean> REPLACE;
|
||||
|
||||
public TenaneaBushFeature() {}
|
||||
|
||||
@Override
|
||||
public boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, DefaultFeatureConfig config) {
|
||||
if (!world.getBlockState(pos.down()).getBlock().isIn(EndTags.END_GROUND)) return false;
|
||||
|
||||
float radius = MHelper.randRange(1.8F, 3.5F, random);
|
||||
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt());
|
||||
BlockState leaves = EndBlocks.TENANEA_LEAVES.getDefaultState();
|
||||
SDF sphere = new SDFSphere().setRadius(radius).setBlock(leaves);
|
||||
sphere = new SDFScale3D().setScale(1, 0.75F, 1).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> { return (float) noise.eval(vec.getX() * 0.2, vec.getY() * 0.2, vec.getZ() * 0.2) * 3; }).setSource(sphere);
|
||||
sphere = new SDFDisplacement().setFunction((vec) -> { return MHelper.randRange(-2F, 2F, random); }).setSource(sphere);
|
||||
sphere = new SDFSubtraction().setSourceA(sphere).setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere));
|
||||
sphere.setReplaceFunction(REPLACE);
|
||||
List<BlockPos> support = Lists.newArrayList();
|
||||
sphere.setPostProcess((info) -> {
|
||||
if (info.getState().getBlock() instanceof LeavesBlock) {
|
||||
int distance = info.getPos().getManhattanDistance(pos);
|
||||
if (distance < 7) {
|
||||
if (random.nextBoolean() && info.getStateDown().isAir()) {
|
||||
BlockPos d = info.getPos().down();
|
||||
support.add(d);
|
||||
}
|
||||
return info.getState().with(LeavesBlock.DISTANCE, distance);
|
||||
}
|
||||
else {
|
||||
return AIR;
|
||||
}
|
||||
}
|
||||
return info.getState();
|
||||
});
|
||||
sphere.fillRecursive(world, pos);
|
||||
BlockState stem = EndBlocks.TENANEA.bark.getDefaultState();
|
||||
BlocksHelper.setWithoutUpdate(world, pos, stem);
|
||||
for (Direction d: Direction.values()) {
|
||||
BlockPos p = pos.offset(d);
|
||||
if (world.isAir(p)) {
|
||||
BlocksHelper.setWithoutUpdate(world, p, leaves.with(LeavesBlock.DISTANCE, 1));
|
||||
}
|
||||
}
|
||||
|
||||
Mutable mut = new Mutable();
|
||||
BlockState top = EndBlocks.TENANEA_FLOWERS.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP);
|
||||
BlockState middle = EndBlocks.TENANEA_FLOWERS.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE);
|
||||
BlockState bottom = EndBlocks.TENANEA_FLOWERS.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM);
|
||||
support.forEach((bpos) -> {
|
||||
int count = MHelper.randRange(3, 8, random);
|
||||
mut.set(bpos);
|
||||
if (world.getBlockState(mut.up()).isOf(EndBlocks.TENANEA_LEAVES)) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, top);
|
||||
for (int i = 1; i < count; i++) {
|
||||
mut.setY(mut.getY() - 1);
|
||||
if (world.isAir(mut.down())) {
|
||||
BlocksHelper.setWithoutUpdate(world, mut, middle);
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
BlocksHelper.setWithoutUpdate(world, mut, bottom);
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static {
|
||||
REPLACE = (state) -> {
|
||||
if (state.getMaterial().equals(Material.PLANT)) {
|
||||
return true;
|
||||
}
|
||||
return state.getMaterial().isReplaceable();
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,19 +1,21 @@
|
|||
package ru.betterend.world.features;
|
||||
package ru.betterend.world.features.terrain;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.Blocks;
|
||||
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.noise.OpenSimplexNoise;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndFeatures;
|
||||
import ru.betterend.util.MHelper;
|
||||
import ru.betterend.util.sdf.SDF;
|
||||
import ru.betterend.util.sdf.operator.SDFDisplacement;
|
||||
import ru.betterend.util.sdf.primitive.SDFSphere;
|
||||
import ru.betterend.world.features.terrain.SpireFeature;
|
||||
|
||||
public class FloatingSpireFeature extends SpireFeature {
|
||||
@Override
|
||||
|
@ -39,10 +41,22 @@ public class FloatingSpireFeature extends SpireFeature {
|
|||
return (float) (Math.abs(noise.eval(vec.getX() * 0.1, vec.getY() * 0.1, vec.getZ() * 0.1)) * 3F + Math.abs(noise.eval(vec.getX() * 0.3, vec.getY() * 0.3 + 100, vec.getZ() * 0.3)) * 1.3F);
|
||||
}).setSource(sdf);
|
||||
final BlockPos center = pos;
|
||||
List<BlockPos> support = Lists.newArrayList();
|
||||
sdf.setReplaceFunction(REPLACE).setPostProcess((info) -> {
|
||||
return info.getStateUp().isAir() ? EndBlocks.END_MOSS.getDefaultState() : info.getState();
|
||||
if (info.getStateUp().isAir()) {
|
||||
if (random.nextInt(16) == 0) {
|
||||
support.add(info.getPos().up());
|
||||
}
|
||||
return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceConfig().getTopMaterial();
|
||||
}
|
||||
return info.getState();
|
||||
});
|
||||
sdf.fillRecursive(world, center);
|
||||
|
||||
support.forEach((bpos) -> {
|
||||
EndFeatures.TENANEA_BUSH.getFeature().generate(world, chunkGenerator, random, bpos, null);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,8 +1,11 @@
|
|||
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.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.LeavesBlock;
|
||||
|
@ -12,7 +15,7 @@ import net.minecraft.world.StructureWorldAccess;
|
|||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import ru.betterend.noise.OpenSimplexNoise;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.registry.EndFeatures;
|
||||
import ru.betterend.registry.EndTags;
|
||||
import ru.betterend.util.MHelper;
|
||||
import ru.betterend.util.sdf.SDF;
|
||||
|
@ -40,10 +43,22 @@ public class SpireFeature extends DefaultFeature {
|
|||
return (float) (Math.abs(noise.eval(vec.getX() * 0.1, vec.getY() * 0.1, vec.getZ() * 0.1)) * 3F + Math.abs(noise.eval(vec.getX() * 0.3, vec.getY() * 0.3 + 100, vec.getZ() * 0.3)) * 1.3F);
|
||||
}).setSource(sdf);
|
||||
final BlockPos center = pos;
|
||||
List<BlockPos> support = Lists.newArrayList();
|
||||
sdf.setReplaceFunction(REPLACE).setPostProcess((info) -> {
|
||||
return info.getStateUp().isAir() ? EndBlocks.END_MOSS.getDefaultState() : info.getState();
|
||||
if (info.getStateUp().isAir()) {
|
||||
if (random.nextInt(16) == 0) {
|
||||
support.add(info.getPos().up());
|
||||
}
|
||||
return world.getBiome(info.getPos()).getGenerationSettings().getSurfaceConfig().getTopMaterial();
|
||||
}
|
||||
return info.getState();
|
||||
});
|
||||
sdf.fillRecursive(world, center);
|
||||
|
||||
support.forEach((bpos) -> {
|
||||
EndFeatures.TENANEA_BUSH.getFeature().generate(world, chunkGenerator, random, bpos, null);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue