User Tools

Site Tools


zh_cn: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 revisionBoth sides next revision
zh_cn:tutorial:features [2021/07/12 01:09] – 译名标准化:feature = 地物(地形特征) solidblockzh_cn:tutorial:features [2021/07/12 01:12] – [注册一个Feature] solidblock
Line 53: Line 53:
 </code> </code>
  
-==== 注册一个Feature ==== +==== 配置地形特征 ==== 
-可以像注册游戏中其他大多数内容一样注册Feature,而且您不必担心任何殊的构建器或机制+我们需要为地形特征提供配置。确保注册配置地形征和地形特征 
 <code java> <code java>
-private static final Feature<DefaultFeatureConfigLAVA_HOLE Registry.register+public class ExampleMod implements ModInitializer { 
- Registry.FEATURE+  public static final ConfiguredFeature<?, ?STONE_SPIRAL_CONFIGURED STONE_SPIRAL.configure(FeatureConfig.DEFAULT) 
- new Identifier("tutorial", "stone_spiral"), +      .decorate(Decorator.CHANCE.configure(new ChanceDecoratorConfig(5))); 
- new StoneSpiralFeature(DefaultFeatureConfig::deserialize) + 
-);+  @Override 
 +  public void onInitialize() { 
 +    [...] 
 +     
 +    RegistryKey<ConfiguredFeature<?, ?>> stoneSpiral = RegistryKey.of(Registry.CONFIGURED_FEATURE_KEY
 +        new Identifier("tutorial", "stone_spiral")); 
 +    Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, stoneSpiral.getValue(), STONE_SPIRAL_CONFIGURED); 
 +  } 
 +}
 </code> </code>
 +
 +Decorator表示世界如何选择放置该特征。要选择正确的Decorator,检查原版的地形特征,你自己的应该要类似。装饰器配置是从这个分支出来的,在''CHANCE''的情况下,你应该传入''ChanceDecoratorConfig''的实例。 
  
 ==== 向生物群落添加Feature ==== ==== 向生物群落添加Feature ====
zh_cn/tutorial/features.txt · Last modified: 2022/08/18 03:37 by solidblock