use of net.minecraft.world.level.chunk.ChunkGenerator in project Tropicraft by Tropicraft.
the class TropicraftTrees method create.
private static AbstractTreeGrower create(FeatureProvider featureProvider) {
return new AbstractTreeGrower() {
@Nullable
@Override
protected ConfiguredFeature<TreeConfiguration, ?> getConfiguredFeature(Random random, boolean beehive) {
return null;
}
@Override
public boolean growTree(ServerLevel world, ChunkGenerator generator, BlockPos pos, BlockState sapling, Random random) {
ConfiguredFeature<?, ?> feature = featureProvider.getFeature(world.getServer(), random, this.hasFlowers(world, pos));
if (feature == null) {
return false;
}
world.setBlock(pos, Blocks.AIR.defaultBlockState(), Block.UPDATE_INVISIBLE);
if (feature.place(world, generator, random, pos)) {
return true;
} else {
world.setBlock(pos, sapling, Block.UPDATE_INVISIBLE);
return false;
}
}
private boolean hasFlowers(LevelAccessor world, BlockPos origin) {
BlockPos min = origin.offset(-2, -1, -2);
BlockPos max = origin.offset(2, 1, 2);
for (BlockPos pos : BlockPos.MutableBlockPos.betweenClosed(min, max)) {
if (world.getBlockState(pos).is(BlockTags.FLOWERS)) {
return true;
}
}
return false;
}
};
}
use of net.minecraft.world.level.chunk.ChunkGenerator in project Tropicraft by Tropicraft.
the class TropicraftDimension method createDimension.
public static LevelStem createDimension(Registry<DimensionType> dimensionTypeRegistry, Registry<Biome> biomeRegistry, Registry<NoiseGeneratorSettings> dimensionSettingsRegistry, long seed) {
Supplier<DimensionType> dimensionType = () -> dimensionTypeRegistry.getOrThrow(TropicraftDimension.DIMENSION_TYPE);
ChunkGenerator generator = TropicraftDimension.createGenerator(biomeRegistry, dimensionSettingsRegistry, seed);
return new LevelStem(dimensionType, generator);
}
Aggregations