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/04/23 18:53] – [Adding a Feature to a Biome] Update feature configuration 2xsaiko | tutorial:features [2020/08/11 09:27] – Updated code snippets to work with newer version of fabric dysnomian | ||
---|---|---|---|
Line 7: | Line 7: | ||
public class StoneSpiralFeature extends Feature< | public class StoneSpiralFeature extends Feature< | ||
- | public StoneSpiralFeature(Function<Dynamic<?>, | + | public StoneSpiralFeature(Codec< |
super(config); | super(config); | ||
} | } | ||
@Override | @Override | ||
- | public boolean generate(IWorld | + | public boolean generate(ServerWorldAccess |
BlockPos topPos = world.getTopPosition(Heightmap.Type.WORLD_SURFACE, | BlockPos topPos = world.getTopPosition(Heightmap.Type.WORLD_SURFACE, | ||
Direction offset = Direction.NORTH; | Direction offset = Direction.NORTH; | ||
Line 26: | Line 26: | ||
</ | </ | ||
- | The constructor takes in a '' | + | The '' |
- | `generate` is called when the chunk decides to generate the feature. If the feature is configured to spawn every chunk, this would be called for each chunk being generated as well. In the case of the feature being configured to spawn at a certain rate per biome, | + | '' |
In our implementation, | In our implementation, | ||
Line 34: | Line 34: | ||
<code java> | <code java> | ||
@Override | @Override | ||
- | public boolean generate(IWorld | + | public boolean generate(WorldAccess |
BlockPos topPos = world.getTopPosition(Heightmap.Type.WORLD_SURFACE, | BlockPos topPos = world.getTopPosition(Heightmap.Type.WORLD_SURFACE, | ||
Direction offset = Direction.NORTH; | Direction offset = Direction.NORTH; | ||
Line 50: | Line 50: | ||
Features can be registered like most other content in the game, and there aren't any special builders or mechanics you'll have to worry about. | Features can be registered like most other content in the game, and there aren't any special builders or mechanics you'll have to worry about. | ||
<code java> | <code java> | ||
- | private static final Feature< | + | private static final Feature< |
Registry.FEATURE, | Registry.FEATURE, | ||
new Identifier(" | new Identifier(" | ||
- | new StoneSpiralFeature(DefaultFeatureConfig:: | + | new StoneSpiralFeature(DefaultFeatureConfig.CODEC) |
); | ); | ||
</ | </ | ||
Line 62: | Line 62: | ||
We can iterate over '' | We can iterate over '' | ||
<code java> | <code java> | ||
- | Registry.BIOME.forEach(biome -> biome.addFeature( | + | Registry.BIOME.forEach(biome -> |
- | | + | .configure(new DefaultFeatureConfig()) |
- | LAVA_HOLE.configure(new DefaultFeatureConfig()) | + | .createDecoratedFeature(Decorator.CHANCE_HEIGHTMAP.configure(new ChanceDecoratorConfig(100))) |
- | .createDecoratedFeature(Decorator.CHANCE_HEIGHTMAP.configure(new ChanceDecoratorConfig(100))); | + | )); |
- | )); | + | |
</ | </ | ||
tutorial/features.txt · Last modified: 2023/12/18 01:19 by solidblock