tutorial:features
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:features [2020/09/05 20:02] – Fix typo siglong | tutorial:features [2020/11/02 13:27] – Use Biome Modification API in Fabric API siglong | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Generating | + | ===== Adding |
- | Rocks, trees, ores, and ponds are all examples of Features. | + | Rocks, trees, ores, and ponds are all examples of features. |
They are simple generation additions to the world which generate depending on how they are configured. | They are simple generation additions to the world which generate depending on how they are configured. | ||
In this tutorial, we'll look at generating a simple stone spiral feature in the plain biomes randomly. | In this tutorial, we'll look at generating a simple stone spiral feature in the plain biomes randomly. | ||
Line 7: | Line 7: | ||
* Create a feature | * Create a feature | ||
* Configure a feature | * Configure a feature | ||
- | * Add a configured | + | * Use [[https:// |
+ | |||
+ | Note that the Biome Modification API is marked as experimental. If the API doesn' | ||
==== Creating a feature ==== | ==== Creating a feature ==== | ||
Line 57: | Line 59: | ||
==== Configuring a feature ==== | ==== Configuring a feature ==== | ||
- | We need to give a configuration to a feature. | + | We need to give a configuration to a feature. Make sure to register configured feature as well as feature. |
<code java> | <code java> | ||
public class ExampleMod implements ModInitializer { | public class ExampleMod implements ModInitializer { | ||
public static final ConfiguredFeature<?, | public static final ConfiguredFeature<?, | ||
- | .decorate(Decorator.CHANCE.configure(new ChanceDecoratorConfig(100))); | + | .decorate(Decorator.CHANCE.configure(new ChanceDecoratorConfig(5))); |
@Override | @Override | ||
public void onInitialize() { | public void onInitialize() { | ||
- | | + | |
+ | |||
+ | RegistryKey< | ||
+ | | ||
+ | Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, | ||
} | } | ||
} | } | ||
Line 76: | Line 82: | ||
==== Adding a configured feature to a biome ==== | ==== Adding a configured feature to a biome ==== | ||
- | Vanilla features generated in the plain biomes are listed in '' | + | We use the Biome Modification API. |
<code java> | <code java> | ||
- | @Mixin(DefaultBiomeFeatures.class) | + | public class ExampleMod implements ModInitializer |
- | public class DefaultBiomeFeaturesMixin | + | [...] |
- | @Inject(method = " | + | |
- | | + | @Override |
- | | + | |
+ | | ||
+ | BiomeModifications.addFeature(BiomeSelectors.all(), | ||
} | } | ||
} | } | ||
</ | </ | ||
- | The first argument of '' | + | The first argument of '' |
+ | |||
+ | The second argument | ||
For above-ground houses you may go with '' | For above-ground houses you may go with '' | ||
tutorial/features.txt · Last modified: 2023/12/18 01:19 by solidblock