Created configured features registry. Created feature for firefly bush patch.
This commit is contained in:
@ -0,0 +1,44 @@
|
|||||||
|
package dev.micle.firefly_bush_backport.worldgen;
|
||||||
|
|
||||||
|
import dev.micle.firefly_bush_backport.FireflyBushBackport;
|
||||||
|
import dev.micle.firefly_bush_backport.block.ModBlocks;
|
||||||
|
import net.minecraft.core.registries.Registries;
|
||||||
|
import net.minecraft.data.worldgen.BootstapContext;
|
||||||
|
import net.minecraft.data.worldgen.placement.PlacementUtils;
|
||||||
|
import net.minecraft.resources.ResourceKey;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
||||||
|
import net.minecraft.world.level.levelgen.feature.Feature;
|
||||||
|
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
|
||||||
|
import net.minecraft.world.level.levelgen.feature.configurations.RandomPatchConfiguration;
|
||||||
|
import net.minecraft.world.level.levelgen.feature.configurations.SimpleBlockConfiguration;
|
||||||
|
import net.minecraft.world.level.levelgen.feature.stateproviders.SimpleStateProvider;
|
||||||
|
|
||||||
|
public class ModConfiguredFeatures {
|
||||||
|
public static final ResourceKey<ConfiguredFeature<?, ?>> PATCH_FIREFLY_BUSH_KEY = registerKey("patch_firefly_bush");
|
||||||
|
|
||||||
|
public static void bootstrap(BootstapContext<ConfiguredFeature<?, ?>> context) {
|
||||||
|
register(context, PATCH_FIREFLY_BUSH_KEY, Feature.RANDOM_PATCH, new RandomPatchConfiguration(
|
||||||
|
20,
|
||||||
|
4,
|
||||||
|
3,
|
||||||
|
PlacementUtils.onlyWhenEmpty(
|
||||||
|
Feature.SIMPLE_BLOCK,
|
||||||
|
new SimpleBlockConfiguration(
|
||||||
|
SimpleStateProvider.simple(ModBlocks.FIREFLY_BUSH.get())
|
||||||
|
)
|
||||||
|
)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResourceKey<ConfiguredFeature<?, ?>> registerKey(String name) {
|
||||||
|
return ResourceKey.create(Registries.CONFIGURED_FEATURE, ResourceLocation.fromNamespaceAndPath(FireflyBushBackport.MOD_ID, name));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <FC extends FeatureConfiguration, F extends Feature<FC>> void register(
|
||||||
|
BootstapContext<ConfiguredFeature<?, ?>> context,
|
||||||
|
ResourceKey<ConfiguredFeature<?, ?>> key, F feature, FC configuration
|
||||||
|
) {
|
||||||
|
context.register(key, new ConfiguredFeature<>(feature, configuration));
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user