tutorial:features
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:features [2023/12/18 01:12] – [Creating a feature] updat ecode solidblock | tutorial:features [2024/10/28 17:58] (current) – Fix new identifier vs Identifier.of cassiancc | ||
---|---|---|---|
Line 70: | Line 70: | ||
< | < | ||
public record ExampleFeatureConfig(int number, Identifier blockId) implements FeatureConfig { | public record ExampleFeatureConfig(int number, Identifier blockId) implements FeatureConfig { | ||
- | public static Codec< | + | public static |
instance -> instance.group( | instance -> instance.group( | ||
// you can add as many of these as you want, one for each parameter | // you can add as many of these as you want, one for each parameter | ||
Line 83: | Line 83: | ||
<code java> | <code java> | ||
public class ExampleMod implements ModInitializer { | public class ExampleMod implements ModInitializer { | ||
- | public static final Identifier EXAMPLE_FEATURE_ID = new Identifier(" | + | public static final Identifier EXAMPLE_FEATURE_ID = Identifier.of(" |
- | public static final Feature< | + | public static final ExampleFeature |
@Override | @Override | ||
Line 101: | Line 101: | ||
public class FeatureExampleMod implements ModInitializer { | public class FeatureExampleMod implements ModInitializer { | ||
- | public static final Identifier EXAMPLE_FEATURE_ID = new Identifier(" | + | public static final Identifier EXAMPLE_FEATURE_ID = Identifier.of(" |
- | public static | + | public static |
- | public static ConfiguredFeature< | + | public static |
- | | + | EXAMPLE_FEATURE, |
- | new ExampleFeatureConfig(10, | + | new ExampleFeatureConfig(10, |
); | ); | ||
Line 117: | Line 117: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | FIXME The last line has to be updated | ||
==== Adding a configured feature to a biome ==== | ==== Adding a configured feature to a biome ==== | ||
Line 123: | Line 125: | ||
Our final initializer class looks like this: | Our final initializer class looks like this: | ||
< | < | ||
- | public class FeatureExampleMod | + | public class ExampleMod |
- | public static final Identifier EXAMPLE_FEATURE_ID = new Identifier(" | + | public static final Identifier EXAMPLE_FEATURE_ID = Identifier.of(" |
- | public static | + | public static |
- | public static ConfiguredFeature< | + | public static |
- | | + | EXAMPLE_FEATURE, |
- | new ExampleFeatureConfig(10, | + | new ExampleFeatureConfig(10, |
); | ); | ||
// our PlacedFeature. this is what gets passed to the biome modification API to add to the biome. | // our PlacedFeature. this is what gets passed to the biome modification API to add to the biome. | ||
Line 135: | Line 137: | ||
RegistryEntry.of( | RegistryEntry.of( | ||
EXAMPLE_FEATURE_CONFIGURED | EXAMPLE_FEATURE_CONFIGURED | ||
- | // the SquarePlacementModifier makes the feature generate a cluster of pillars each time | + | |
), List.of(SquarePlacementModifier.of()) | ), List.of(SquarePlacementModifier.of()) | ||
); | ); | ||
Line 141: | Line 143: | ||
@Override | @Override | ||
public void onInitialize() { | public void onInitialize() { | ||
- | // register the features | + | |
Registry.register(class_7923.field_41144, | Registry.register(class_7923.field_41144, | ||
- | Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, | ||
- | Registry.register(BuiltinRegistries.PLACED_FEATURE, | ||
- | // 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.1702861922.txt.gz · Last modified: 2023/12/18 01:12 by solidblock