More Feature Changes

This commit is contained in:
Frank 2022-07-01 18:23:04 +02:00
parent 5c3a9986bc
commit 6dd711930e
19 changed files with 417 additions and 213 deletions

View file

@ -14,9 +14,9 @@ public class EmptyAuroraCaveBiome extends EndCaveBiome.Config {
public Biome(ResourceLocation biomeID, net.minecraft.world.level.biome.Biome biome, BCLBiomeSettings settings) {
super(biomeID, biome, settings);
this.addFloorFeature(EndFeatures.BIG_AURORA_CRYSTAL, 1);
this.addFloorFeature(EndFeatures.BIG_AURORA_CRYSTAL.configuredFeature, 1);
this.addCeilFeature(EndFeatures.END_STONE_STALACTITE, 1);
this.addCeilFeature(EndFeatures.END_STONE_STALACTITE.configuredFeature, 1);
}
@Override

View file

@ -13,8 +13,8 @@ public class EmptyEndCaveBiome extends EndCaveBiome.Config {
public Biome(ResourceLocation biomeID, net.minecraft.world.level.biome.Biome biome, BCLBiomeSettings settings) {
super(biomeID, biome, settings);
this.addFloorFeature(EndFeatures.END_STONE_STALAGMITE, 1);
this.addCeilFeature(EndFeatures.END_STONE_STALACTITE, 1);
this.addFloorFeature(EndFeatures.END_STONE_STALAGMITE.configuredFeature, 1);
this.addCeilFeature(EndFeatures.END_STONE_STALACTITE.configuredFeature, 1);
}
@Override

View file

@ -14,10 +14,10 @@ public class EmptySmaragdantCaveBiome extends EndCaveBiome.Config {
public Biome(ResourceLocation biomeID, net.minecraft.world.level.biome.Biome biome, BCLBiomeSettings settings) {
super(biomeID, biome, settings);
this.addFloorFeature(EndFeatures.SMARAGDANT_CRYSTAL, 1);
this.addFloorFeature(EndFeatures.SMARAGDANT_CRYSTAL_SHARD, 20);
this.addFloorFeature(EndFeatures.SMARAGDANT_CRYSTAL.configuredFeature, 1);
this.addFloorFeature(EndFeatures.SMARAGDANT_CRYSTAL_SHARD.configuredFeature, 20);
this.addCeilFeature(EndFeatures.END_STONE_STALACTITE, 1);
this.addCeilFeature(EndFeatures.END_STONE_STALACTITE.configuredFeature, 1);
}
@Override

View file

@ -14,12 +14,13 @@ import org.betterx.betterend.world.features.terrain.caves.CaveChunkPopulatorFeat
import org.betterx.betterend.world.features.terrain.caves.CaveChunkPopulatorFeatureConfig;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.GenerationStep;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
public class EndCaveBiome extends EndBiome {
public static abstract class Config extends EndBiome.Config {
@ -59,26 +60,26 @@ public class EndCaveBiome extends EndBiome {
}
}
private final WeightedList<Feature<?>> floorFeatures = new WeightedList<Feature<?>>();
private final WeightedList<Feature<?>> ceilFeatures = new WeightedList<Feature<?>>();
private final WeightedList<Holder<? extends ConfiguredFeature<?, ?>>> floorFeatures = new WeightedList<>();
private final WeightedList<Holder<? extends ConfiguredFeature<?, ?>>> ceilFeatures = new WeightedList<>();
public EndCaveBiome(ResourceLocation biomeID, Biome biome, BCLBiomeSettings settings) {
super(biomeID, biome, settings);
}
public void addFloorFeature(Feature<?> feature, float weight) {
public void addFloorFeature(Holder<? extends ConfiguredFeature<?, ?>> feature, float weight) {
floorFeatures.add(feature, weight);
}
public void addCeilFeature(Feature<?> feature, float weight) {
public void addCeilFeature(Holder<? extends ConfiguredFeature<?, ?>> feature, float weight) {
ceilFeatures.add(feature, weight);
}
public Feature<?> getFloorFeature(RandomSource random) {
public Holder<? extends ConfiguredFeature<?, ?>> getFloorFeature(RandomSource random) {
return floorFeatures.isEmpty() ? null : floorFeatures.get(random);
}
public Feature<?> getCeilFeature(RandomSource random) {
public Holder<? extends ConfiguredFeature<?, ?>> getCeilFeature(RandomSource random) {
return ceilFeatures.isEmpty() ? null : ceilFeatures.get(random);
}

View file

@ -19,16 +19,16 @@ public class LushAuroraCaveBiome extends EndCaveBiome.Config {
public Biome(ResourceLocation biomeID, net.minecraft.world.level.biome.Biome biome, BCLBiomeSettings settings) {
super(biomeID, biome, settings);
this.addFloorFeature(EndFeatures.BIG_AURORA_CRYSTAL, 1);
this.addFloorFeature(EndFeatures.CAVE_BUSH, 5);
this.addFloorFeature(EndFeatures.CAVE_GRASS, 40);
this.addFloorFeature(EndFeatures.END_STONE_STALAGMITE_CAVEMOSS, 5);
this.addFloorFeature(EndFeatures.BIG_AURORA_CRYSTAL.configuredFeature, 1);
this.addFloorFeature(EndFeatures.CAVE_BUSH.configuredFeature, 5);
this.addFloorFeature(EndFeatures.CAVE_GRASS.configuredFeature, 40);
this.addFloorFeature(EndFeatures.END_STONE_STALAGMITE_CAVEMOSS.configuredFeature, 5);
this.addCeilFeature(EndFeatures.CAVE_BUSH, 1);
this.addCeilFeature(EndFeatures.CAVE_PUMPKIN, 1);
this.addCeilFeature(EndFeatures.RUBINEA.getFeature(), 3);
this.addCeilFeature(EndFeatures.MAGNULA.getFeature(), 1);
this.addCeilFeature(EndFeatures.END_STONE_STALACTITE_CAVEMOSS, 10);
this.addCeilFeature(EndFeatures.CAVE_BUSH.configuredFeature, 1);
this.addCeilFeature(EndFeatures.CAVE_PUMPKIN.configuredFeature, 1);
this.addCeilFeature(EndFeatures.RUBINEA.configuredFeature, 3);
this.addCeilFeature(EndFeatures.MAGNULA.configuredFeature, 1);
this.addCeilFeature(EndFeatures.END_STONE_STALACTITE_CAVEMOSS.configuredFeature, 10);
}
@Override

View file

@ -17,10 +17,10 @@ public class LushSmaragdantCaveBiome extends EndCaveBiome.Config {
public Biome(ResourceLocation biomeID, net.minecraft.world.level.biome.Biome biome, BCLBiomeSettings settings) {
super(biomeID, biome, settings);
this.addFloorFeature(EndFeatures.SMARAGDANT_CRYSTAL, 1);
this.addFloorFeature(EndFeatures.SMARAGDANT_CRYSTAL_SHARD, 20);
this.addFloorFeature(EndFeatures.SMARAGDANT_CRYSTAL.configuredFeature, 1);
this.addFloorFeature(EndFeatures.SMARAGDANT_CRYSTAL_SHARD.configuredFeature, 20);
this.addCeilFeature(EndFeatures.END_STONE_STALACTITE, 1);
this.addCeilFeature(EndFeatures.END_STONE_STALACTITE.configuredFeature, 1);
}
@Override

View file

@ -19,24 +19,21 @@ import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
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;
import net.minecraft.world.level.material.Material;
import java.util.function.Function;
public class BushFeature extends DefaultFeature {
public class BushFeature extends Feature<BushFeatureConfig> {
private static final Function<BlockState, Boolean> REPLACE;
private final Block leaves;
private final Block stem;
public BushFeature(Block leaves, Block stem) {
this.leaves = leaves;
this.stem = stem;
public BushFeature() {
super(BushFeatureConfig.CODEC);
}
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
public boolean place(FeaturePlaceContext<BushFeatureConfig> featureConfig) {
final RandomSource random = featureConfig.random();
final BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
@ -44,16 +41,19 @@ public class BushFeature extends DefaultFeature {
.is(CommonBlockTags.END_STONES))
return false;
BushFeatureConfig cfg = featureConfig.config();
Block leaves = cfg.leaves.getState(random, pos).getBlock();
BlockState stem = cfg.stem.getState(random, pos);
float radius = MHelper.randRange(1.8F, 3.5F, random);
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt());
SDF sphere = new SDFSphere().setRadius(radius).setBlock(this.leaves);
SDF sphere = new SDFSphere().setRadius(radius).setBlock(leaves);
sphere = new SDFScale3D().setScale(1, 0.5F, 1).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> {
return (float) noise.eval(vec.x() * 0.2, vec.y() * 0.2, vec.z() * 0.2) * 3;
}).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> {
return MHelper.randRange(-2F, 2F, random);
}).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> (float) noise.eval(
vec.x() * 0.2,
vec.y() * 0.2,
vec.z() * 0.2
) * 3).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> MHelper.randRange(-2F, 2F, random)).setSource(sphere);
sphere = new SDFSubtraction().setSourceA(sphere)
.setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere));
sphere.setReplaceFunction(REPLACE);
@ -63,7 +63,7 @@ public class BushFeature extends DefaultFeature {
if (distance < 7) {
return info.getState().setValue(LeavesBlock.DISTANCE, distance);
} else {
return AIR;
return DefaultFeature.AIR;
}
}
return info.getState();

View file

@ -0,0 +1,36 @@
package org.betterx.betterend.world.features.bushes;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider;
import net.minecraft.world.level.levelgen.feature.stateproviders.SimpleStateProvider;
public class BushFeatureConfig implements FeatureConfiguration {
public static final Codec<BushFeatureConfig> CODEC = RecordCodecBuilder.create(instance -> instance
.group(
BlockStateProvider.CODEC.fieldOf("leaves").forGetter(o -> o.leaves),
BlockStateProvider.CODEC.fieldOf("stem").forGetter(o -> o.stem)
)
.apply(instance, BushFeatureConfig::new));
public final BlockStateProvider leaves;
public final BlockStateProvider stem;
public BushFeatureConfig(Block leaves, Block stem) {
this(
SimpleStateProvider.simple(leaves),
SimpleStateProvider.simple(stem)
);
}
public BushFeatureConfig(
BlockStateProvider leaves,
BlockStateProvider stem
) {
this.leaves = leaves;
this.stem = stem;
}
}

View file

@ -20,29 +20,30 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.LeavesBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
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;
import net.minecraft.world.level.material.Material;
import java.util.function.Function;
public class BushWithOuterFeature extends DefaultFeature {
public class BushWithOuterFeature extends Feature<BushWithOuterFeatureConfig> {
private static final Direction[] DIRECTIONS = Direction.values();
private static final Function<BlockState, Boolean> REPLACE;
private final Block outer_leaves;
private final Block leaves;
private final Block stem;
public BushWithOuterFeature(Block leaves, Block outer_leaves, Block stem) {
this.outer_leaves = outer_leaves;
this.leaves = leaves;
this.stem = stem;
public BushWithOuterFeature() {
super(BushWithOuterFeatureConfig.CODEC);
}
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
public boolean place(FeaturePlaceContext<BushWithOuterFeatureConfig> featureConfig) {
final RandomSource random = featureConfig.random();
final BlockPos pos = featureConfig.origin();
BushWithOuterFeatureConfig cfg = featureConfig.config();
BlockState outer_leaves = cfg.outer_leaves.getState(random, pos);
Block leaves = cfg.leaves.getState(random, pos).getBlock();
BlockState stem = cfg.stem.getState(random, pos);
final WorldGenLevel world = featureConfig.level();
if (!world.getBlockState(pos.below()).is(CommonBlockTags.END_STONES) && !world.getBlockState(pos.above())
.is(CommonBlockTags.END_STONES))
@ -50,14 +51,14 @@ public class BushWithOuterFeature extends DefaultFeature {
float radius = MHelper.randRange(1.8F, 3.5F, random);
OpenSimplexNoise noise = new OpenSimplexNoise(random.nextInt());
SDF sphere = new SDFSphere().setRadius(radius).setBlock(this.leaves);
SDF sphere = new SDFSphere().setRadius(radius).setBlock(leaves);
sphere = new SDFScale3D().setScale(1, 0.5F, 1).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> {
return (float) noise.eval(vec.x() * 0.2, vec.y() * 0.2, vec.z() * 0.2) * 3;
}).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> {
return MHelper.randRange(-2F, 2F, random);
}).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> (float) noise.eval(
vec.x() * 0.2,
vec.y() * 0.2,
vec.z() * 0.2
) * 3).setSource(sphere);
sphere = new SDFDisplacement().setFunction((vec) -> MHelper.randRange(-2F, 2F, random)).setSource(sphere);
sphere = new SDFSubtraction().setSourceA(sphere)
.setSourceB(new SDFTranslate().setTranslate(0, -radius, 0).setSource(sphere));
sphere.setReplaceFunction(REPLACE);
@ -67,7 +68,7 @@ public class BushWithOuterFeature extends DefaultFeature {
if (distance < 7) {
return info.getState().setValue(LeavesBlock.DISTANCE, distance);
} else {
return AIR;
return DefaultFeature.AIR;
}
}
return info.getState();
@ -78,7 +79,7 @@ public class BushWithOuterFeature extends DefaultFeature {
if (info.getState(dir).isAir()) {
info.setBlockPos(
info.getPos().relative(dir),
outer_leaves.defaultBlockState().setValue(BlockStateProperties.FACING, dir)
outer_leaves.setValue(BlockStateProperties.FACING, dir)
);
}
}

View file

@ -0,0 +1,37 @@
package org.betterx.betterend.world.features.bushes;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider;
import net.minecraft.world.level.levelgen.feature.stateproviders.SimpleStateProvider;
public class BushWithOuterFeatureConfig extends BushFeatureConfig {
public static final Codec<BushWithOuterFeatureConfig> CODEC = RecordCodecBuilder.create(instance -> instance
.group(
BlockStateProvider.CODEC.fieldOf("leaves").forGetter(o -> o.leaves),
BlockStateProvider.CODEC.fieldOf("outer_leaves").forGetter(o -> o.outer_leaves),
BlockStateProvider.CODEC.fieldOf("stem").forGetter(o -> o.stem)
)
.apply(instance, BushWithOuterFeatureConfig::new));
public final BlockStateProvider outer_leaves;
public BushWithOuterFeatureConfig(Block leaves, Block outer_leaves, Block stem) {
this(
SimpleStateProvider.simple(leaves),
SimpleStateProvider.simple(outer_leaves),
SimpleStateProvider.simple(stem)
);
}
public BushWithOuterFeatureConfig(
BlockStateProvider leaves,
BlockStateProvider outer_leaves,
BlockStateProvider stem
) {
super(leaves, stem);
this.outer_leaves = outer_leaves;
}
}

View file

@ -1,6 +1,5 @@
package org.betterx.betterend.world.features.terrain;
import org.betterx.bclib.api.v2.levelgen.features.features.DefaultFeature;
import org.betterx.bclib.sdf.SDF;
import org.betterx.bclib.sdf.operator.SDFRotation;
import org.betterx.bclib.sdf.operator.SDFTranslate;
@ -14,32 +13,27 @@ import net.minecraft.core.BlockPos;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
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;
import java.util.ArrayList;
import java.util.List;
public class IceStarFeature extends DefaultFeature {
private final float minSize;
private final float maxSize;
private final int minCount;
private final int maxCount;
public class IceStarFeature extends Feature<IceStarFeatureConfig> {
public IceStarFeature(float minSize, float maxSize, int minCount, int maxCount) {
this.minSize = minSize;
this.maxSize = maxSize;
this.minCount = minCount;
this.maxCount = maxCount;
public IceStarFeature() {
super(IceStarFeatureConfig.CODEC);
}
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
public boolean place(FeaturePlaceContext<IceStarFeatureConfig> featureConfig) {
final RandomSource random = featureConfig.random();
BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
float size = MHelper.randRange(minSize, maxSize, random);
int count = MHelper.randRange(minCount, maxCount, random);
IceStarFeatureConfig cfg = featureConfig.config();
float size = MHelper.randRange(cfg.minSize, cfg.maxSize, random);
int count = MHelper.randRange(cfg.minCount, cfg.maxCount, random);
List<Vector3f> points = getFibonacciPoints(count);
SDF sdf = null;
SDF spike = new SDFCappedCone().setRadius1(3 + (size - 5) * 0.2F)

View file

@ -0,0 +1,30 @@
package org.betterx.betterend.world.features.terrain;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
public class IceStarFeatureConfig implements FeatureConfiguration {
public static final Codec<IceStarFeatureConfig> CODEC = RecordCodecBuilder.create(instance -> instance
.group(
Codec.FLOAT.fieldOf("min_size").forGetter(o -> o.minSize),
Codec.FLOAT.fieldOf("max_size").forGetter(o -> o.maxSize),
Codec.INT.fieldOf("min_count").forGetter(o -> o.minCount),
Codec.INT.fieldOf("max_count").forGetter(o -> o.maxCount)
)
.apply(instance, IceStarFeatureConfig::new));
public final float minSize;
public final float maxSize;
public final int minCount;
public final int maxCount;
public IceStarFeatureConfig(float minSize, float maxSize, int minCount, int maxCount) {
this.minSize = minSize;
this.maxSize = maxSize;
this.minCount = minCount;
this.maxCount = maxCount;
}
}

View file

@ -1,36 +1,34 @@
package org.betterx.betterend.world.features.terrain;
import org.betterx.bclib.api.v2.levelgen.features.features.DefaultFeature;
import org.betterx.bclib.util.BlocksHelper;
import org.betterx.worlds.together.tag.v3.CommonBlockTags;
import net.minecraft.core.BlockPos;
import net.minecraft.util.RandomSource;
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.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.SimpleBlockConfiguration;
public class SingleBlockFeature extends DefaultFeature {
private final Block block;
public SingleBlockFeature(Block block) {
this.block = block;
public class SingleBlockFeature extends Feature<SimpleBlockConfiguration> {
public SingleBlockFeature() {
super(SimpleBlockConfiguration.CODEC);
}
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
public boolean place(FeaturePlaceContext<SimpleBlockConfiguration> featureConfig) {
final RandomSource random = featureConfig.random();
final BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
final SimpleBlockConfiguration cfg = featureConfig.config();
if (!world.getBlockState(pos.below()).is(CommonBlockTags.GEN_END_STONES)) {
return false;
}
BlockState state = block.defaultBlockState();
if (block.getStateDefinition().getProperty("waterlogged") != null) {
BlockState state = cfg.toPlace().getState(random, pos);
if (state.getBlock().getStateDefinition().getProperty("waterlogged") != null) {
boolean waterlogged = !world.getFluidState(pos).isEmpty();
state = state.setValue(BlockStateProperties.WATERLOGGED, waterlogged);
}

View file

@ -1,6 +1,5 @@
package org.betterx.betterend.world.features.terrain;
import org.betterx.bclib.api.v2.levelgen.features.features.DefaultFeature;
import org.betterx.bclib.blocks.StalactiteBlock;
import org.betterx.bclib.util.BlocksHelper;
import org.betterx.worlds.together.tag.v3.CommonBlockTags;
@ -10,35 +9,30 @@ import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
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.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
public class StalactiteFeature extends DefaultFeature {
private final boolean ceiling;
private final Block[] ground;
private final Block block;
public class StalactiteFeature extends Feature<StalactiteFeatureConfig> {
public StalactiteFeature(boolean ceiling, Block block, Block... ground) {
this.ceiling = ceiling;
this.ground = ground;
this.block = block;
public StalactiteFeature() {
super(StalactiteFeatureConfig.CODEC);
}
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> featureConfig) {
public boolean place(FeaturePlaceContext<StalactiteFeatureConfig> featureConfig) {
final RandomSource random = featureConfig.random();
final BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
if (!isGround(world.getBlockState(ceiling ? pos.above() : pos.below()).getBlock())) {
final StalactiteFeatureConfig cfg = featureConfig.config();
if (!cfg.allowedGround.test(world, cfg.ceiling ? pos.above() : pos.below())) {
return false;
}
MutableBlockPos mut = new MutableBlockPos().set(pos);
int height = random.nextInt(16);
int dir = ceiling ? -1 : 1;
int dir = cfg.ceiling ? -1 : 1;
boolean stalagnate = false;
for (int i = 1; i <= height; i++) {
@ -60,9 +54,9 @@ 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 base = cfg.block.getState(random, mut)
.setValue(StalactiteBlock.SIZE, size)
.setValue(BlockStateProperties.WATERLOGGED, waterlogged);
BlockState state = stalagnate ? base.setValue(
StalactiteBlock.IS_FLOOR,
dir > 0 ? i < center : i > center
@ -72,13 +66,4 @@ public class StalactiteFeature extends DefaultFeature {
return true;
}
private boolean isGround(Block block) {
for (Block b : ground) {
if (b == block) {
return true;
}
}
return false;
}
}

View file

@ -0,0 +1,39 @@
package org.betterx.betterend.world.features.terrain;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate;
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider;
import net.minecraft.world.level.levelgen.feature.stateproviders.SimpleStateProvider;
public class StalactiteFeatureConfig implements FeatureConfiguration {
public static final Codec<StalactiteFeatureConfig> CODEC = RecordCodecBuilder.create(instance -> instance
.group(
Codec.BOOL.fieldOf("ceiling").forGetter(o -> o.ceiling),
BlockStateProvider.CODEC.fieldOf("states").forGetter(o -> o.block),
BlockPredicate.CODEC.fieldOf("allowed_ground").forGetter(o -> o.allowedGround)
)
.apply(instance, StalactiteFeatureConfig::new));
public final boolean ceiling;
public final BlockStateProvider block;
public final BlockPredicate allowedGround;
public StalactiteFeatureConfig(boolean ceiling, Block block, Block... ground) {
this(
ceiling,
SimpleStateProvider.simple(block),
net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate.matchesBlocks(ground)
);
}
public StalactiteFeatureConfig(boolean ceiling, BlockStateProvider block, BlockPredicate allowedGround) {
this.ceiling = ceiling;
this.block = block;
this.allowedGround = allowedGround;
}
}

View file

@ -12,12 +12,13 @@ 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.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import com.google.common.collect.Sets;
import java.util.Optional;
import java.util.Set;
public class CaveChunkPopulatorFeature extends Feature<CaveChunkPopulatorFeatureConfig> {
@ -32,6 +33,7 @@ public class CaveChunkPopulatorFeature extends Feature<CaveChunkPopulatorFeature
final RandomSource random = featureConfig.random();
final BlockPos pos = featureConfig.origin();
final WorldGenLevel world = featureConfig.level();
final ChunkGenerator chunkGenerator = featureConfig.chunkGenerator();
Set<BlockPos> floorPositions = Sets.newHashSet();
Set<BlockPos> ceilPositions = Sets.newHashSet();
int sx = (pos.getX() >> 4) << 4;
@ -41,8 +43,8 @@ public class CaveChunkPopulatorFeature extends Feature<CaveChunkPopulatorFeature
fillSets(sx, sz, world.getChunk(pos), floorPositions, ceilPositions, min, max);
EndCaveBiome biome = cfg.getCaveBiome();
BlockState surfaceBlock = Blocks.END_STONE.defaultBlockState(); //biome.getBiome().getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
placeFloor(world, biome, floorPositions, random, surfaceBlock);
placeCeil(world, biome, ceilPositions, random);
placeFloor(world, chunkGenerator, biome, floorPositions, random, surfaceBlock);
placeCeil(world, chunkGenerator, biome, ceilPositions, random);
BlockFixer.fixBlocks(world, min, max);
return true;
}
@ -113,6 +115,7 @@ public class CaveChunkPopulatorFeature extends Feature<CaveChunkPopulatorFeature
protected void placeFloor(
WorldGenLevel world,
ChunkGenerator generator,
EndCaveBiome biome,
Set<BlockPos> floorPositions,
RandomSource random,
@ -122,9 +125,9 @@ public class CaveChunkPopulatorFeature extends Feature<CaveChunkPopulatorFeature
floorPositions.forEach((pos) -> {
BlocksHelper.setWithoutUpdate(world, pos, surfaceBlock);
if (density > 0 && random.nextFloat() <= density) {
Feature<?> feature = biome.getFloorFeature(random);
ConfiguredFeature<?, ?> feature = biome.getFloorFeature(random).value();
if (feature != null) {
feature.place(new FeaturePlaceContext<>(Optional.empty(), world, null, random, pos.above(), null));
feature.place(world, generator, random, pos.above());
}
}
});
@ -132,6 +135,7 @@ public class CaveChunkPopulatorFeature extends Feature<CaveChunkPopulatorFeature
protected void placeCeil(
WorldGenLevel world,
ChunkGenerator generator,
EndCaveBiome biome,
Set<BlockPos> ceilPositions,
RandomSource random
@ -143,9 +147,9 @@ public class CaveChunkPopulatorFeature extends Feature<CaveChunkPopulatorFeature
BlocksHelper.setWithoutUpdate(world, pos, ceilBlock);
}
if (density > 0 && random.nextFloat() <= density) {
Feature<?> feature = biome.getCeilFeature(random);
ConfiguredFeature<?, ?> feature = biome.getCeilFeature(random).value();
if (feature != null) {
feature.place(new FeaturePlaceContext<>(Optional.empty(), world, null, random, pos.below(), null));
feature.place(world, generator, random, pos.below());
}
}
});

View file

@ -22,8 +22,9 @@ import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.biome.Biome;
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.Heightmap;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
@ -31,7 +32,6 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import java.util.List;
import java.util.Optional;
import java.util.Set;
public abstract class EndCaveFeature extends DefaultFeature {
@ -64,6 +64,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
Set<BlockPos> caveBlocks = generate(world, center, radius, random);
if (!caveBlocks.isEmpty()) {
if (biome != null) {
ChunkGenerator generator = featureConfig.chunkGenerator();
setBiomes(world, biome, caveBlocks);
Set<BlockPos> floorPositions = Sets.newConcurrentHashSet();
Set<BlockPos> ceilPositions = Sets.newConcurrentHashSet();
@ -81,9 +82,9 @@ public abstract class EndCaveFeature extends DefaultFeature {
});
BlockState surfaceBlock = EndBiome.findTopMaterial(biome.bclBiome);
placeFloor(world, (EndCaveBiome) biome.bclBiome, floorPositions, random, surfaceBlock);
placeCeil(world, (EndCaveBiome) biome.bclBiome, ceilPositions, random);
placeWalls(world, (EndCaveBiome) biome.bclBiome, caveBlocks, random);
placeFloor(world, generator, (EndCaveBiome) biome.bclBiome, floorPositions, random, surfaceBlock);
placeCeil(world, generator, (EndCaveBiome) biome.bclBiome, ceilPositions, random);
placeWalls(world, generator, (EndCaveBiome) biome.bclBiome, caveBlocks, random);
}
fixBlocks(world, caveBlocks);
}
@ -95,6 +96,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
protected void placeFloor(
WorldGenLevel world,
ChunkGenerator generator,
EndCaveBiome biome,
Set<BlockPos> floorPositions,
RandomSource random,
@ -106,9 +108,9 @@ public abstract class EndCaveFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, pos, surfaceBlock);
}
if (density > 0 && random.nextFloat() <= density) {
Feature<?> feature = biome.getFloorFeature(random);
ConfiguredFeature<?, ?> feature = biome.getFloorFeature(random).value();
if (feature != null) {
feature.place(new FeaturePlaceContext<>(Optional.empty(), world, null, random, pos.above(), null));
feature.place(world, generator, random, pos.above());
}
}
});
@ -116,6 +118,7 @@ public abstract class EndCaveFeature extends DefaultFeature {
protected void placeCeil(
WorldGenLevel world,
ChunkGenerator generator,
EndCaveBiome biome,
Set<BlockPos> ceilPositions,
RandomSource random
@ -127,15 +130,21 @@ public abstract class EndCaveFeature extends DefaultFeature {
BlocksHelper.setWithoutUpdate(world, pos, ceilBlock);
}
if (density > 0 && random.nextFloat() <= density) {
Feature<?> feature = biome.getCeilFeature(random);
ConfiguredFeature<?, ?> feature = biome.getCeilFeature(random).value();
if (feature != null) {
feature.place(new FeaturePlaceContext<>(Optional.empty(), world, null, random, pos.below(), null));
feature.place(world, generator, random, pos.below());
}
}
});
}
protected void placeWalls(WorldGenLevel world, EndCaveBiome biome, Set<BlockPos> positions, RandomSource random) {
protected void placeWalls(
WorldGenLevel world,
ChunkGenerator generator,
EndCaveBiome biome,
Set<BlockPos> positions,
RandomSource random
) {
Set<BlockPos> placed = Sets.newHashSet();
positions.forEach(pos -> {
if (random.nextInt(4) == 0 && hasOpenSide(pos, positions)) {

View file

@ -21,9 +21,10 @@ import net.minecraft.world.level.biome.Biome;
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.Heightmap.Types;
import net.minecraft.world.level.levelgen.LegacyRandomSource;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
@ -31,7 +32,6 @@ import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.IntStream;
@ -136,6 +136,7 @@ public class TunelCaveFeature extends EndCaveFeature {
return false;
}
final ChunkGenerator generator = featureConfig.chunkGenerator();
Map<BiomePicker.ActualBiome, Set<BlockPos>> floorSets = Maps.newHashMap();
Map<BiomePicker.ActualBiome, Set<BlockPos>> ceilSets = Maps.newHashMap();
MutableBlockPos mut = new MutableBlockPos();
@ -176,13 +177,13 @@ public class TunelCaveFeature extends EndCaveFeature {
floorSets.forEach((biome, floorPositions) -> {
BlockState surfaceBlock = EndBiome.findTopMaterial(biome.bclBiome);
placeFloor(world, (EndCaveBiome) biome.bclBiome, floorPositions, random, surfaceBlock);
placeFloor(world, generator, (EndCaveBiome) biome.bclBiome, floorPositions, random, surfaceBlock);
});
ceilSets.forEach((biome, ceilPositions) -> {
placeCeil(world, (EndCaveBiome) biome.bclBiome, ceilPositions, random);
placeCeil(world, generator, (EndCaveBiome) biome.bclBiome, ceilPositions, random);
});
BiomePicker.ActualBiome biome = EndBiomes.getCaveBiome(pos.getX(), pos.getZ());
placeWalls(world, (EndCaveBiome) biome.bclBiome, caveBlocks, random);
placeWalls(world, generator, (EndCaveBiome) biome.bclBiome, caveBlocks, random);
fixBlocks(world, caveBlocks);
return true;
@ -196,6 +197,7 @@ public class TunelCaveFeature extends EndCaveFeature {
@Override
protected void placeFloor(
WorldGenLevel world,
ChunkGenerator generator,
EndCaveBiome biome,
Set<BlockPos> floorPositions,
RandomSource random,
@ -207,9 +209,9 @@ public class TunelCaveFeature extends EndCaveFeature {
BlocksHelper.setWithoutUpdate(world, pos, surfaceBlock);
}
if (density > 0 && random.nextFloat() <= density) {
Feature<?> feature = biome.getFloorFeature(random);
ConfiguredFeature<?, ?> feature = biome.getFloorFeature(random).value();
if (feature != null) {
feature.place(new FeaturePlaceContext<>(Optional.empty(), world, null, random, pos.above(), null));
feature.place(world, generator, random, pos.above());
}
}
});
@ -218,6 +220,7 @@ public class TunelCaveFeature extends EndCaveFeature {
@Override
protected void placeCeil(
WorldGenLevel world,
ChunkGenerator generator,
EndCaveBiome biome,
Set<BlockPos> ceilPositions,
RandomSource random
@ -229,9 +232,9 @@ public class TunelCaveFeature extends EndCaveFeature {
BlocksHelper.setWithoutUpdate(world, pos, ceilBlock);
}
if (density > 0 && random.nextFloat() <= density) {
Feature<?> feature = biome.getCeilFeature(random);
ConfiguredFeature<?, ?> feature = biome.getCeilFeature(random).value();
if (feature != null) {
feature.place(new FeaturePlaceContext<>(Optional.empty(), world, null, random, pos.below(), null));
feature.place(world, generator, random, pos.below());
}
}
});