net.minecraft.world.gen.feature.ConfiguredFeature Java Examples

The following examples show how to use net.minecraft.world.gen.feature.ConfiguredFeature. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OilPoolGenerator.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
public static void registerOilLake() {
    for (Biome biome : Biome.BIOMES) {
        if (!biome.getCategory().equals(Biomes.NETHER_WASTES.getCategory()) && !biome.getCategory().equals(Biomes.THE_END.getCategory())) {

            biome.addFeature(GenerationStep.Feature.UNDERGROUND_DECORATION, new ConfiguredFeature<>((LakeFeature) Feature.LAKE, new SingleStateFeatureConfig(GalacticraftBlocks.CRUDE_OIL.getDefaultState())));
        }
    }
}
 
Example #2
Source File: DeceasedGrassBlock.java    From the-hallow with MIT License 5 votes vote down vote up
@Override
public void grow(ServerWorld world, Random random, BlockPos blockPos, BlockState blockState) {
	BlockPos upPos = blockPos.up();
	BlockState grassBlock = HallowedBlocks.DECEASED_GRASS_BLOCK.getDefaultState();
	
	label48:
	for (int i = 0; i < 128; ++i) {
		BlockPos randomPos = upPos;
		
		for (int j = 0; j < i / 16; ++j) {
			randomPos = randomPos.add(random.nextInt(3) - 1, (random.nextInt(3) - 1) * random.nextInt(3) / 2, random.nextInt(3) - 1);
			if (world.getBlockState(randomPos.down()).getBlock() != this || world.getBlockState(randomPos).isFullCube(world, randomPos)) {
				continue label48;
			}
		}
		
		BlockState randomBlockState = world.getBlockState(randomPos);
		if (randomBlockState.getBlock() == grassBlock.getBlock() && random.nextInt(10) == 0) {
			((Fertilizable) grassBlock.getBlock()).grow(world, random, randomPos, randomBlockState);
		}
		
		if (randomBlockState.isAir()) {
			BlockState stateToPlace;
			if (random.nextInt(8) == 0) {
				List<ConfiguredFeature<?, ?>> list = world.getBiomeAccess().getBiome(randomPos).getFlowerFeatures();
				if (list.isEmpty()) {
					continue;
				}
				stateToPlace = ((FlowerFeature) ((DecoratedFeatureConfig) (list.get(0)).config).feature.feature).getFlowerToPlace(random, randomPos, list.get(0).config);
			} else {
				stateToPlace = grassBlock;
			}
			
			if (stateToPlace.canPlaceAt(world, randomPos)) {
				world.setBlockState(randomPos, stateToPlace, 3);
			}
		}
	}
}
 
Example #3
Source File: FeatureGenerator.java    From fabric-carpet with MIT License 5 votes vote down vote up
private static Thing simplePlop(ConfiguredFeature feature)
{
    return (w, p) -> {
        CarpetSettings.skipGenerationChecks=true;
        try
        {
            return feature.generate(w, w.getChunkManager().getChunkGenerator(), w.random, p);
        }
        finally
        {
            CarpetSettings.skipGenerationChecks = false;
        }
    };
}
 
Example #4
Source File: HallowedBiomeFeatures.java    From the-hallow with MIT License 4 votes vote down vote up
public static <F extends FeatureConfig, D extends DecoratorConfig> ConfiguredFeature<?, ?> configureFeature(Feature<F> feature, F featureConfig, Decorator<D> decorator, D decoratorConfig) {
	Feature<DecoratedFeatureConfig> feature2 = feature instanceof FlowerFeature ? Feature.DECORATED_FLOWER : Feature.DECORATED;
	return new ConfiguredFeature(feature2, new DecoratedFeatureConfig(feature.configure(featureConfig), decorator.configure(decoratorConfig)));
}
 
Example #5
Source File: DeadwoodSaplingGenerator.java    From the-hallow with MIT License 4 votes vote down vote up
@Override
protected ConfiguredFeature<BranchedTreeFeatureConfig, ?> createTreeFeature(Random rand, boolean bool) {
	return HallowedFeatures.SMALL_DEADWOOD_TREE.configure(HallowedFeatures.SMALL_DEADWOOD_TREE_CONFIG);
}
 
Example #6
Source File: DeadwoodSaplingGenerator.java    From the-hallow with MIT License 4 votes vote down vote up
@Override
protected ConfiguredFeature<MegaTreeFeatureConfig, ?> createLargeTreeFeature(Random var1) {
	return HallowedFeatures.LARGE_DEADWOOD_TREE.configure(HallowedFeatures.LARGE_DEADWOOD_TREE_CONFIG);
}