44 lines
1.9 KiB
Java
44 lines
1.9 KiB
Java
package net.minecraft.world.level.levelgen.placement;
|
|
|
|
import net.minecraft.world.level.levelgen.feature.configurations.DecoratorConfiguration;
|
|
import java.util.function.Predicate;
|
|
import java.util.Objects;
|
|
import net.minecraft.world.level.levelgen.Heightmap;
|
|
import java.util.stream.IntStream;
|
|
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;
|
|
import net.minecraft.world.level.levelgen.feature.configurations.NoneDecoratorConfiguration;
|
|
|
|
public class ChorusPlantPlacementDecorator extends FeatureDecorator<NoneDecoratorConfiguration> {
|
|
public ChorusPlantPlacementDecorator(final Function<Dynamic<?>, ? extends NoneDecoratorConfiguration> function) {
|
|
super(function);
|
|
}
|
|
|
|
@Override
|
|
public Stream<BlockPos> getPositions(final LevelAccessor bju, final ChunkGenerator<? extends ChunkGeneratorSettings> bzx, final Random random, final NoneDecoratorConfiguration cgr, final BlockPos fk) {
|
|
final int integer7 = random.nextInt(5);
|
|
final int integer8;
|
|
final int integer9;
|
|
final int integer10;
|
|
int integer11;
|
|
return IntStream.range(0, integer7).<BlockPos>mapToObj(integer -> {
|
|
integer8 = random.nextInt(16) + fk.getX();
|
|
integer9 = random.nextInt(16) + fk.getZ();
|
|
integer10 = bju.getHeight(Heightmap.Types.MOTION_BLOCKING, integer8, integer9);
|
|
if (integer10 > 0) {
|
|
integer11 = integer10 - 1;
|
|
return new BlockPos(integer8, integer11, integer9);
|
|
}
|
|
else {
|
|
return null;
|
|
}
|
|
}).filter(Objects::nonNull);
|
|
}
|
|
}
|