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
Next revision
Previous revision
Next revisionBoth sides next revision
tutorial:features [2020/09/05 20:01] – 1.16.2 siglongtutorial:features [2020/11/02 13:27] – Use Biome Modification API in Fabric API siglong
Line 1: Line 1:
-===== Generating Features in your World ===== +===== Adding Features [1.16.3] ===== 
-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 feature to a biome+  * Use [[https://github.com/FabricMC/fabric/pull/1097|Biome Modification API in Fabric API]] to add your feature to biomes. 
 + 
 +Note that the Biome Modification API is marked as experimental. If the API doesn't work, consider using [[?rev=1599388928|the mixin version]].
  
 ==== 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<?, ?> STONE_SPIRAL_CONFIGURED = STONE_SPIRAL.configure(FeatureConfig.DEFAULT)   public static final ConfiguredFeature<?, ?> STONE_SPIRAL_CONFIGURED = STONE_SPIRAL.configure(FeatureConfig.DEFAULT)
-      .decorate(Decorator.CHANCE.configure(new ChanceDecoratorConfig(100)));+      .decorate(Decorator.CHANCE.configure(new ChanceDecoratorConfig(5)));
  
   @Override   @Override
   public void onInitialize() {   public void onInitialize() {
-    Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier("tutorial", "stone_spiral"), STONE_SPIRAL_CONFIGURED);+    [...] 
 +     
 +    RegistryKey<ConfiguredFeature<?, ?>> stoneSpiral = RegistryKey.of(Registry.CONFIGURED_FEATURE_WORLDGEN, 
 +        new Identifier("tutorial", "stone_spiral")); 
 +    Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, stoneSpiral.getValue(), STONE_SPIRAL_CONFIGURED);
   }   }
 } }
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 ''DefaultBiomeFeatures.addPlainsFeatures''We modify this method to add our feature to the plain biomes.+We use the Biome Modification API.
  
 <code java> <code java>
-@Mixin(DefaultBiomeFeatures.class) +public class ExampleMod implements ModInitializer { 
-public class DefaultBiomeFeaturesMixin +  [...] 
-  @Inject(method = "addPlainsFeatures(Lnet/minecraft/world/biome/GenerationSettings$Builder;)V", at = @At("TAIL")) + 
-  private static void addPlainsFeaturs(GenerationSettings.Builder builder, CallbackInfo ci) { +  @Override 
-    builder.feature(GenerationStep.Feature.TOP_LAYER_MODIFICATIONExampleMod.STONE_SPIRAL_CONFIGURED);+  public void onInitialize() { 
 +    [...] 
 +    BiomeModifications.addFeature(BiomeSelectors.all(), GenerationStep.Feature.UNDERGROUND_ORESstoneSpiral);
   }   }
 } }
 </code> </code>
  
-The first argument of ''feature'' helps determine when the structure is generated.+The first argument of ''addFeature'' determine what biomes the structure is generated in. 
 + 
 +The second argument helps determine when the structure is generated.
 For above-ground houses you may go with ''SURFACE_STRUCTURES'', and for caves, you might go with ''RAW_GENERATION''. For above-ground houses you may go with ''SURFACE_STRUCTURES'', and for caves, you might go with ''RAW_GENERATION''.
  
tutorial/features.txt · Last modified: 2023/12/18 01:19 by solidblock