User Tools

Site Tools


tutorial:features

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
tutorial:features [2023/12/18 01:16] – [Creating a feature] solidblocktutorial:features [2023/12/18 01:19] (current) – [Adding a configured feature to a biome] update code solidblock
Line 125: Line 125:
 Our final initializer class looks like this: Our final initializer class looks like this:
 <yarncode java> <yarncode java>
-public class FeatureExampleMod implements ModInitializer {+public class ExampleMod implements ModInitializer {
  
     public static final Identifier EXAMPLE_FEATURE_ID = new Identifier("tutorial", "example_feature");     public static final Identifier EXAMPLE_FEATURE_ID = new Identifier("tutorial", "example_feature");
-    public static Feature<ExampleFeatureConfig> EXAMPLE_FEATURE = new ExampleFeature(ExampleFeatureConfig.CODEC); +    public static final ExampleFeature EXAMPLE_FEATURE = new ExampleFeature(ExampleFeatureConfig.CODEC); 
-    public static ConfiguredFeature<ExampleFeatureConfig, ExampleFeature> EXAMPLE_FEATURE_CONFIGURED = new ConfiguredFeature<>+    public static final ConfiguredFeature<ExampleFeatureConfig, ExampleFeature> EXAMPLE_FEATURE_CONFIGURED = new ConfiguredFeature<>
-                    (ExampleFeature) EXAMPLE_FEATURE,+                    EXAMPLE_FEATURE,
                     new ExampleFeatureConfig(10, new Identifier("minecraft", "netherite_block"))                     new ExampleFeatureConfig(10, new Identifier("minecraft", "netherite_block"))
     );     );
Line 137: Line 137:
             RegistryEntry.of(             RegistryEntry.of(
                     EXAMPLE_FEATURE_CONFIGURED                     EXAMPLE_FEATURE_CONFIGURED
-//                    the SquarePlacementModifier makes the feature generate a cluster of pillars each time+                  //  the SquarePlacementModifier makes the feature generate a cluster of pillars each time
             ), List.of(SquarePlacementModifier.of())             ), List.of(SquarePlacementModifier.of())
     );     );
Line 143: Line 143:
     @Override     @Override
     public void onInitialize() {     public void onInitialize() {
-//        register the features+        // register the features
         Registry.register(class_7923.field_41144, EXAMPLE_FEATURE_ID, EXAMPLE_FEATURE);         Registry.register(class_7923.field_41144, EXAMPLE_FEATURE_ID, EXAMPLE_FEATURE);
-        Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, EXAMPLE_FEATURE_ID, EXAMPLE_FEATURE_CONFIGURED); 
-        Registry.register(BuiltinRegistries.PLACED_FEATURE, EXAMPLE_FEATURE_ID, EXAMPLE_FEATURE_PLACED); 
  
-//        add it to overworld biomes using FAPI+        // add it to overworld biomes using FAPI
         BiomeModifications.addFeature(         BiomeModifications.addFeature(
                 BiomeSelectors.foundInOverworld(),                 BiomeSelectors.foundInOverworld(),
                 // the feature is to be added while flowers and trees are being generated                 // the feature is to be added while flowers and trees are being generated
                 GenerationStep.Feature.VEGETAL_DECORATION,                 GenerationStep.Feature.VEGETAL_DECORATION,
-                RegistryKey.of(Registry.PLACED_FEATURE_KEY, EXAMPLE_FEATURE_ID));+                RegistryKey.of(RegistryKeys.PLACED_FEATURE, EXAMPLE_FEATURE_ID));
     }     }
 } }
tutorial/features.txt · Last modified: 2023/12/18 01:19 by solidblock