35 lines
1.7 KiB
Java
35 lines
1.7 KiB
Java
package net.minecraft.world.level.levelgen.placement;
|
|
|
|
import net.minecraft.world.level.levelgen.feature.configurations.DecoratorConfiguration;
|
|
import java.util.stream.IntStream;
|
|
import net.minecraft.world.level.biome.Biome;
|
|
import java.util.stream.Stream;
|
|
import net.minecraft.core.BlockPos;
|
|
import java.util.Random;
|
|
import net.minecraft.world.level.levelgen.ChunkGeneratorSettings;
|
|
import net.minecraft.world.level.chunk.ChunkGenerator;
|
|
import net.minecraft.world.level.LevelAccessor;
|
|
import com.mojang.datafixers.Dynamic;
|
|
import java.util.function.Function;
|
|
|
|
public class TopSolidHeightMapNoiseBasedDecorator extends FeatureDecorator<NoiseCountFactorDecoratorConfiguration> {
|
|
public TopSolidHeightMapNoiseBasedDecorator(final Function<Dynamic<?>, ? extends NoiseCountFactorDecoratorConfiguration> function) {
|
|
super(function);
|
|
}
|
|
|
|
@Override
|
|
public Stream<BlockPos> getPositions(final LevelAccessor bju, final ChunkGenerator<? extends ChunkGeneratorSettings> bzx, final Random random, final NoiseCountFactorDecoratorConfiguration ckg, final BlockPos fk) {
|
|
final double double7 = Biome.BIOME_INFO_NOISE.getValue(fk.getX() / ckg.noiseFactor, fk.getZ() / ckg.noiseFactor, false);
|
|
final int integer9 = (int)Math.ceil((double7 + ckg.noiseOffset) * ckg.noiseToCountRatio);
|
|
final int integer10;
|
|
final int integer11;
|
|
final int integer12;
|
|
return IntStream.range(0, integer9).<BlockPos>mapToObj(integer -> {
|
|
integer10 = random.nextInt(16) + fk.getX();
|
|
integer11 = random.nextInt(16) + fk.getZ();
|
|
integer12 = bju.getHeight(ckg.heightmap, integer10, integer11);
|
|
return new BlockPos(integer10, integer12, integer11);
|
|
});
|
|
}
|
|
}
|